//========= Copyright Valve Corporation, All rights reserved. ============// // TOGL CODE LICENSE // // Copyright 2011-2014 Valve Corporation // All Rights Reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // // dxabstract_types.h // //================================================================================================== #ifndef DXABSTRACT_TYPES_H #define DXABSTRACT_TYPES_H #pragma once #if GL_BATCH_PERF_ANALYSIS class simple_bitmap; #endif struct IUnknown; struct IDirect3D9; struct IDirect3DDevice9; struct IDirect3DResource9; struct IDirect3DBaseTexture9; struct IDirect3DTexture9; struct IDirect3DCubeTexture9; struct IDirect3DVolumeTexture9; struct IDirect3DSurface9; struct IDirect3DVertexDeclaration9; struct IDirect3DQuery9; struct IDirect3DVertexBuffer9; struct IDirect3DIndexBuffer9; struct IDirect3DPixelShader9; struct IDirect3DVertexShader9; struct IDirect3DDevice9Params; class GLMContext; struct GLMRect; struct GLMShaderPairInfo; class CGLMBuffer; class CGLMQuery; class CGLMTex; class CGLMProgram; class CGLMFBO; #ifdef TOGL_DLL_EXPORT #define TOGL_INTERFACE DLL_EXPORT #define TOGL_OVERLOAD DLL_GLOBAL_EXPORT #define TOGL_CLASS DLL_CLASS_EXPORT #define TOGL_GLOBAL DLL_GLOBAL_EXPORT #else #define TOGL_INTERFACE DLL_IMPORT #define TOGL_OVERLOAD DLL_GLOBAL_IMPORT #define TOGL_CLASS DLL_CLASS_IMPORT #define TOGL_GLOBAL DLL_GLOBAL_IMPORT #endif #define TOGLMETHODCALLTYPE __stdcall //#define TOGLMETHODCALLTYPE #define DXABSTRACT_BREAK_ON_ERROR() DebuggerBreak() typedef void* VD3DHWND; typedef void* VD3DHANDLE; #define MAKEFOURCC(ch0, ch1, ch2, ch3) ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) // // // Stuff that would be in windows.h // // #if !defined(_WINNT_) typedef int INT; typedef unsigned long ULONG; typedef long LONG; typedef float FLOAT; typedef unsigned int DWORD; typedef unsigned short WORD; typedef long long LONGLONG; typedef unsigned int UINT; typedef long HRESULT; typedef unsigned char BYTE; #define CONST const #if defined(POSIX) typedef size_t ULONG_PTR; #else typedef unsigned long ULONG_PTR; #endif typedef ULONG_PTR SIZE_T; typedef const char* LPCSTR; typedef char* LPSTR; typedef DWORD* LPDWORD; #define ZeroMemory RtlZeroMemory #define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length)) typedef union _LARGE_INTEGER { struct { DWORD LowPart; LONG HighPart; }; struct { DWORD LowPart; LONG HighPart; } u; LONGLONG QuadPart; } LARGE_INTEGER; typedef struct _GUID { bool operator==( const struct _GUID &other ) const; unsigned long Data1; unsigned short Data2; unsigned short Data3; unsigned char Data4[ 8 ]; } GUID; typedef struct _RECT { int left; int top; int right; int bottom; } RECT; typedef struct tagPOINT { LONG x; LONG y; } POINT, *PPOINT, *LPPOINT; typedef struct _MEMORYSTATUS { DWORD dwLength; SIZE_T dwTotalPhys; } MEMORYSTATUS, *LPMEMORYSTATUS; typedef DWORD COLORREF; #define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16))) #define MAKE_HRESULT(sev,fac,code) ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) ) #define S_FALSE ((HRESULT)0x00000001L) #define S_OK 0 #define E_FAIL ((HRESULT)0x80004005L) #define E_OUTOFMEMORY ((HRESULT)0x8007000EL) #define FAILED(hr) ((HRESULT)(hr) < 0) #define SUCCEEDED(hr) ((HRESULT)(hr) >= 0) struct RGNDATA { }; typedef const void* LPCVOID; #endif //----------------------------------------------------------------------------- typedef enum _D3DFORMAT D3DFORMAT; #define D3DSI_OPCODE_MASK 0x0000FFFF #define D3DSP_TEXTURETYPE_MASK 0x78000000 #define D3DUSAGE_AUTOGENMIPMAP 0x00000400L #define D3DSP_DCL_USAGE_MASK 0x0000000f #define D3DSP_OPCODESPECIFICCONTROL_MASK 0x00ff0000 #define D3DSP_OPCODESPECIFICCONTROL_SHIFT 16 // Comparison for dynamic conditional instruction opcodes (i.e. if, breakc) typedef enum _D3DSHADER_COMPARISON { // < = > D3DSPC_RESERVED0= 0, // 0 0 0 D3DSPC_GT = 1, // 0 0 1 D3DSPC_EQ = 2, // 0 1 0 D3DSPC_GE = 3, // 0 1 1 D3DSPC_LT = 4, // 1 0 0 D3DSPC_NE = 5, // 1 0 1 D3DSPC_LE = 6, // 1 1 0 D3DSPC_RESERVED1= 7 // 1 1 1 } D3DSHADER_COMPARISON; // Comparison is part of instruction opcode token: #define D3DSHADER_COMPARISON_SHIFT D3DSP_OPCODESPECIFICCONTROL_SHIFT #define D3DSHADER_COMPARISON_MASK (0x7<>8)&0xFF) #define D3DSHADER_VERSION_MINOR(_Version) (((_Version)>>0)&0xFF) #define D3DSHADER_ADDRESSMODE_SHIFT 13 #define D3DSHADER_ADDRESSMODE_MASK (1 << D3DSHADER_ADDRESSMODE_SHIFT) #define D3DPS_END() 0x0000FFFF // ps_2_0 texld controls #define D3DSI_TEXLD_PROJECT (0x01 << D3DSP_OPCODESPECIFICCONTROL_SHIFT) #define D3DSI_TEXLD_BIAS (0x02 << D3DSP_OPCODESPECIFICCONTROL_SHIFT) // destination parameter write mask #define D3DSP_WRITEMASK_0 0x00010000 // Component 0 (X;Red) #define D3DSP_WRITEMASK_1 0x00020000 // Component 1 (Y;Green) #define D3DSP_WRITEMASK_2 0x00040000 // Component 2 (Z;Blue) #define D3DSP_WRITEMASK_3 0x00080000 // Component 3 (W;Alpha) #define D3DSP_WRITEMASK_ALL 0x000F0000 // All Components #define D3DVS_SWIZZLE_SHIFT 16 #define D3DVS_SWIZZLE_MASK 0x00FF0000 // The following bits define where to take component X from: #define D3DVS_X_X (0 << D3DVS_SWIZZLE_SHIFT) #define D3DVS_X_Y (1 << D3DVS_SWIZZLE_SHIFT) #define D3DVS_X_Z (2 << D3DVS_SWIZZLE_SHIFT) #define D3DVS_X_W (3 << D3DVS_SWIZZLE_SHIFT) // The following bits define where to take component Y from: #define D3DVS_Y_X (0 << (D3DVS_SWIZZLE_SHIFT + 2)) #define D3DVS_Y_Y (1 << (D3DVS_SWIZZLE_SHIFT + 2)) #define D3DVS_Y_Z (2 << (D3DVS_SWIZZLE_SHIFT + 2)) #define D3DVS_Y_W (3 << (D3DVS_SWIZZLE_SHIFT + 2)) // The following bits define where to take component Z from: #define D3DVS_Z_X (0 << (D3DVS_SWIZZLE_SHIFT + 4)) #define D3DVS_Z_Y (1 << (D3DVS_SWIZZLE_SHIFT + 4)) #define D3DVS_Z_Z (2 << (D3DVS_SWIZZLE_SHIFT + 4)) #define D3DVS_Z_W (3 << (D3DVS_SWIZZLE_SHIFT + 4)) // The following bits define where to take component W from: #define D3DVS_W_X (0 << (D3DVS_SWIZZLE_SHIFT + 6)) #define D3DVS_W_Y (1 << (D3DVS_SWIZZLE_SHIFT + 6)) #define D3DVS_W_Z (2 << (D3DVS_SWIZZLE_SHIFT + 6)) #define D3DVS_W_W (3 << (D3DVS_SWIZZLE_SHIFT + 6)) // source parameter modifiers #define D3DSP_SRCMOD_SHIFT 24 #define D3DSP_SRCMOD_MASK 0x0F000000 // ------------------------------------------------------------------------------------------------------------------------------ // // ENUMS // ------------------------------------------------------------------------------------------------------------------------------ // typedef enum _D3DSHADER_PARAM_SRCMOD_TYPE { D3DSPSM_NONE = 0<= 2.0 D3DDECLTYPE_UBYTE4N = 8, // Each of 4 bytes is normalized by dividing to 255.0 D3DDECLTYPE_SHORT2N = 9, // 2D signed short normalized (v[0]/32767.0,v[1]/32767.0,0,1) D3DDECLTYPE_SHORT4N = 10, // 4D signed short normalized (v[0]/32767.0,v[1]/32767.0,v[2]/32767.0,v[3]/32767.0) D3DDECLTYPE_USHORT2N = 11, // 2D unsigned short normalized (v[0]/65535.0,v[1]/65535.0,0,1) D3DDECLTYPE_USHORT4N = 12, // 4D unsigned short normalized (v[0]/65535.0,v[1]/65535.0,v[2]/65535.0,v[3]/65535.0) D3DDECLTYPE_UDEC3 = 13, // 3D unsigned 10 10 10 format expanded to (value, value, value, 1) D3DDECLTYPE_DEC3N = 14, // 3D signed 10 10 10 format normalized and expanded to (v[0]/511.0, v[1]/511.0, v[2]/511.0, 1) D3DDECLTYPE_FLOAT16_2 = 15, // Two 16-bit floating point values, expanded to (value, value, 0, 1) D3DDECLTYPE_FLOAT16_4 = 16, // Four 16-bit floating point values D3DDECLTYPE_UNUSED = 17, // When the type field in a decl is unused. } D3DDECLTYPE; typedef enum _D3DDECLMETHOD { D3DDECLMETHOD_DEFAULT = 0, D3DDECLMETHOD_PARTIALU, D3DDECLMETHOD_PARTIALV, D3DDECLMETHOD_CROSSUV, // Normal D3DDECLMETHOD_UV, D3DDECLMETHOD_LOOKUP, // Lookup a displacement map D3DDECLMETHOD_LOOKUPPRESAMPLED, // Lookup a pre-sampled displacement map } D3DDECLMETHOD; typedef enum _D3DDECLUSAGE { D3DDECLUSAGE_POSITION = 0, D3DDECLUSAGE_BLENDWEIGHT = 1, D3DDECLUSAGE_BLENDINDICES = 2, D3DDECLUSAGE_NORMAL = 3, D3DDECLUSAGE_PSIZE = 4, D3DDECLUSAGE_TEXCOORD = 5, D3DDECLUSAGE_TANGENT = 6, D3DDECLUSAGE_BINORMAL = 7, D3DDECLUSAGE_TESSFACTOR = 8, D3DDECLUSAGE_PLUGH = 9, // mystery value D3DDECLUSAGE_COLOR = 10, D3DDECLUSAGE_FOG = 11, D3DDECLUSAGE_DEPTH = 12, D3DDECLUSAGE_SAMPLE = 13, } D3DDECLUSAGE; typedef enum _D3DPRIMITIVETYPE { D3DPT_POINTLIST = 1, D3DPT_LINELIST = 2, D3DPT_TRIANGLELIST = 4, D3DPT_TRIANGLESTRIP = 5, D3DPT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ } D3DPRIMITIVETYPE; // ------------------------------------------------------------------------------------------------------------------------------ // // STRUCTURES // ------------------------------------------------------------------------------------------------------------------------------ // typedef struct TOGL_CLASS D3DXPLANE { float& operator[]( int i ); bool operator==( const D3DXPLANE &o ); bool operator!=( const D3DXPLANE &o ); operator float*(); operator const float*() const; float a, b, c, d; } D3DXPLANE; typedef enum _D3DVERTEXBLENDFLAGS { D3DVBF_DISABLE = 0, // Disable vertex blending D3DVBF_1WEIGHTS = 1, // 2 matrix blending D3DVBF_2WEIGHTS = 2, // 3 matrix blending D3DVBF_3WEIGHTS = 3, // 4 matrix blending D3DVBF_TWEENING = 255, // blending using D3DRS_TWEENFACTOR D3DVBF_0WEIGHTS = 256, // one matrix is used with weight 1.0 D3DVBF_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum } D3DVERTEXBLENDFLAGS; typedef struct _D3DINDEXBUFFER_DESC { D3DFORMAT Format; D3DRESOURCETYPE Type; DWORD Usage; D3DPOOL Pool; UINT Size; } D3DINDEXBUFFER_DESC; typedef struct _D3DVERTEXELEMENT9 { WORD Stream; // Stream index WORD Offset; // Offset in the stream in bytes BYTE Type; // Data type BYTE Method; // Processing method BYTE Usage; // Semantics BYTE UsageIndex; // Semantic index } D3DVERTEXELEMENT9, *LPD3DVERTEXELEMENT9; #define MAX_DEVICE_IDENTIFIER_STRING 512 typedef struct _D3DADAPTER_IDENTIFIER9 { char Driver[MAX_DEVICE_IDENTIFIER_STRING]; char Description[MAX_DEVICE_IDENTIFIER_STRING]; char DeviceName[32]; /* Device name for GDI (ex. \\.\DISPLAY1) */ LARGE_INTEGER DriverVersion; /* Defined for 32 bit components */ DWORD VendorId; DWORD DeviceId; DWORD SubSysId; DWORD Revision; DWORD VideoMemory; } D3DADAPTER_IDENTIFIER9; typedef struct _D3DCOLORVALUE { float r; float g; float b; float a; } D3DCOLORVALUE; typedef struct _D3DMATERIAL9 { D3DCOLORVALUE Diffuse; /* Diffuse color RGBA */ D3DCOLORVALUE Ambient; /* Ambient color RGB */ D3DCOLORVALUE Specular; /* Specular 'shininess' */ D3DCOLORVALUE Emissive; /* Emissive color RGB */ float Power; /* Sharpness if specular highlight */ } D3DMATERIAL9; typedef struct _D3DVOLUME_DESC { D3DFORMAT Format; D3DRESOURCETYPE Type; DWORD Usage; D3DPOOL Pool; UINT Width; UINT Height; UINT Depth; } D3DVOLUME_DESC; typedef struct _D3DVIEWPORT9 { DWORD X; DWORD Y; /* Viewport Top left */ DWORD Width; DWORD Height; /* Viewport Dimensions */ float MinZ; /* Min/max of clip Volume */ float MaxZ; } D3DVIEWPORT9; typedef struct _D3DPSHADERCAPS2_0 { DWORD Caps; INT DynamicFlowControlDepth; INT NumTemps; INT StaticFlowControlDepth; INT NumInstructionSlots; } D3DPSHADERCAPS2_0; typedef struct _D3DCAPS9 { /* Device Info */ D3DDEVTYPE DeviceType; /* Caps from DX7 Draw */ DWORD Caps; DWORD Caps2; /* Cursor Caps */ DWORD CursorCaps; /* 3D Device Caps */ DWORD DevCaps; DWORD PrimitiveMiscCaps; DWORD RasterCaps; DWORD TextureCaps; DWORD TextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture9's DWORD MaxTextureWidth, MaxTextureHeight; DWORD MaxVolumeExtent; DWORD MaxTextureAspectRatio; DWORD MaxAnisotropy; DWORD TextureOpCaps; DWORD MaxTextureBlendStages; DWORD MaxSimultaneousTextures; DWORD VertexProcessingCaps; DWORD MaxActiveLights; DWORD MaxUserClipPlanes; DWORD MaxVertexBlendMatrices; DWORD MaxVertexBlendMatrixIndex; DWORD MaxPrimitiveCount; // max number of primitives per DrawPrimitive call DWORD MaxStreams; DWORD VertexShaderVersion; DWORD MaxVertexShaderConst; // number of vertex shader constant registers DWORD PixelShaderVersion; // Here are the DX9 specific ones DWORD DevCaps2; D3DPSHADERCAPS2_0 PS20Caps; DWORD NumSimultaneousRTs; // Will be at least 1 DWORD MaxVertexShader30InstructionSlots; DWORD MaxPixelShader30InstructionSlots; // only on Posix/GL DWORD FakeSRGBWrite; // 1 for parts which can't support SRGB writes due to driver issues - 0 for others DWORD MixedSizeTargets; // 1 for parts which can mix attachment sizes (RT's color vs depth) DWORD CanDoSRGBReadFromRTs; // 0 when we're on Leopard, 1 when on Snow Leopard } D3DCAPS9; typedef struct _D3DDISPLAYMODE { UINT Width; UINT Height; UINT RefreshRate; D3DFORMAT Format; } D3DDISPLAYMODE; typedef struct _D3DGAMMARAMP { WORD red [256]; WORD green[256]; WORD blue [256]; } D3DGAMMARAMP; /* Resize Optional Parameters */ typedef struct _D3DPRESENT_PARAMETERS_ { UINT BackBufferWidth; UINT BackBufferHeight; D3DFORMAT BackBufferFormat; UINT BackBufferCount; D3DMULTISAMPLE_TYPE MultiSampleType; DWORD MultiSampleQuality; D3DSWAPEFFECT SwapEffect; VD3DHWND hDeviceWindow; BOOL Windowed; BOOL EnableAutoDepthStencil; D3DFORMAT AutoDepthStencilFormat; DWORD Flags; /* FullScreen_RefreshRateInHz must be zero for Windowed mode */ UINT FullScreen_RefreshRateInHz; UINT PresentationInterval; } D3DPRESENT_PARAMETERS; typedef struct _D3DDEVICE_CREATION_PARAMETERS { UINT AdapterOrdinal; D3DDEVTYPE DeviceType; VD3DHWND hFocusWindow; DWORD BehaviorFlags; } D3DDEVICE_CREATION_PARAMETERS; /* Structures for LockBox */ typedef struct _D3DBOX { UINT Left; UINT Top; UINT Right; UINT Bottom; UINT Front; UINT Back; } D3DBOX; typedef struct _D3DLOCKED_BOX { INT RowPitch; INT SlicePitch; void* pBits; } D3DLOCKED_BOX; typedef struct _D3DSURFACE_DESC { D3DFORMAT Format; D3DRESOURCETYPE Type; DWORD Usage; D3DPOOL Pool; D3DMULTISAMPLE_TYPE MultiSampleType; DWORD MultiSampleQuality; UINT Width; UINT Height; } D3DSURFACE_DESC; typedef struct _D3DLOCKED_RECT { INT Pitch; void* pBits; } D3DLOCKED_RECT; typedef struct _D3DRASTER_STATUS { BOOL InVBlank; UINT ScanLine; } D3DRASTER_STATUS; typedef enum _D3DLIGHTTYPE { D3DLIGHT_POINT = 1, D3DLIGHT_SPOT = 2, D3DLIGHT_DIRECTIONAL = 3, D3DLIGHT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ } D3DLIGHTTYPE; typedef struct TOGL_CLASS _D3DVECTOR { float x; float y; float z; } D3DVECTOR; class TOGL_CLASS D3DXVECTOR2 { public: operator FLOAT* (); operator CONST FLOAT* () const; float x,y; }; class TOGL_CLASS D3DXVECTOR3 : public D3DVECTOR { public: D3DXVECTOR3() {} D3DXVECTOR3( float a, float b, float c ); operator FLOAT* (); operator CONST FLOAT* () const; }; typedef enum _D3DXINCLUDE_TYPE { D3DXINC_LOCAL, // force 32-bit size enum D3DXINC_FORCE_DWORD = 0x7fffffff } D3DXINCLUDE_TYPE; typedef struct _D3DLIGHT9 { D3DLIGHTTYPE Type; /* Type of light source */ D3DCOLORVALUE Diffuse; /* Diffuse color of light */ D3DCOLORVALUE Specular; /* Specular color of light */ D3DCOLORVALUE Ambient; /* Ambient color of light */ D3DVECTOR Position; /* Position in world space */ D3DVECTOR Direction; /* Direction in world space */ float Range; /* Cutoff range */ float Falloff; /* Falloff */ float Attenuation0; /* Constant attenuation */ float Attenuation1; /* Linear attenuation */ float Attenuation2; /* Quadratic attenuation */ float Theta; /* Inner angle of spotlight cone */ float Phi; /* Outer angle of spotlight cone */ } D3DLIGHT9; class TOGL_CLASS D3DXVECTOR4 { public: D3DXVECTOR4() {} D3DXVECTOR4( float a, float b, float c, float d ); float x,y,z,w; }; //---------------------------------------------------------------------------- // D3DXMACRO: // ---------- // Preprocessor macro definition. The application pass in a NULL-terminated // array of this structure to various D3DX APIs. This enables the application // to #define tokens at runtime, before the file is parsed. //---------------------------------------------------------------------------- typedef struct _D3DXMACRO { LPCSTR Name; LPCSTR Definition; } D3DXMACRO, *LPD3DXMACRO; // ------------------------------------------------------------------------------------------------------------------------------ // // ------------------------------------------------------------------------------------------------------------------------------ // // **** FIXED FUNCTION STUFF - None of this stuff needs support in GL. // // Also look for any functions marked with "**** FIXED FUNCTION STUFF" // // It's only laying around here so we don't have to chop up the shader system a lot to strip out the fixed function code paths. // ------------------------------------------------------------------------------------------------------------------------------ // // ------------------------------------------------------------------------------------------------------------------------------ // // **** FIXED FUNCTION STUFF - None of this stuff needs support in GL. typedef enum _D3DTRANSFORMSTATETYPE { D3DTS_VIEW = 2, D3DTS_PROJECTION = 3, D3DTS_TEXTURE0 = 16, D3DTS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ } D3DTRANSFORMSTATETYPE; // **** FIXED FUNCTION STUFF - None of this stuff needs support in GL. typedef enum _D3DTEXTUREOP { // Control D3DTOP_DISABLE = 1, // disables stage D3DTOP_SELECTARG1 = 2, // the default D3DTOP_SELECTARG2 = 3, // Modulate D3DTOP_MODULATE = 4, // multiply args together D3DTOP_MODULATE2X = 5, // multiply and 1 bit D3DTOP_MODULATE4X = 6, // multiply and 2 bits // Add D3DTOP_ADD = 7, // add arguments together D3DTOP_ADDSIGNED = 8, // add with -0.5 bias D3DTOP_ADDSIGNED2X = 9, // as above but left 1 bit D3DTOP_SUBTRACT = 10, // Arg1 - Arg2, with no saturation D3DTOP_ADDSMOOTH = 11, // add 2 args, subtract product // Arg1 + Arg2 - Arg1*Arg2 // = Arg1 + (1-Arg1)*Arg2 // Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha) D3DTOP_BLENDDIFFUSEALPHA = 12, // iterated alpha D3DTOP_BLENDTEXTUREALPHA = 13, // texture alpha D3DTOP_BLENDFACTORALPHA = 14, // alpha from D3DRS_TEXTUREFACTOR // Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha) D3DTOP_BLENDTEXTUREALPHAPM = 15, // texture alpha D3DTOP_BLENDCURRENTALPHA = 16, // by alpha of current color // Specular mapping D3DTOP_PREMODULATE = 17, // modulate with next texture before use D3DTOP_MODULATEALPHA_ADDCOLOR = 18, // Arg1.RGB + Arg1.A*Arg2.RGB // COLOROP only D3DTOP_MODULATECOLOR_ADDALPHA = 19, // Arg1.RGB*Arg2.RGB + Arg1.A // COLOROP only D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20, // (1-Arg1.A)*Arg2.RGB + Arg1.RGB // COLOROP only D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21, // (1-Arg1.RGB)*Arg2.RGB + Arg1.A // COLOROP only // Bump mapping D3DTOP_BUMPENVMAP = 22, // per pixel env map perturbation D3DTOP_BUMPENVMAPLUMINANCE = 23, // with luminance channel // This can do either diffuse or specular bump mapping with correct input. // Performs the function (Arg1.R*Arg2.R + Arg1.G*Arg2.G + Arg1.B*Arg2.B) // where each component has been scaled and offset to make it signed. // The result is replicated into all four (including alpha) channels. // This is a valid COLOROP only. D3DTOP_DOTPRODUCT3 = 24, // Triadic ops D3DTOP_MULTIPLYADD = 25, // Arg0 + Arg1*Arg2 D3DTOP_LERP = 26, // (Arg0)*Arg1 + (1-Arg0)*Arg2 D3DTOP_FORCE_DWORD = 0x7fffffff, } D3DTEXTUREOP; // **** FIXED FUNCTION STUFF - None of this stuff needs support in GL. typedef enum _D3DTEXTURESTAGESTATETYPE { D3DTSS_COLOROP = 1, /* D3DTEXTUREOP - per-stage blending controls for color channels */ D3DTSS_COLORARG1 = 2, /* D3DTA_* (texture arg) */ D3DTSS_COLORARG2 = 3, /* D3DTA_* (texture arg) */ D3DTSS_ALPHAOP = 4, /* D3DTEXTUREOP - per-stage blending controls for alpha channel */ D3DTSS_ALPHAARG1 = 5, /* D3DTA_* (texture arg) */ D3DTSS_ALPHAARG2 = 6, /* D3DTA_* (texture arg) */ D3DTSS_BUMPENVMAT00 = 7, /* float (bump mapping matrix) */ D3DTSS_BUMPENVMAT01 = 8, /* float (bump mapping matrix) */ D3DTSS_BUMPENVMAT10 = 9, /* float (bump mapping matrix) */ D3DTSS_BUMPENVMAT11 = 10, /* float (bump mapping matrix) */ D3DTSS_TEXCOORDINDEX = 11, /* identifies which set of texture coordinates index this texture */ D3DTSS_BUMPENVLOFFSET = 23, /* float offset for bump map luminance */ D3DTSS_TEXTURETRANSFORMFLAGS = 24, /* D3DTEXTURETRANSFORMFLAGS controls texture transform */ D3DTSS_COLORARG0 = 26, /* D3DTA_* third arg for triadic ops */ D3DTSS_RESULTARG = 28, /* D3DTA_* arg for result (CURRENT or TEMP) */ D3DTSS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ } D3DTEXTURESTAGESTATETYPE; //===========================================================================// enum GLMVertexAttributeIndex { kGLMGenericAttr00 = 0, kGLMGenericAttr01, kGLMGenericAttr02, kGLMGenericAttr03, kGLMGenericAttr04, kGLMGenericAttr05, kGLMGenericAttr06, kGLMGenericAttr07, kGLMGenericAttr08, kGLMGenericAttr09, kGLMGenericAttr10, kGLMGenericAttr11, kGLMGenericAttr12, kGLMGenericAttr13, kGLMGenericAttr14, kGLMGenericAttr15, kGLMVertexAttributeIndexMax // ideally < 32 }; struct GLMVertexAttributeDesc // all the info you need to do vertex setup for one attribute { CGLMBuffer *m_pBuffer; // NULL allowed in which case m_offset is the full 32-bit pointer.. so you can draw from plain RAM if desired GLuint m_nCompCount; // comp count of the attribute (1-4) GLenum m_datatype; // data type of the attribute (GL_FLOAT, GL_UNSIGNED_BYTE, etc) GLuint m_stride; GLuint m_offset; // net offset to attribute 'zero' within the buffer. GLuint m_streamOffset; // net offset to attribute 'zero' within the buffer. GLboolean m_normalized; // apply to any fixed point data that needs normalizing, esp color bytes inline uint GetDataTypeSizeInBytes() const { switch ( m_datatype ) { case GL_BYTE: case GL_UNSIGNED_BYTE: return 1; case GL_SHORT: case GL_UNSIGNED_SHORT: case GL_HALF_FLOAT: return 2; case GL_INT: case GL_FLOAT: return 4; default: Assert( 0 ); break; } return 0; } inline uint GetTotalAttributeSizeInBytes() const { Assert( m_nCompCount ); return m_nCompCount * GetDataTypeSizeInBytes(); } // may need a seed value at some point to be able to disambiguate re-lifed buffers holding same pointer // simpler alternative is to do shoot-down inside the vertex/index buffer free calls. // I'd rather not have to have each attribute fiddling a ref count on the buffer to which it refers.. //#define EQ(fff) ( (src.fff) == (fff) ) // test in decreasing order of likelihood of difference, but do not include the buffer revision as caller is not supplying it.. //inline bool operator== ( const GLMVertexAttributeDesc& src ) const { return EQ( m_pBuffer ) && EQ( m_offset ) && EQ( m_stride ) && EQ( m_datatype ) && EQ( m_normalized ) && EQ( m_nCompCount ); } //#undef EQ uint m_bufferRevision; // only set in GLM context's copy, to disambiguate references that are same offset / same buffer but cross an orphan event }; #define MAX_D3DVERTEXELEMENTS 16 struct D3DVERTEXELEMENT9_GL { // fields right out of the original decl element (copied) D3DVERTEXELEMENT9 m_dxdecl; // d3d info // WORD Stream; // Stream index // WORD Offset; // Offset in the stream in bytes // BYTE Type; // Data type // BYTE Method; // Processing method // BYTE Usage; // Semantics // BYTE UsageIndex; // Semantic index GLMVertexAttributeDesc m_gldecl; // CGLMBuffer *m_buffer; // late-dropped from selected stream desc (left NULL, will replace with stream source buffer at sync time) // GLuint m_datasize; // component count (1,2,3,4) of the attrib // GLenum m_datatype; // data type of the attribute (GL_FLOAT et al) // GLuint m_stride; // late-dropped from stream desc // GLuint m_offset; // net offset to attribute 'zero' within the stream data. Add the stream offset before passing to GL. // GLuint m_normalized; // net offset to attribute 'zero' within the stream data. Add the stream offset before passing to GL. }; struct IDirect3DDevice9Params { UINT m_adapter; D3DDEVTYPE m_deviceType; VD3DHWND m_focusWindow; DWORD m_behaviorFlags; D3DPRESENT_PARAMETERS m_presentationParameters; }; #define D3D_MAX_STREAMS 5 //9 struct D3DStreamDesc { IDirect3DVertexBuffer9 *m_vtxBuffer; uint m_offset; uint m_stride; }; struct D3DIndexDesc { IDirect3DIndexBuffer9 *m_idxBuffer; }; // we latch sampler values until draw time and then convert them all to GL form // note these are similar in name to the fields of a GLMTexSamplingParams but contents are not // particularly in the texture filtering area struct D3DSamplerDesc { DWORD m_srgb; // D3DSAMP_SRGBTEXTURE 0 = no SRGB sampling }; // Tracking and naming sampler dimensions #define SAMPLER_TYPE_2D 0 #define SAMPLER_TYPE_CUBE 1 #define SAMPLER_TYPE_3D 2 #define SAMPLER_TYPE_UNUSED 3 #endif // DXABSTRACT_TYPES_H