MMD3DTyp.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:42k
- {========================================================================}
- {= (c) 1995-98 SwiftSoft Ronald Dittrich =}
- {========================================================================}
- {= All Rights Reserved =}
- {========================================================================}
- {= D 01099 Dresden = Tel.: +0351-8012255 =}
- {= Loewenstr.7a = info@swiftsoft.de =}
- {========================================================================}
- {= Actual versions on http://www.swiftsoft.de/mmtools.html =}
- {========================================================================}
- {= This code is for reference purposes only and may not be copied or =}
- {= distributed in any format electronic or otherwise except one copy =}
- {= for backup purposes. =}
- {= =}
- {= No Delphi Component Kit or Component individually or in a collection=}
- {= subclassed or otherwise from the code in this unit, or associated =}
- {= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
- {= without express permission from SwiftSoft. =}
- {= =}
- {= For more licence informations please refer to the associated =}
- {= HelpFile. =}
- {========================================================================}
- {= $Date: 20.01.1998 - 18:00:00 $ =}
- {========================================================================}
- {= Aufgabe: Direct3D types Unit =}
- {========================================================================}
- {= This code is for reference purposes only and may not be copied or =}
- {= distributed in any format electronic or otherwise except one copy =}
- {= for backup purposes. =}
- {= =}
- {= No Delphi Component Kit or Component individually or in a collection=}
- {= subclassed or otherwise from the code in this unit, or associated =}
- {= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
- {= without express permission from SwiftSoft. =}
- {= =}
- {= For more licence informations please refer to the associated =}
- {= HelpFile. =}
- {========================================================================}
- unit MMD3DTyp;
- {$I COMPILER.INC}
- interface
- uses
- Windows,
- MMDDraw;
- type
- FLOAT = Single;
- LONG = LongInt;
- PVOID = Pointer;
- D3DENUM = DWORD;
- {-- D3DVALUE is the fundamental Direct3D fractional data type ----------------}
- type
- PD3DVALUE = ^D3DVALUE;
- D3DVALUE = FLOAT;
- function D3DVALP(val: Extended; prec: Integer): D3DVALUE;
- function D3DVAL(val: Extended): D3DVALUE;
- function D3DDivide(a, b: D3DVALUE): D3DVALUE;
- function D3DMultiply(a, b: D3DVALUE): D3DVALUE;
- type
- D3DFIXED = LONG;
- PD3DCOLOR = ^D3DCOLOR;
- D3DCOLOR = DWORD;
- //
- // Format of CI colors is
- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // | alpha | color index | fraction |
- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- //
- function CI_GETALPHA(ci: D3DCOLOR): Byte;
- function CI_GETINDEX(ci: D3DCOLOR): Word;
- function CI_GETFRACTION(ci: D3DCOLOR): Byte;
- function CI_ROUNDINDEX(ci: D3DCOLOR): Word;
- function CI_MASKALPHA(ci: D3DCOLOR): DWord;
- function CI_MAKE(a: Byte; i: Word; f: Byte): D3DCOLOR;
- //
- // Format of RGBA colors is
- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // | alpha | red | green | blue |
- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- //
- function RGBA_GETALPHA(rgb: D3DCOLOR): Byte;
- function RGBA_GETRED(rgb: D3DCOLOR): Byte;
- function RGBA_GETGREEN(rgb: D3DCOLOR): Byte;
- function RGBA_GETBLUE(rgb: D3DCOLOR): Byte;
- function RGBA_MAKE(r, g, b, a: Byte): D3DCOLOR;
- //
- // D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs
- // The float values must be in the range 0..1
- //
- function D3DRGB(r, g, b: D3DVALUE): D3DCOLOR;
- function D3DRGBA(r, g, b, a: D3DVALUE): D3DCOLOR;
- //
- // Format of RGB colors is
- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // | ignored | red | green | blue |
- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- //
- function RGB_GETRED(rgb: D3DCOLOR): Byte;
- function RGB_GETGREEN(rgb: D3DCOLOR): Byte;
- function RGB_GETBLUE(rgb: D3DCOLOR): Byte;
- function RGBA_SETALPHA(rgba: D3DCOLOR; x: Byte): D3DCOLOR;
- function RGB_MAKE(r, g, b: Byte): D3DCOLOR;
- function RGBA_TORGB(rgba: D3DCOLOR): D3DCOLOR;
- function RGB_TORGBA(rgb: D3DCOLOR): D3DCOLOR;
- {== Flags for Enumerate functions ============================================}
- const
- {-- Stop the enumeration -----------------------------------------------------}
- D3DENUMRET_CANCEL = DDENUMRET_CANCEL;
- {-- Continue the enumeration -------------------------------------------------}
- D3DENUMRET_OK = DDENUMRET_OK;
- type
- TD3DVALIDATECALLBACK = function(lpUserArg: PVOID; dwOffset: DWORD): HRESULT; stdcall;
- TD3DENUMTEXTUREFORMATSCALLBACK = function(lpDdsd: PDDSURFACEDESC; lpContext: PVOID): HRESULT; stdcall;
- PD3DMATERIALHANDLE = ^D3DMATERIALHANDLE;
- D3DMATERIALHANDLE = DWORD;
- PD3DTEXTUREHANDLE = ^D3DTEXTUREHANDLE;
- D3DTEXTUREHANDLE = DWORD;
- PD3DMATRIXHANDLE = ^D3DMATRIXHANDLE;
- D3DMATRIXHANDLE = DWORD;
- TD3DCOLORVALUE = record
- case Byte of
- 0: (r, g, b, a : D3DVALUE);
- 1: (dvR, dvG, dvB, dvA : D3DVALUE);
- end;
- PD3DRECT = ^TD3DRECT;
- TD3DRECT = record
- case Byte of
- 0: (x1, y1, x2, y2: LONG);
- 1: (lX1, lY1, lX2, lY2: LONG);
- end;
- PD3DVECTOR = ^TD3DVECTOR;
- TD3DVECTOR = record
- case Byte of
- 0: (x, y, z: D3DVALUE);
- 1: (dvX, dvY, dvZ: D3DVALUE);
- end;
- {== Vertext data types supported in an ExecuteBuffer =========================}
- {-- Homogenous vertices ------------------------------------------------------}
- type
- PD3DHVERTEX = ^TD3DHVERTEX;
- TD3DHVERTEX = record
- dwFlags : DWORD; // Homogeneous clipping flags
- case Byte of
- 0: (hx, hy, hz: D3DVALUE);
- 1: (dvHX, dvHY, dvHZ: D3DVALUE);
- end;
- {-- Transformed/lit vertices -------------------------------------------------}
- PD3DTLVERTEX = ^TD3DTLVERTEX;
- TD3DTLVERTEX = record
- case Byte of
- 0: (
- sx : D3DVALUE; // Screen coordinates
- sy : D3DVALUE;
- sz : D3DVALUE;
- rhw : D3DVALUE; // Reciprocal of homogeneous w
- color : D3DCOLOR; // Vertex color
- specular : D3DCOLOR; // Specular component of vertex
- tu : D3DVALUE; // Texture coordinates
- tv : D3DVALUE
- );
- 1: (
- dvSX : D3DVALUE;
- dvSY : D3DVALUE;
- dvSZ : D3DVALUE;
- dvRHW : D3DVALUE;
- dcColor : D3DCOLOR;
- dcSpecular : D3DCOLOR;
- dvTU : D3DVALUE;
- dvTV : D3DVALUE
- );
- end;
- {-- Untransformed/lit vertices -----------------------------------------------}
- PD3DLVERTEX = ^TD3DLVERTEX;
- TD3DLVERTEX = record
- case Byte of
- 0: (
- x : D3DVALUE; // Screen coordinates
- y : D3DVALUE;
- z : D3DVALUE;
- dwReserved : DWORD;
- color : D3DCOLOR; // Vertex color
- specular : D3DCOLOR; // Specular component of vertex
- tu : D3DVALUE; // Texture coordinates
- tv : D3DVALUE
- );
- 1: (
- dvX : D3DVALUE;
- dvY : D3DVALUE;
- dvZ : D3DVALUE;
- _dwReserved : DWORD;
- dcColor : D3DCOLOR;
- dcSpecular : D3DCOLOR;
- dvTU : D3DVALUE;
- dvTV : D3DVALUE
- );
- end;
- {-- Untransformed/unlit vertices ---------------------------------------------}
- PD3DVERTEX = ^TD3DVERTEX;
- TD3DVERTEX = record
- case Byte of
- 0: (
- x : D3DVALUE; // Screen coordinates
- y : D3DVALUE;
- z : D3DVALUE;
- nx : D3DVALUE; // Normal
- ny : D3DVALUE;
- nz : D3DVALUE;
- tu : D3DVALUE; // Texture coordinates
- tv : D3DVALUE
- );
- 1: (
- dvX : D3DVALUE;
- dvY : D3DVALUE;
- dvZ : D3DVALUE;
- dvNX : D3DVALUE;
- dvNY : D3DVALUE;
- dvNZ : D3DVALUE;
- dvTU : D3DVALUE;
- dvTV : D3DVALUE
- );
- end;
- {-- Matrix, viewport, and transformation structures and definitions ----------}
- PD3DMATRIX = ^TD3DMATRIX;
- TD3DMATRIX = record
- _11, _12, _13, _14 : D3DVALUE;
- _21, _22, _23, _24 : D3DVALUE;
- _31, _32, _33, _34 : D3DVALUE;
- _41, _42, _43, _44 : D3DVALUE;
- end;
- PD3DVIEWPORT = ^TD3DVIEWPORT;
- TD3DVIEWPORT = record
- dwSize : DWORD;
- dwX : DWORD;
- dwY : DWORD; // Top left
- dwWidth : DWORD;
- dwHeight : DWORD; // Dimensions
- dvScaleX : D3DVALUE; // Scale homogeneous to screen
- dvScaleY : D3DVALUE; // Scale homogeneous to screen
- dvMaxX : D3DVALUE; // Min/max homogeneous x coord
- dvMaxY : D3DVALUE; // Min/max homogeneous y coord
- dvMinZ : D3DVALUE;
- dvMaxZ : D3DVALUE; // Min/max homogeneous z coord
- end;
- {-- Values for clip fields ---------------------------------------------------}
- const
- D3DCLIP_LEFT = $00000001 ;
- D3DCLIP_RIGHT = $00000002 ;
- D3DCLIP_TOP = $00000004 ;
- D3DCLIP_BOTTOM = $00000008 ;
- D3DCLIP_FRONT = $00000010 ;
- D3DCLIP_BACK = $00000020 ;
- D3DCLIP_GEN0 = $00000040 ;
- D3DCLIP_GEN1 = $00000080 ;
- D3DCLIP_GEN2 = $00000100 ;
- D3DCLIP_GEN3 = $00000200 ;
- D3DCLIP_GEN4 = $00000400 ;
- D3DCLIP_GEN5 = $00000800 ;
- {-- Values for D3D status ----------------------------------------------------}
- D3DSTATUS_CLIPUNIONLEFT = D3DCLIP_LEFT;
- D3DSTATUS_CLIPUNIONRIGHT = D3DCLIP_RIGHT;
- D3DSTATUS_CLIPUNIONTOP = D3DCLIP_TOP;
- D3DSTATUS_CLIPUNIONBOTTOM = D3DCLIP_BOTTOM;
- D3DSTATUS_CLIPUNIONFRONT = D3DCLIP_FRONT;
- D3DSTATUS_CLIPUNIONBACK = D3DCLIP_BACK;
- D3DSTATUS_CLIPUNIONGEN0 = D3DCLIP_GEN0;
- D3DSTATUS_CLIPUNIONGEN1 = D3DCLIP_GEN1;
- D3DSTATUS_CLIPUNIONGEN2 = D3DCLIP_GEN2;
- D3DSTATUS_CLIPUNIONGEN3 = D3DCLIP_GEN3;
- D3DSTATUS_CLIPUNIONGEN4 = D3DCLIP_GEN4;
- D3DSTATUS_CLIPUNIONGEN5 = D3DCLIP_GEN5;
- D3DSTATUS_CLIPINTERSECTIONLEFT = $00001000;
- D3DSTATUS_CLIPINTERSECTIONRIGHT = $00002000;
- D3DSTATUS_CLIPINTERSECTIONTOP = $00004000;
- D3DSTATUS_CLIPINTERSECTIONBOTTOM= $00008000;
- D3DSTATUS_CLIPINTERSECTIONFRONT = $00010000;
- D3DSTATUS_CLIPINTERSECTIONBACK = $00020000;
- D3DSTATUS_CLIPINTERSECTIONGEN0 = $00040000;
- D3DSTATUS_CLIPINTERSECTIONGEN1 = $00080000;
- D3DSTATUS_CLIPINTERSECTIONGEN2 = $00100000;
- D3DSTATUS_CLIPINTERSECTIONGEN3 = $00200000;
- D3DSTATUS_CLIPINTERSECTIONGEN4 = $00400000;
- D3DSTATUS_CLIPINTERSECTIONGEN5 = $00800000;
- D3DSTATUS_ZNOTVISIBLE = $01000000;
- D3DSTATUS_CLIPUNIONALL =
- D3DSTATUS_CLIPUNIONLEFT or
- D3DSTATUS_CLIPUNIONRIGHT or
- D3DSTATUS_CLIPUNIONTOP or
- D3DSTATUS_CLIPUNIONBOTTOM or
- D3DSTATUS_CLIPUNIONFRONT or
- D3DSTATUS_CLIPUNIONBACK or
- D3DSTATUS_CLIPUNIONGEN0 or
- D3DSTATUS_CLIPUNIONGEN1 or
- D3DSTATUS_CLIPUNIONGEN2 or
- D3DSTATUS_CLIPUNIONGEN3 or
- D3DSTATUS_CLIPUNIONGEN4 or
- D3DSTATUS_CLIPUNIONGEN5
- ;
- D3DSTATUS_CLIPINTERSECTIONALL =
- D3DSTATUS_CLIPINTERSECTIONLEFT or
- D3DSTATUS_CLIPINTERSECTIONRIGHT or
- D3DSTATUS_CLIPINTERSECTIONTOP or
- D3DSTATUS_CLIPINTERSECTIONBOTTOM or
- D3DSTATUS_CLIPINTERSECTIONFRONT or
- D3DSTATUS_CLIPINTERSECTIONBACK or
- D3DSTATUS_CLIPINTERSECTIONGEN0 or
- D3DSTATUS_CLIPINTERSECTIONGEN1 or
- D3DSTATUS_CLIPINTERSECTIONGEN2 or
- D3DSTATUS_CLIPINTERSECTIONGEN3 or
- D3DSTATUS_CLIPINTERSECTIONGEN4 or
- D3DSTATUS_CLIPINTERSECTIONGEN5
- ;
- D3DSTATUS_DEFAULT =
- D3DSTATUS_CLIPINTERSECTIONALL or
- D3DSTATUS_ZNOTVISIBLE
- ;
- {-- Options for direct transform calls ---------------------------------------}
- D3DTRANSFORM_CLIPPED = $00000001;
- D3DTRANSFORM_UNCLIPPED = $00000002;
- type
- PD3DTRANSFORMDATA = ^TD3DTRANSFORMDATA;
- TD3DTRANSFORMDATA = record
- dwSize : DWORD;
- lpIn : PVOID; // Input vertices
- dwInSize : DWORD; // Stride of input vertices
- lpOut : PVOID; // Output vertices
- dwOutSize : DWORD; // Stride of output vertices
- lpHOut : PD3DHVERTEX; // Output homogeneous vertices
- dwClip : DWORD; // Clipping hint
- dwClipIntersection : DWORD;
- dwClipUnion : DWORD; // Union of all clip flags
- drExtent : TD3DRECT; // Extent of transformed vertices
- end;
- {-- Structure defining position and direction properties for lightning -------}
- PD3DLIGHTINGELEMENT = ^TD3DLIGHTINGELEMENT;
- TD3DLIGHTINGELEMENT = record
- dvPosition : TD3DVECTOR; // Lightable point in model space
- dvNormal : TD3DVECTOR; // Normalised unit vector
- end;
- {-- Structure defining material properties for lightning ---------------------}
- PD3DMATERIAL = ^TD3DMATERIAL;
- TD3DMATERIAL = record
- dwSize : DWORD;
- case Byte of
- 0: (diffuse : TD3DCOLORVALUE; // Diffuse color RGBA
- ambient : TD3DCOLORVALUE; // Ambient color RGB
- specular : TD3DCOLORVALUE; // Specular 'shininess'
- emissive : TD3DCOLORVALUE; // Emissive color RGB
- power : D3DVALUE; // Sharpness if specular highlight
- );
- 1: (dcvDiffuse : TD3DCOLORVALUE;
- dcvAmbient : TD3DCOLORVALUE;
- dcvSpecular : TD3DCOLORVALUE;
- dcvEmissive : TD3DCOLORVALUE;
- dvPower : D3DVALUE;
- hTexture : D3DTEXTUREHANDLE; // Handle to texture map
- dwRampSize : DWORD;
- );
- end;
- type
- D3DLIGHTTYPE = D3DENUM;
- const
- D3DLIGHT_POINT = 1;
- D3DLIGHT_SPOT = 2;
- D3DLIGHT_DIRECTIONAL = 3;
- D3DLIGHT_PARALLELPOINT = 4;
- D3DLIGHT_GLSPOT = 5;
- {-- Structure defining a light source and its properties ---------------------}
- type
- PD3DLIGHT = ^TD3DLIGHT;
- TD3DLIGHT = record
- dwSize : DWORD;
- dltType : D3DLIGHTTYPE; // Type of light source
- dcvColor : TD3DCOLORVALUE; // Color of light
- dvPosition : TD3DVECTOR; // Position in world space
- dvDirection : TD3DVECTOR; // Direction in world space
- dvRange : D3DVALUE; // Cutoff range
- dvFalloff : D3DVALUE; // Falloff
- dvAttenuation0 : D3DVALUE; // Constant attenuation
- dvAttenuation1 : D3DVALUE; // Linear attenuation
- dvAttenuation2 : D3DVALUE; // Quadratic attenuation
- dvTheta : D3DVALUE; // Inner angle of spotlight cone
- dvPhi : D3DVALUE; // Outer angle of spotlight cone
- end;
- PD3DLIGHTDATA = ^TD3DLIGHTDATA;
- TD3DLIGHTDATA = record
- dwSize : DWORD;
- lpIn : PD3DLIGHTINGELEMENT; // Input positions and normals
- dwInSize : DWORD; // Stride of input elements
- lpOut : PD3DTLVERTEX; // Output colors
- dwOutSize : DWORD; // Stride of output colors
- end;
- D3DCOLORMODEL = D3DENUM;
- const
- D3DCOLOR_MONO = 1;
- D3DCOLOR_RGB = 2;
- {-- Options for clearing -----------------------------------------------------}
- D3DCLEAR_TARGET = $00000001; // Clear target surface
- D3DCLEAR_ZBUFFER = $00000002; // Clear target z buffer
- //
- // Execute buffers are allocated via Direct3D. These buffers may then
- // be filled by the application with instructions to execute along with
- // vertex data.
- //
- //
- // Supported op codes for execute instructions.
- //
- type
- D3DOPCODE = D3DENUM;
- const
- D3DOP_POINT = 1;
- D3DOP_LINE = 2;
- D3DOP_TRIANGLE = 3;
- D3DOP_MATRIXLOAD = 4;
- D3DOP_MATRIXMULTIPLY = 5;
- D3DOP_STATETRANSFORM = 6;
- D3DOP_STATELIGHT = 7;
- D3DOP_STATERENDER = 8;
- D3DOP_PROCESSVERTICES = 9;
- D3DOP_TEXTURELOAD = 10;
- D3DOP_EXIT = 11;
- D3DOP_BRANCHFORWARD = 12;
- D3DOP_SPAN = 13;
- D3DOP_SETSTATUS = 14;
- type
- PD3DINSTRUCTION = ^TD3DINSTRUCTION;
- TD3DINSTRUCTION = record
- bOpcode : BYTE; // Instruction opcode
- bSize : BYTE; // Size of each instruction data unit
- wCount : WORD; // Count of instruction data units to follow
- end;
- {-- Structure for texture loads ----------------------------------------------}
- PD3DTEXTURELOAD = ^TD3DTEXTURELOAD;
- TD3DTEXTURELOAD = record
- hDestTexture : D3DTEXTUREHANDLE;
- hSrcTexture : D3DTEXTUREHANDLE;
- end;
- {-- Structure for picking ----------------------------------------------------}
- PD3DPICKRECORD = ^TD3DPICKRECORD;
- TD3DPICKRECORD = record
- bOpcode : BYTE;
- bPad : BYTE;
- dwOffset : DWORD;
- dvZ : D3DVALUE;
- end;
- {-- Following defines the rendering states which can be set in execute buf ---}
- type
- D3DSHADEMODE = D3DENUM;
- const
- D3DSHADE_FLAT = 1;
- D3DSHADE_GOURAUD = 2;
- D3DSHADE_PHONG = 3;
- type
- D3DFILLMODE = D3DENUM;
- const
- D3DFILL_POINT = 1;
- D3DFILL_WIREFRAME = 2;
- D3DFILL_SOLID = 3;
- type
- PD3DLINEPATTERN = ^TD3DLINEPATTERN;
- TD3DLINEPATTERN = record
- wRepeatFactor : WORD;
- wLinePattern : WORD;
- end;
- D3DTEXTUREFILTER = D3DENUM;
- const
- D3DFILTER_NEAREST = 1;
- D3DFILTER_LINEAR = 2;
- D3DFILTER_MIPNEAREST = 3;
- D3DFILTER_MIPLINEAR = 4;
- D3DFILTER_LINEARMIPNEAREST = 5;
- D3DFILTER_LINEARMIPLINEAR = 6;
- type
- D3DBLEND = D3DENUM;
- const
- D3DBLEND_ZERO = 1;
- D3DBLEND_ONE = 2;
- D3DBLEND_SRCCOLOR = 3;
- D3DBLEND_INVSRCCOLOR = 4;
- D3DBLEND_SRCALPHA = 5;
- D3DBLEND_INVSRCALPHA = 6;
- D3DBLEND_DESTALPHA = 7;
- D3DBLEND_INVDESTALPHA = 8;
- D3DBLEND_DESTCOLOR = 9;
- D3DBLEND_INVDESTCOLOR = 10;
- D3DBLEND_SRCALPHASAT = 11;
- D3DBLEND_BOTHSRCALPHA = 12;
- D3DBLEND_BOTHINVSRCALPHA = 13;
- type
- D3DTEXTUREBLEND = D3DENUM;
- const
- D3DTBLEND_DECAL = 1;
- D3DTBLEND_MODULATE = 2;
- D3DTBLEND_DECALALPHA = 3;
- D3DTBLEND_MODULATEALPHA = 4;
- D3DTBLEND_DECALMASK = 5;
- D3DTBLEND_MODULATEMASK = 6;
- D3DTBLEND_COPY = 7;
- type
- D3DTEXTUREADDRESS = D3DENUM;
- const
- D3DTADDRESS_WRAP = 1;
- D3DTADDRESS_MIRROR = 2;
- D3DTADDRESS_CLAMP = 3;
- type
- D3DCULL = D3DENUM;
- const
- D3DCULL_NONE = 1;
- D3DCULL_CW = 2;
- D3DCULL_CCW = 3;
- type
- D3DCMPFUNC = D3DENUM;
- const
- D3DCMP_NEVER = 1;
- D3DCMP_LESS = 2;
- D3DCMP_EQUAL = 3;
- D3DCMP_LESSEQUAL = 4;
- D3DCMP_GREATER = 5;
- D3DCMP_NOTEQUAL = 6;
- D3DCMP_GREATEREQUAL = 7;
- D3DCMP_ALWAYS = 8;
- type
- D3DFOGMODE = D3DENUM;
- const
- D3DFOG_NONE = 0;
- D3DFOG_EXP = 1;
- D3DFOG_EXP2 = 2;
- D3DFOG_LINEAR = 3;
- {-- Amount to add to a state to generate the override for that state ---------}
- const
- D3DSTATE_OVERRIDE_BIAS = 256;
- {-- A state which sets the override flag for the specified state type --------}
- function D3DSTATE_OVERRIDE(_type: DWORD): DWORD;
- type
- D3DTRANSFORMSTATETYPE = D3DENUM;
- const
- D3DTRANSFORMSTATE_WORLD = 1;
- D3DTRANSFORMSTATE_VIEW = 2;
- D3DTRANSFORMSTATE_PROJECTION = 3;
- type
- D3DLIGHTSTATETYPE = D3DENUM;
- const
- D3DLIGHTSTATE_MATERIAL = 1;
- D3DLIGHTSTATE_AMBIENT = 2;
- D3DLIGHTSTATE_COLORMODEL = 3;
- D3DLIGHTSTATE_FOGMODE = 4;
- D3DLIGHTSTATE_FOGSTART = 5;
- D3DLIGHTSTATE_FOGEND = 6;
- D3DLIGHTSTATE_FOGDENSITY = 7;
- type
- D3DRENDERSTATETYPE = D3DENUM;
- const
- D3DRENDERSTATE_TEXTUREHANDLE = 1; // Texture handle
- D3DRENDERSTATE_ANTIALIAS = 2; // Antialiasing prim edges
- D3DRENDERSTATE_TEXTUREADDRESS = 3; // D3DTEXTUREADDRESS
- D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4; // TRUE for perspective correction
- D3DRENDERSTATE_WRAPU = 5; // TRUE for wrapping in u
- D3DRENDERSTATE_WRAPV = 6; // TRUE for wrapping in v
- D3DRENDERSTATE_ZENABLE = 7; // TRUE to enable z test
- D3DRENDERSTATE_FILLMODE = 8; // D3DFILL_MODE
- D3DRENDERSTATE_SHADEMODE = 9; // D3DSHADEMODE
- D3DRENDERSTATE_LINEPATTERN = 10; // D3DLINEPATTERN
- D3DRENDERSTATE_MONOENABLE = 11; // TRUE to enable mono rasterization
- D3DRENDERSTATE_ROP2 = 12; // ROP2
- D3DRENDERSTATE_PLANEMASK = 13; // DWORD physical plane mask
- D3DRENDERSTATE_ZWRITEENABLE = 14; // TRUE to enable z writes
- D3DRENDERSTATE_ALPHATESTENABLE = 15; // TRUE to enable alpha tests
- D3DRENDERSTATE_LASTPIXEL = 16; // TRUE for last-pixel on lines
- D3DRENDERSTATE_TEXTUREMAG = 17; // D3DTEXTUREFILTER
- D3DRENDERSTATE_TEXTUREMIN = 18; // D3DTEXTUREFILTER
- D3DRENDERSTATE_SRCBLEND = 19; // D3DBLEND
- D3DRENDERSTATE_DESTBLEND = 20; // D3DBLEND
- D3DRENDERSTATE_TEXTUREMAPBLEND = 21; // D3DTEXTUREBLEND
- D3DRENDERSTATE_CULLMODE = 22; // D3DCULL
- D3DRENDERSTATE_ZFUNC = 23; // D3DCMPFUNC
- D3DRENDERSTATE_ALPHAREF = 24; // D3DFIXED
- D3DRENDERSTATE_ALPHAFUNC = 25; // D3DCMPFUNC
- D3DRENDERSTATE_DITHERENABLE = 26; // TRUE to enable dithering
- D3DRENDERSTATE_BLENDENABLE = 27; // TRUE to enable alpha blending
- D3DRENDERSTATE_FOGENABLE = 28; // TRUE to enable fog
- D3DRENDERSTATE_SPECULARENABLE = 29; // TRUE to enable specular
- D3DRENDERSTATE_ZVISIBLE = 30; // TRUE to enable z checking
- D3DRENDERSTATE_SUBPIXEL = 31; // TRUE to enable subpixel correction
- D3DRENDERSTATE_SUBPIXELX = 32; // TRUE to enable correction in X only
- D3DRENDERSTATE_STIPPLEDALPHA = 33; // TRUE to enable stippled alpha
- D3DRENDERSTATE_FOGCOLOR = 34; // D3DCOLOR
- D3DRENDERSTATE_FOGTABLEMODE = 35; // D3DFOGMODE
- D3DRENDERSTATE_FOGTABLESTART = 36; // Fog table start
- D3DRENDERSTATE_FOGTABLEEND = 37; // Fog table end
- D3DRENDERSTATE_FOGTABLEDENSITY = 38; // Fog table density
- D3DRENDERSTATE_STIPPLEENABLE = 39; // TRUE to enable stippling
- D3DRENDERSTATE_STIPPLEPATTERN00 = 64; // Stipple pattern 01...
- D3DRENDERSTATE_STIPPLEPATTERN01 = 65;
- D3DRENDERSTATE_STIPPLEPATTERN02 = 66;
- D3DRENDERSTATE_STIPPLEPATTERN03 = 67;
- D3DRENDERSTATE_STIPPLEPATTERN04 = 68;
- D3DRENDERSTATE_STIPPLEPATTERN05 = 69;
- D3DRENDERSTATE_STIPPLEPATTERN06 = 70;
- D3DRENDERSTATE_STIPPLEPATTERN07 = 71;
- D3DRENDERSTATE_STIPPLEPATTERN08 = 72;
- D3DRENDERSTATE_STIPPLEPATTERN09 = 73;
- D3DRENDERSTATE_STIPPLEPATTERN10 = 74;
- D3DRENDERSTATE_STIPPLEPATTERN11 = 75;
- D3DRENDERSTATE_STIPPLEPATTERN12 = 76;
- D3DRENDERSTATE_STIPPLEPATTERN13 = 77;
- D3DRENDERSTATE_STIPPLEPATTERN14 = 78;
- D3DRENDERSTATE_STIPPLEPATTERN15 = 79;
- D3DRENDERSTATE_STIPPLEPATTERN16 = 80;
- D3DRENDERSTATE_STIPPLEPATTERN17 = 81;
- D3DRENDERSTATE_STIPPLEPATTERN18 = 82;
- D3DRENDERSTATE_STIPPLEPATTERN19 = 83;
- D3DRENDERSTATE_STIPPLEPATTERN20 = 84;
- D3DRENDERSTATE_STIPPLEPATTERN21 = 85;
- D3DRENDERSTATE_STIPPLEPATTERN22 = 86;
- D3DRENDERSTATE_STIPPLEPATTERN23 = 87;
- D3DRENDERSTATE_STIPPLEPATTERN24 = 88;
- D3DRENDERSTATE_STIPPLEPATTERN25 = 89;
- D3DRENDERSTATE_STIPPLEPATTERN26 = 90;
- D3DRENDERSTATE_STIPPLEPATTERN27 = 91;
- D3DRENDERSTATE_STIPPLEPATTERN28 = 92;
- D3DRENDERSTATE_STIPPLEPATTERN29 = 93;
- D3DRENDERSTATE_STIPPLEPATTERN30 = 94;
- D3DRENDERSTATE_STIPPLEPATTERN31 = 95;
- function D3DRENDERSTATE_STIPPLEPATTERN(y: D3DRENDERSTATETYPE): D3DRENDERSTATETYPE;
- type
- TStateType = record
- case Byte of
- 0: (dtstTransformStateType : D3DTRANSFORMSTATETYPE);
- 1: (dlstLightStateType : D3DLIGHTSTATETYPE);
- 2: (drstRenderStateType : D3DRENDERSTATETYPE);
- end;
- PD3DSTATE = ^TD3DSTATE;
- TD3DSTATE = record
- stType : TStateType;
- case Byte of
- 0: (dwArg: array[0..0] of DWORD);
- 1: (dvArg: array[0..0] of D3DVALUE);
- end;
- {-- Operation used to load matrices (hDstMat = hSrcMat) ----------------------}
- PD3DMATRIXLOAD = ^TD3DMATRIXLOAD;
- TD3DMATRIXLOAD = record
- hDestMatrix : D3DMATRIXHANDLE; // Destination matrix
- hSrcMatrix : D3DMATRIXHANDLE; // Source matrix
- end;
- {-- Operation used to multiply matrices (hDstMat = hSrcMat1 * hSrcMat2) ------}
- PD3DMATRIXMULTIPLY = ^TD3DMATRIXMULTIPLY;
- TD3DMATRIXMULTIPLY = record
- hDestMatrix : D3DMATRIXHANDLE; // Destination matrix
- hSrcMatrix1 : D3DMATRIXHANDLE; // First source matrix
- hSrcMatrix2 : D3DMATRIXHANDLE; // Second source matrix
- end;
- {-- Operation used to transform and light vertices ---------------------------}
- PD3DPROCESSVERTICES = ^TD3DPROCESSVERTICES;
- TD3DPROCESSVERTICES = record
- dwFlags : DWORD; // Do we transform or light or just copy?
- wStart : WORD; // Index to first vertex in source
- wDest : WORD; // Index to first vertex in local buffer
- dwCount : DWORD; // Number of vertices to be processed
- dwReserved : DWORD; // Must be zero
- end;
- const
- D3DPROCESSVERTICES_TRANSFORMLIGHT = $00000000;
- D3DPROCESSVERTICES_TRANSFORM = $00000001;
- D3DPROCESSVERTICES_COPY = $00000002;
- D3DPROCESSVERTICES_OPMASK = $00000007;
- D3DPROCESSVERTICES_UPDATEEXTENTS = $00000008;
- D3DPROCESSVERTICES_NOCOLOR = $00000010;
- {== Triangle flags ===========================================================}
- {-- Tri strip and fan flags --------------------------------------------------}
- //
- // START loads all three vertices
- // EVEN and ODD load just v3 with even or odd culling
- // START_FLAT contains a count from 0 to 29 that allows the
- // whole strip or fan to be culled in one hit.
- // e.g. for a quad len = 1
- //
- const
- D3DTRIFLAG_START = $00000000;
- // 0 < len < 30
- function D3DTRIFLAG_STARTFLAT(len: DWORD): DWORD;
- const
- D3DTRIFLAG_ODD = $0000001e;
- D3DTRIFLAG_EVEN = $0000001f;
- {-- Triangle edge flags - enable edges for wireframe or antialiasing ---------}
- const
- D3DTRIFLAG_EDGEENABLE1 = $00000100; // v0-v1 edge
- D3DTRIFLAG_EDGEENABLE2 = $00000200; // v1-v2 edge
- D3DTRIFLAG_EDGEENABLE3 = $00000400; // v2-v0 edge
- D3DTRIFLAG_EDGEENABLETRIANGLE = D3DTRIFLAG_EDGEENABLE1 or D3DTRIFLAG_EDGEENABLE2 or D3DTRIFLAG_EDGEENABLE3;
- {== Primitive structures and related defines =================================}
- // Vertex offsets are to types D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX.
- {-- Triangle list primitive structure ----------------------------------------}
- type
- PD3DTRIANGLE = ^TD3DTRIANGLE;
- TD3DTRIANGLE = record
- case Byte of
- 0: (v1, v2, v3: WORD); // Vertex indices
- 1: (wV1, wV2, wV3,
- wFlags: WORD); // Edge (and other) flags
- end;
- {-- Line strip structure - the instr count - 1 defines the num of line segs --}
- PD3DLINE = ^TD3DLINE;
- TD3DLINE = record
- case Byte of
- 0: (v1, v2: WORD); // Vertex indices
- 1: (wV1, wV2: WORD);
- end;
- {-- Span structure -----------------------------------------------------------}
- // Spans join a list of points with the same y value.
- // If the y value changes, a new span is started.
- PD3DSPAN = ^TD3DSPAN;
- TD3DSPAN = record
- wCount : WORD; // Number of spans
- wFirst : WORD; // Index to first vertex
- end;
- {-- Point structure ----------------------------------------------------------}
- PD3DPOINT = ^TD3DPOINT;
- TD3DPOINT = record
- wCount : WORD; // number of points
- wFirst : WORD; // index to first vertex
- end;
- {-- Forward branch structure -------------------------------------------------}
- // Mask is logically anded with the driver status mask
- // if the result equals 'value', the branch is taken.
- PD3DBRANCH = ^TD3DBRANCH;
- TD3DBRANCH = record
- dwMask : DWORD; // Bitmask against D3D status
- dwValue : DWORD;
- bNegate : BOOL; // TRUE to negate comparison
- dwOffset : DWORD; // How far to branch forward (0 for exit)
- end;
- {-- Status used for set status instruction -----------------------------------}
- // The D3D status is initialised on device creation
- // and is modified by all execute calls.
- PD3DSTATUS = ^TD3DSTATUS;
- TD3DSTATUS = record
- dwFlags : DWORD; // Do we set extents or status
- dwStatus : DWORD; // D3D status
- drExtent : TD3DRECT;
- end;
- const
- D3DSETSTATUS_STATUS = $00000001;
- D3DSETSTATUS_EXTENTS = $00000002;
- D3DSETSTATUS_ALL = (D3DSETSTATUS_STATUS or D3DSETSTATUS_EXTENTS);
- {-- Statistics structure -----------------------------------------------------}
- type
- PD3DSTATS = ^TD3DSTATS;
- TD3DSTATS = record
- dwSize : DWORD;
- dwTrianglesDrawn : DWORD;
- dwLinesDrawn : DWORD;
- dwPointsDrawn : DWORD;
- dwSpansDrawn : DWORD;
- dwVerticesProcessed : DWORD;
- end;
- {-- Execute options ----------------------------------------------------------}
- // When calling using D3DEXECUTE_UNCLIPPED all the primitives
- // inside the buffer must be contained within the viewport.
- const
- D3DEXECUTE_CLIPPED = $00000001;
- D3DEXECUTE_UNCLIPPED = $00000002;
- type
- PD3DEXECUTEDATA = ^TD3DEXECUTEDATA;
- TD3DEXECUTEDATA = record
- dwSize : DWORD;
- dwVertexOffset : DWORD;
- dwVertexCount : DWORD;
- dwInstructionOffset : DWORD;
- dwInstructionLength : DWORD;
- dwHVertexOffset : DWORD;
- dsStatus : TD3DSTATUS; // Status after execute
- end;
- {-- Palette flags ------------------------------------------------------------}
- // This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw.
- const
- D3DPAL_FREE = $00; // Renderer may use this entry freely
- D3DPAL_READONLY = $40; // Renderer may not set this entry
- D3DPAL_RESERVED = $80; // Renderer may not use this entry
- function D3DVector(vX,vY,vZ: D3DValue): TD3DVECTOR;
- implementation
- function D3DVector(vX,vY,vZ: D3DValue): TD3DVECTOR;
- begin
- with Result do
- begin
- X := vX;
- Y := vY;
- Z := vZ;
- end;
- end;
- function D3DVALP(val: Extended; prec: Integer): D3DVALUE;
- begin
- Result := val;
- end;
- function D3DVAL(val: Extended): D3DVALUE;
- begin
- Result := val;
- end;
- function D3DDivide(a, b: D3DVALUE): D3DVALUE;
- begin
- Result := a / b;
- end;
- function D3DMultiply(a, b: D3DVALUE): D3DVALUE;
- begin
- Result := a * b;
- end;
- function CI_GETALPHA(ci: D3DCOLOR): Byte;
- begin
- Result := ci shr 24;
- end;
- function CI_GETINDEX(ci: D3DCOLOR): Word;
- begin
- Result := (ci shr 8) and $ffff;
- end;
- function CI_GETFRACTION(ci: D3DCOLOR): Byte;
- begin
- Result := ci and $ff;
- end;
- function CI_ROUNDINDEX(ci: D3DCOLOR): Word;
- begin
- Result := CI_GETINDEX(ci + $80);
- end;
- function CI_MASKALPHA(ci: D3DCOLOR): DWord;
- begin
- Result := ci and $ffffff;
- end;
- function CI_MAKE(a: Byte; i: Word; f: Byte): D3DCOLOR;
- begin
- Result := (a shl 24) or (i shl 8) or f;
- end;
- function RGBA_GETALPHA(rgb: D3DCOLOR): Byte;
- begin
- Result := rgb shr 24;
- end;
- function RGBA_GETRED(rgb: D3DCOLOR): Byte;
- begin
- Result := (rgb shr 16) and $ff;
- end;
- function RGBA_GETGREEN(rgb: D3DCOLOR): Byte;
- begin
- Result := (rgb shr 8) and $ff;
- end;
- function RGBA_GETBLUE(rgb: D3DCOLOR): Byte;
- begin
- Result := rgb and $ff;
- end;
- function RGBA_MAKE(r, g, b, a: Byte): D3DCOLOR;
- begin
- Result := (a shl 24) or (r shl 16) or (g shl 8) or b;
- end;
- function D3DRGB(r, g, b: D3DVALUE): D3DCOLOR;
- begin
- Result := $ff000000 or (Trunc(r * 255) shl 16) or (Trunc(g * 255) shl 8) or Trunc(b * 255);
- end;
- function D3DRGBA(r, g, b, a: D3DVALUE): D3DCOLOR;
- begin
- Result := (Trunc(a * 255) shl 24) or (Trunc(r * 255) shl 16) or (Trunc(g * 255) shl 8) or Trunc(b * 255);
- end;
- function RGB_GETRED(rgb: D3DCOLOR): Byte;
- begin
- Result := (rgb shr 16) and $ff;
- end;
- function RGB_GETGREEN(rgb: D3DCOLOR): Byte;
- begin
- Result := (rgb shr 8) and $ff;
- end;
- function RGB_GETBLUE(rgb: D3DCOLOR): Byte;
- begin
- Result := rgb and $ff;
- end;
- function RGBA_SETALPHA(rgba: D3DCOLOR; x: Byte): D3DCOLOR;
- begin
- Result := (x shl 24) or (rgba and $00ffffff);
- end;
- function RGB_MAKE(r, g, b: Byte): D3DCOLOR;
- begin
- Result := (r shl 16) or (g shl 8) or b;
- end;
- function RGBA_TORGB(rgba: D3DCOLOR): D3DCOLOR;
- begin
- Result := rgba and $ffffff;
- end;
- function RGB_TORGBA(rgb: D3DCOLOR): D3DCOLOR;
- begin
- Result := rgb or $ff000000;
- end;
- {-- A state which sets the override flag for the specified state type --------}
- function D3DSTATE_OVERRIDE(_type: DWORD): DWORD;
- begin
- Result := _type + D3DSTATE_OVERRIDE_BIAS;
- end;
- function D3DRENDERSTATE_STIPPLEPATTERN(y: D3DRENDERSTATETYPE): D3DRENDERSTATETYPE;
- begin
- Result := D3DRENDERSTATE_STIPPLEPATTERN00 + y;
- end;
- function D3DTRIFLAG_STARTFLAT(len: DWORD): DWORD;
- begin
- Result := len;
- end;
- end.