home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 December / Chip_2001-12_cd1.bin / zkuste / delphi / kompon / d56 / CMDXCAP.ZIP / DirectXGraphics.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-03-14  |  108.3 KB  |  2,631 lines

  1. (*==========================================================================;
  2.  *
  3.  *  Copyright (C) 1995-2000 Microsoft Corporation.  All Rights Reserved.
  4.  *
  5.  *  Files : d3d8types.h d3d8caps.h d3d8.h
  6.  *
  7.  *  DirectX 8.0 Delphi adaptation by Tim Baumgarten
  8.  *
  9.  *  Modified: 14-Mar-2001 (032WE2001 Edition)
  10.  *
  11.  *  E-Mail : Ampaze@gmx.net
  12.  *
  13.  ***************************************************************************)
  14.  
  15. (*==========================================================================;
  16.  * History :
  17.  *
  18.  * 14-Mar-2001 (Tim Baumgarten) : Changed CreateVertexShader as pFunction can be nil
  19.  * 28-Jan-2001 (Tim Baumgarten) : Added TD3DMultiSampleType = TD3DMultiSample_Type;
  20.  * 23-Dec-2000 (Tim Baumgarten) : Changed all types that are declared as UInt in C to be Cardinal in Delphi
  21.  *                              : Changed all types that are declared as DWord in C to be LongWord in Delphi
  22.  * 14-Dec-2000 (Tim Baumgarten) : Changed some parameters of IDirect3DDevice8.DrawRectPatch and IDirect3DDevice8.DrawTriPatch to Pointers.
  23.  *                              : Added versions without underlines of some structures
  24.  *                              : Added "Pointer to Structure" (PStructure = ^TStructure) to all structures.
  25.  * 26-Nov-2000 (Tim Baumgarten) : Returncodes are now typecasted with HResult
  26.  *
  27.  ***************************************************************************)
  28.  
  29. unit DirectXGraphics;
  30.  
  31. {$MINENUMSIZE 4}
  32. {$ALIGN ON}
  33.  
  34. interface
  35.  
  36. uses
  37.   Windows;
  38.  
  39. var
  40.   D3D8DLL : HMODULE;
  41.  
  42. (*==========================================================================;
  43.  *
  44.  *  Copyright (C) 1995-2000 Microsoft Corporation.  All Rights Reserved.
  45.  *
  46.  *  File:       d3d8types.h
  47.  *  Content:    Direct3D capabilities include file
  48.  *
  49.  ***************************************************************************)
  50.  
  51. const
  52.   DIRECT3D_VERSION = $0800;
  53.  
  54.  
  55. type
  56.   TD3DColor = type LongWord;
  57.  
  58.   // maps unsigned 8 bits/channel to D3DCOLOR
  59.   function D3DCOLOR_ARGB(a, r, g, b : Cardinal) : TD3DColor; // ((D3DCOLOR)((((a)&= $ff)<<24)|(((r)&= $ff)<<16)|(((g)&= $ff)<<8)|((b)&= $ff)))
  60.   function D3DCOLOR_RGBA(r, g, b, a : Cardinal) : TD3DColor; // D3DCOLOR_ARGB(a;r;g;b)
  61.   function D3DCOLOR_XRGB(r, g, b : Cardinal) : TD3DColor; //   D3DCOLOR_ARGB(= $ff;r;g;b)
  62.  
  63. // maps floating point channels (0.f to 1.f range) to D3DCOLOR
  64.   function D3DCOLOR_COLORVALUE(r, g, b, a : Single) : TD3DColor; // D3DCOLOR_RGBA((DWORD)((r)*255.f);(DWORD)((g)*255.f);(DWORD)((b)*255.f);(DWORD)((a)*255.f))
  65.  
  66. type
  67.   PD3DVector = ^TD3DVector;
  68.   TD3DVector = packed record
  69.     x : Single;
  70.     y : Single;
  71.     z : Single;
  72.   end;
  73.  
  74.   PD3DColorValue = ^TD3DColorValue;
  75.   TD3DColorValue = packed record
  76.     r : Single;
  77.     g : Single;
  78.     b : Single;
  79.     a : Single;
  80.   end;
  81.  
  82.   PD3DRect = ^TD3DRect;
  83.   TD3DRect = packed record
  84.     x1 : LongInt;
  85.     y1 : LongInt;
  86.     x2 : LongInt;
  87.     y2 : LongInt;
  88.   end;
  89.  
  90.   PD3DMatrix = ^TD3DMatrix;
  91.   TD3DMatrix = packed record
  92.     case Integer of
  93.       0 : (_11, _12, _13, _14 : Single;
  94.            _21, _22, _23, _24 : Single;
  95.            _31, _32, _33, _34 : Single;
  96.            _41, _42, _43, _44 : Single);
  97.       1 : (m : array [0..3, 0..3] of Single);
  98.   end;
  99.  
  100.   PD3DViewport8 = ^TD3DViewport8;
  101.   TD3DViewport8 = packed record
  102.     X      : LongWord;
  103.     Y      : LongWord;  (* Viewport Top left *)
  104.     Width  : LongWord;
  105.     Height : LongWord;  (* Viewport Dimensions *)
  106.     MinZ   : Single;    (* Min/max of clip Volume *)
  107.     MaxZ   : Single
  108.   end;
  109.  
  110.  
  111. (*
  112.  * Values for clip fields.
  113.  *)
  114.  
  115. // Max number of user clipping planes; supported in D3D.
  116. const
  117.   D3DMAXUSERCLIPPLANES = 32;
  118.  
  119. // These bits could be ORed together to use with D3DRS_CLIPPLANEENABLE
  120. //                 shl
  121.   D3DCLIPPLANE0 = 1;   // (1 << 0)
  122.   D3DCLIPPLANE1 = 2;   // (1 << 1)
  123.   D3DCLIPPLANE2 = 4;   // (1 << 2)
  124.   D3DCLIPPLANE3 = 8;   // (1 << 3)
  125.   D3DCLIPPLANE4 = 16;  // (1 << 4)
  126.   D3DCLIPPLANE5 = 32;  // (1 << 5)
  127.  
  128. // The following bits are used in the ClipUnion and ClipIntersection
  129. // members of the D3DCLIPSTATUS8
  130. //
  131.  
  132.   D3DCS_LEFT        = $00000001;
  133.   D3DCS_RIGHT       = $00000002;
  134.   D3DCS_TOP         = $00000004;
  135.   D3DCS_BOTTOM      = $00000008;
  136.   D3DCS_FRONT       = $00000010;
  137.   D3DCS_BACK        = $00000020;
  138.   D3DCS_PLANE0      = $00000040;
  139.   D3DCS_PLANE1      = $00000080;
  140.   D3DCS_PLANE2      = $00000100;
  141.   D3DCS_PLANE3      = $00000200;
  142.   D3DCS_PLANE4      = $00000400;
  143.   D3DCS_PLANE5      = $00000800;
  144.  
  145.   D3DCS_ALL = D3DCS_LEFT or D3DCS_RIGHT or D3DCS_TOP or
  146.               D3DCS_BOTTOM or D3DCS_FRONT or D3DCS_BACK or
  147.               D3DCS_PLANE0 or D3DCS_PLANE1 or D3DCS_PLANE2 or
  148.               D3DCS_PLANE3 or D3DCS_PLANE4 or D3DCS_PLANE5;
  149.  
  150.  
  151. type
  152.   PD3DClipStatus8 = ^TD3DClipStatus8;
  153.   TD3DClipStatus8 = packed record
  154.     ClipUnion        : LongWord;
  155.     ClipIntersection : LongWord;
  156.   end;
  157.  
  158.   PD3DMaterial8 = ^TD3DMaterial8;
  159.   TD3DMaterial8 = packed record
  160.     Diffuse  : TD3DColorValue;  (* Diffuse color RGBA *)
  161.     Ambient  : TD3DColorValue;  (* Ambient color RGB *)
  162.     Specular : TD3DColorValue;  (* Specular 'shininess' *)
  163.     Emissive : TD3DColorValue;  (* Emissive color RGB *)
  164.     Power    : Single;          (* Sharpness if specular highlight *)
  165.   end;
  166.  
  167. type
  168.   TD3DLightType = LongWord;
  169.   
  170. const
  171.   D3DLIGHT_POINT          = 1;
  172.   D3DLIGHT_SPOT           = 2;
  173.   D3DLIGHT_DIRECTIONAL    = 3;
  174.   D3DLIGHT_FORCE_DWORD    = $7fffffff; (* force 32-bit size enum *)
  175.  
  176. type
  177.   PD3DLight8 = ^TD3DLight8;
  178.   TD3DLight8 = packed record
  179.     _Type        : LongWord;        (* Type of light source *) //D3DLIGHTTYPE
  180.     Diffuse      : TD3DColorValue;  (* Diffuse color of light *)
  181.     Specular     : TD3DColorValue;  (* Specular color of light *)
  182.     Ambient      : TD3DColorValue;  (* Ambient color of light *)
  183.     Position     : TD3DVector;      (* Position in world space *)
  184.     Direction    : TD3DVector;      (* Direction in world space *)
  185.     Range        : Single;          (* Cutoff range *)
  186.     Falloff      : Single;          (* Falloff *)
  187.     Attenuation0 : Single;          (* Constant attenuation *)
  188.     Attenuation1 : Single;          (* Linear attenuation *)
  189.     Attenuation2 : Single;          (* Quadratic attenuation *)
  190.     Theta        : Single;          (* Inner angle of spotlight cone *)
  191.     Phi          : Single;          (* Outer angle of spotlight cone *)
  192.   end;
  193.  
  194. (*
  195.  * Options for clearing
  196.  *)
  197. const
  198.   D3DCLEAR_TARGET  = $00000001;  (* Clear target surface *)
  199.   D3DCLEAR_ZBUFFER = $00000002;  (* Clear target z buffer *)
  200.   D3DCLEAR_STENCIL = $00000004;  (* Clear stencil planes *)
  201.  
  202. (*
  203.  * The following defines the rendering states
  204.  *)
  205.  
  206. type
  207.  TD3DShadeMode = LongWord;
  208.  
  209. const
  210.   D3DSHADE_FLAT               = 1;
  211.   D3DSHADE_GOURAUD            = 2;
  212.   D3DSHADE_PHONG              = 3;
  213.   D3DSHADE_FORCE_DWORD        = $7fffffff; (* force 32-bit size enum *)
  214.  
  215. type
  216.   TD3DFillMode = LongWord;
  217.   
  218. const
  219.   D3DFILL_POINT               = 1;
  220.   D3DFILL_WIREFRAME           = 2;
  221.   D3DFILL_SOLID               = 3;
  222.   D3DFILL_FORCE_DWORD         = $7fffffff; (* force 32-bit size enum *)
  223.  
  224. type
  225.   PD3DLinePattern = ^TD3DLinePattern;
  226.   TD3DLinePattern = packed record
  227.     wRepeatFactor : Word;
  228.     wLinePattern  : Word;
  229.   end;
  230.  
  231. type
  232.  TD3DBlend = LongWord;
  233.  
  234. const
  235.   D3DBLEND_ZERO               = 1;
  236.   D3DBLEND_ONE                = 2;
  237.   D3DBLEND_SRCCOLOR           = 3;
  238.   D3DBLEND_INVSRCCOLOR        = 4;
  239.   D3DBLEND_SRCALPHA           = 5;
  240.   D3DBLEND_INVSRCALPHA        = 6;
  241.   D3DBLEND_DESTALPHA          = 7;
  242.   D3DBLEND_INVDESTALPHA       = 8;
  243.   D3DBLEND_DESTCOLOR          = 9;
  244.   D3DBLEND_INVDESTCOLOR       = 10;
  245.   D3DBLEND_SRCALPHASAT        = 11;
  246.   D3DBLEND_BOTHSRCALPHA       = 12;
  247.   D3DBLEND_BOTHINVSRCALPHA    = 13;
  248.   D3DBLEND_FORCE_DWORD        = $7fffffff; (* force 32-bit size enum *)
  249.  
  250. type
  251.   TD3DBLendOp = LongWord;
  252.  
  253. const
  254.   D3DBLENDOP_ADD              = 1;
  255.   D3DBLENDOP_SUBTRACT         = 2;
  256.   D3DBLENDOP_REVSUBTRACT      = 3;
  257.   D3DBLENDOP_MIN              = 4;
  258.   D3DBLENDOP_MAX              = 5;
  259.   D3DBLENDOP_FORCE_DWORD      = $7fffffff; (* force 32-bit size enum *)
  260.  
  261. type
  262.   TD3DTextureAddress = LongWord;
  263.  
  264. const
  265.   D3DTADDRESS_WRAP            = 1;
  266.   D3DTADDRESS_MIRROR          = 2;
  267.   D3DTADDRESS_CLAMP           = 3;
  268.   D3DTADDRESS_BORDER          = 4;
  269.   D3DTADDRESS_MIRRORONCE      = 5;
  270.   D3DTADDRESS_FORCE_DWORD     = $7fffffff; (* force 32-bit size enum *)
  271.  
  272. type
  273.   TD3DCull = LongWord;
  274.  
  275. const
  276.   D3DCULL_NONE                = 1;
  277.   D3DCULL_CW                  = 2;
  278.   D3DCULL_CCW                 = 3;
  279.   D3DCULL_FORCE_DWORD         = $7fffffff; (* force 32-bit size enum *)
  280.  
  281. type
  282.   TD3DCmpFunc = LongWord;
  283.  
  284. const
  285.   D3DCMP_NEVER                = 1;
  286.   D3DCMP_LESS                 = 2;
  287.   D3DCMP_EQUAL                = 3;
  288.   D3DCMP_LESSEQUAL            = 4;
  289.   D3DCMP_GREATER              = 5;
  290.   D3DCMP_NOTEQUAL             = 6;
  291.   D3DCMP_GREATEREQUAL         = 7;
  292.   D3DCMP_ALWAYS               = 8;
  293.   D3DCMP_FORCE_DWORD          = $7fffffff; (* force 32-bit size enum *)
  294.  
  295. type
  296.   TD3DStencilOp = LongWord;
  297.  
  298. const
  299.   D3DSTENCILOP_KEEP           = 1;
  300.   D3DSTENCILOP_ZERO           = 2;
  301.   D3DSTENCILOP_REPLACE        = 3;
  302.   D3DSTENCILOP_INCRSAT        = 4;
  303.   D3DSTENCILOP_DECRSAT        = 5;
  304.   D3DSTENCILOP_INVERT         = 6;
  305.   D3DSTENCILOP_INCR           = 7;
  306.   D3DSTENCILOP_DECR           = 8;
  307.   D3DSTENCILOP_FORCE_DWORD    = $7fffffff; (* force 32-bit size enum *)
  308.  
  309. type
  310.   TD3DFogMode = LongWord;
  311.  
  312. const
  313.   D3DFOG_NONE                 = 0;
  314.   D3DFOG_EXP                  = 1;
  315.   D3DFOG_EXP2                 = 2;
  316.   D3DFOG_LINEAR               = 3;
  317.   D3DFOG_FORCE_DWORD          = $7fffffff; (* force 32-bit size enum *)
  318.  
  319. type  
  320.   TD3DZBufferType = LongWord;
  321.  
  322. const
  323.   D3DZB_FALSE                 = 0;
  324.   D3DZB_TRUE                  = 1; // Z buffering
  325.   D3DZB_USEW                  = 2; // W buffering
  326.   D3DZB_FORCE_DWORD           = $7fffffff; (* force 32-bit size enum *)
  327.  
  328. // Primitives supported by draw-primitive API
  329. type
  330.   TD3DPrimitiveType = LongWord;
  331.  
  332. const
  333.   D3DPT_POINTLIST             = 1;
  334.   D3DPT_LINELIST              = 2;
  335.   D3DPT_LINESTRIP             = 3;
  336.   D3DPT_TRIANGLELIST          = 4;
  337.   D3DPT_TRIANGLESTRIP         = 5;
  338.   D3DPT_TRIANGLEFAN           = 6;
  339.   D3DPT_FORCE_DWORD           = $7fffffff; (* force 32-bit size enum *)
  340.  
  341. type
  342.   TD3DTransformStateType = LongWord;
  343.  
  344. const
  345.   D3DTS_VIEW          = 2;
  346.   D3DTS_PROJECTION    = 3;
  347.   D3DTS_TEXTURE0      = 16;
  348.   D3DTS_TEXTURE1      = 17;
  349.   D3DTS_TEXTURE2      = 18;
  350.   D3DTS_TEXTURE3      = 19;
  351.   D3DTS_TEXTURE4      = 20;
  352.   D3DTS_TEXTURE5      = 21;
  353.   D3DTS_TEXTURE6      = 22;
  354.   D3DTS_TEXTURE7      = 23;
  355.   D3DTS_FORCE_DWORD   = $7fffffff; (* force 32-bit size enum *)
  356.  
  357.  
  358.   function D3DTS_WORLDMATRIX(index : LongWord) : LongWord; // (D3DTRANSFORMSTATETYPE)(index + 256)
  359.  
  360. const
  361.   D3DTS_WORLD  = 0 + 256; // D3DTS_WORLDMATRIX(0)
  362.   D3DTS_WORLD1 = 1 + 256; // D3DTS_WORLDMATRIX(1)
  363.   D3DTS_WORLD2 = 2 + 256; // D3DTS_WORLDMATRIX(2)
  364.   D3DTS_WORLD3 = 3 + 256; // D3DTS_WORLDMATRIX(3)
  365.  
  366. type
  367.   TD3DRenderStateType = LongWord;
  368.  
  369. const
  370.   D3DRS_ZENABLE                   = 7;    (* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) *)
  371.   D3DRS_FILLMODE                  = 8;    (* D3DFILL_MODE        *)
  372.   D3DRS_SHADEMODE                 = 9;    (* D3DSHADEMODE *)
  373.   D3DRS_LINEPATTERN               = 10;   (* D3DLINEPATTERN *)
  374.   D3DRS_ZWRITEENABLE              = 14;   (* TRUE to enable z writes *)
  375.   D3DRS_ALPHATESTENABLE           = 15;   (* TRUE to enable alpha tests *)
  376.   D3DRS_LASTPIXEL                 = 16;   (* TRUE for last-pixel on lines *)
  377.   D3DRS_SRCBLEND                  = 19;   (* D3DBLEND *)
  378.   D3DRS_DESTBLEND                 = 20;   (* D3DBLEND *)
  379.   D3DRS_CULLMODE                  = 22;   (* D3DCULL *)
  380.   D3DRS_ZFUNC                     = 23;   (* D3DCMPFUNC *)
  381.   D3DRS_ALPHAREF                  = 24;   (* D3DFIXED *)
  382.   D3DRS_ALPHAFUNC                 = 25;   (* D3DCMPFUNC *)
  383.   D3DRS_DITHERENABLE              = 26;   (* TRUE to enable dithering *)
  384.   D3DRS_ALPHABLENDENABLE          = 27;   (* TRUE to enable alpha blending *)
  385.   D3DRS_FOGENABLE                 = 28;   (* TRUE to enable fog blending *)
  386.   D3DRS_SPECULARENABLE            = 29;   (* TRUE to enable specular *)
  387.   D3DRS_ZVISIBLE                  = 30;   (* TRUE to enable z checking *)
  388.   D3DRS_FOGCOLOR                  = 34;   (* D3DCOLOR *)
  389.   D3DRS_FOGTABLEMODE              = 35;   (* D3DFOGMODE *)
  390.   D3DRS_FOGSTART                  = 36;   (* Fog start (for both vertex and pixel fog) *)
  391.   D3DRS_FOGEND                    = 37;   (* Fog end      *)
  392.   D3DRS_FOGDENSITY                = 38;   (* Fog density  *)
  393.   D3DRS_EDGEANTIALIAS             = 40;   (* TRUE to enable edge antialiasing *)
  394.   D3DRS_ZBIAS                     = 47;   (* LONG Z bias *)
  395.   D3DRS_RANGEFOGENABLE            = 48;   (* Enables range-based fog *)
  396.   D3DRS_STENCILENABLE             = 52;   (* BOOL enable/disable stenciling *)
  397.   D3DRS_STENCILFAIL               = 53;   (* D3DSTENCILOP to do if stencil test fails *)
  398.   D3DRS_STENCILZFAIL              = 54;   (* D3DSTENCILOP to do if stencil test passes and Z test fails *)
  399.   D3DRS_STENCILPASS               = 55;   (* D3DSTENCILOP to do if both stencil and Z tests pass *)
  400.   D3DRS_STENCILFUNC               = 56;   (* D3DCMPFUNC fn.  Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true *)
  401.   D3DRS_STENCILREF                = 57;   (* Reference value used in stencil test *)
  402.   D3DRS_STENCILMASK               = 58;   (* Mask value used in stencil test *)
  403.   D3DRS_STENCILWRITEMASK          = 59;   (* Write mask applied to values written to stencil buffer *)
  404.   D3DRS_TEXTUREFACTOR             = 60;   (* D3DCOLOR used for multi-texture blend *)
  405.   D3DRS_WRAP0                     = 128;  (* wrap for 1st texture coord. set *)
  406.   D3DRS_WRAP1                     = 129;  (* wrap for 2nd texture coord. set *)
  407.   D3DRS_WRAP2                     = 130;  (* wrap for 3rd texture coord. set *)
  408.   D3DRS_WRAP3                     = 131;  (* wrap for 4th texture coord. set *)
  409.   D3DRS_WRAP4                     = 132;  (* wrap for 5th texture coord. set *)
  410.   D3DRS_WRAP5                     = 133;  (* wrap for 6th texture coord. set *)
  411.   D3DRS_WRAP6                     = 134;  (* wrap for 7th texture coord. set *)
  412.   D3DRS_WRAP7                     = 135;  (* wrap for 8th texture coord. set *)
  413.   D3DRS_CLIPPING                  = 136;
  414.   D3DRS_LIGHTING                  = 137;
  415.   D3DRS_AMBIENT                   = 139;
  416.   D3DRS_FOGVERTEXMODE             = 140;
  417.   D3DRS_COLORVERTEX               = 141;
  418.   D3DRS_LOCALVIEWER               = 142;
  419.   D3DRS_NORMALIZENORMALS          = 143;
  420.   D3DRS_DIFFUSEMATERIALSOURCE     = 145;
  421.   D3DRS_SPECULARMATERIALSOURCE    = 146;
  422.   D3DRS_AMBIENTMATERIALSOURCE     = 147;
  423.   D3DRS_EMISSIVEMATERIALSOURCE    = 148;
  424.   D3DRS_VERTEXBLEND               = 151;
  425.   D3DRS_CLIPPLANEENABLE           = 152;
  426.   D3DRS_SOFTWAREVERTEXPROCESSING  = 153;
  427.   D3DRS_POINTSIZE                 = 154;  (* float point size *)
  428.   D3DRS_POINTSIZE_MIN             = 155;  (* float point size min threshold *)
  429.   D3DRS_POINTSPRITEENABLE         = 156;  (* BOOL point texture coord control *)
  430.   D3DRS_POINTSCALEENABLE          = 157;  (* BOOL point size scale enable *)
  431.   D3DRS_POINTSCALE_A              = 158;  (* float point attenuation A value *)
  432.   D3DRS_POINTSCALE_B              = 159;  (* float point attenuation B value *)
  433.   D3DRS_POINTSCALE_C              = 160;  (* float point attenuation C value *)
  434.   D3DRS_MULTISAMPLEANTIALIAS      = 161;  // BOOL - set to do FSAA with multisample buffer *)
  435.   D3DRS_MULTISAMPLEMASK           = 162;  // DWORD - per-sample enable/disable
  436.   D3DRS_PATCHEDGESTYLE            = 163;  // Sets whether patch edges will use float style tessellation
  437.   D3DRS_PATCHSEGMENTS             = 164;  // Number of segments per edge when drawing patches
  438.   D3DRS_DEBUGMONITORTOKEN         = 165;  // DEBUG ONLY - token to debug monitor
  439.   D3DRS_POINTSIZE_MAX             = 166;  (* float point size max threshold *)
  440.   D3DRS_INDEXEDVERTEXBLENDENABLE  = 167;
  441.   D3DRS_COLORWRITEENABLE          = 168;  // per-channel write enable
  442.   D3DRS_TWEENFACTOR               = 170;  // float tween factor
  443.   D3DRS_BLENDOP                   = 171;  // D3DBLENDOP setting
  444.  
  445.   D3DRS_FORCE_DWORD               = $7fffffff; (* force 32-bit size enum *)
  446.  
  447. // Values for material source
  448. type
  449.   TD3DMaterialColorSource = LongWord;
  450.  
  451. const
  452.   D3DMCS_MATERIAL         = 0;          // Color from material is used
  453.   D3DMCS_COLOR1           = 1;          // Diffuse vertex color is used
  454.   D3DMCS_COLOR2           = 2;          // Specular vertex color is used
  455.   D3DMCS_FORCE_DWORD      = $7fffffff;  // force 32-bit size enum
  456.  
  457.  
  458. // Bias to apply to the texture coordinate set to apply a wrap to.
  459.   D3DRENDERSTATE_WRAPBIAS  = 128;
  460.  
  461. (* Flags to construct the WRAP render states *)
  462.   D3DWRAP_U = $00000001;
  463.   D3DWRAP_V = $00000002;
  464.   D3DWRAP_W = $00000004;
  465.  
  466. (* Flags to construct the WRAP render states for 1D thru 4D texture coordinates *)
  467.   D3DWRAPCOORD_0  = $00000001;    // same as D3DWRAP_U
  468.   D3DWRAPCOORD_1  = $00000002;    // same as D3DWRAP_V
  469.   D3DWRAPCOORD_2  = $00000004;    // same as D3DWRAP_W
  470.   D3DWRAPCOORD_3  = $00000008;
  471.  
  472. (* Flags to construct D3DRS_COLORWRITEENABLE *)
  473.   D3DCOLORWRITEENABLE_RED   = 1;  // (1L<<0)
  474.   D3DCOLORWRITEENABLE_GREEN = 2;  // (1L<<1)
  475.   D3DCOLORWRITEENABLE_BLUE  = 4;  // (1L<<2)
  476.   D3DCOLORWRITEENABLE_ALPHA = 8;  // (1L<<3)
  477.  
  478. (*
  479.  * State enumerants for per-stage texture processing.
  480.  *)
  481. type
  482.   TD3DTextureStageStateType = LongWord;
  483.  
  484. const
  485.   D3DTSS_COLOROP               =  1;         (* D3DTEXTUREOP - per-stage blending controls for color channels *)
  486.   D3DTSS_COLORARG1             =  2;         (* D3DTA_* (texture arg) *)
  487.   D3DTSS_COLORARG2             =  3;         (* D3DTA_* (texture arg) *)
  488.   D3DTSS_ALPHAOP               =  4;         (* D3DTEXTUREOP - per-stage blending controls for alpha channel *)
  489.   D3DTSS_ALPHAARG1             =  5;         (* D3DTA_* (texture arg) *)
  490.   D3DTSS_ALPHAARG2             =  6;         (* D3DTA_* (texture arg) *)
  491.   D3DTSS_BUMPENVMAT00          =  7;         (* float (bump mapping matrix) *)
  492.   D3DTSS_BUMPENVMAT01          =  8;         (* float (bump mapping matrix) *)
  493.   D3DTSS_BUMPENVMAT10          =  9;         (* float (bump mapping matrix) *)
  494.   D3DTSS_BUMPENVMAT11          = 10;         (* float (bump mapping matrix) *)
  495.   D3DTSS_TEXCOORDINDEX         = 11;         (* identifies which set of texture coordinates index this texture *)
  496.   D3DTSS_ADDRESSU              = 13;         (* D3DTEXTUREADDRESS for U coordinate *)
  497.   D3DTSS_ADDRESSV              = 14;         (* D3DTEXTUREADDRESS for V coordinate *)
  498.   D3DTSS_BORDERCOLOR           = 15;         (* D3DCOLOR *)
  499.   D3DTSS_MAGFILTER             = 16;         (* D3DTEXTUREFILTER filter to use for magnification *)
  500.   D3DTSS_MINFILTER             = 17;         (* D3DTEXTUREFILTER filter to use for minification *)
  501.   D3DTSS_MIPFILTER             = 18;         (* D3DTEXTUREFILTER filter to use between mipmaps during minification *)
  502.   D3DTSS_MIPMAPLODBIAS         = 19;         (* float Mipmap LOD bias *)
  503.   D3DTSS_MAXMIPLEVEL           = 20;         (* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) *)
  504.   D3DTSS_MAXANISOTROPY         = 21;         (* DWORD maximum anisotropy *)
  505.   D3DTSS_BUMPENVLSCALE         = 22;         (* float scale for bump map luminance *)
  506.   D3DTSS_BUMPENVLOFFSET        = 23;         (* float offset for bump map luminance *)
  507.   D3DTSS_TEXTURETRANSFORMFLAGS = 24;         (* D3DTEXTURETRANSFORMFLAGS controls texture transform *)
  508.   D3DTSS_ADDRESSW              = 25;         (* D3DTEXTUREADDRESS for W coordinate *)
  509.   D3DTSS_COLORARG0             = 26;         (* D3DTA_* third arg for triadic ops *)
  510.   D3DTSS_ALPHAARG0             = 27;         (* D3DTA_* third arg for triadic ops *)
  511.   D3DTSS_RESULTARG             = 28;         (* D3DTA_* arg for result (CURRENT or TEMP) *)
  512.   D3DTSS_FORCE_DWORD           = $7fffffff;  (* force 32-bit size enum *)
  513.  
  514. // Values; used with D3DTSS_TEXCOORDINDEX; to specify that the vertex data(position
  515. // and normal in the camera space) should be taken as texture coordinates
  516. // Low 16 bits are used to specify texture coordinate index; to take the WRAP mode from
  517. //
  518.   D3DTSS_TCI_PASSTHRU                    = $00000000;
  519.   D3DTSS_TCI_CAMERASPACENORMAL           = $00010000;
  520.   D3DTSS_TCI_CAMERASPACEPOSITION         = $00020000;
  521.   D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR = $00030000;
  522.  
  523. (*
  524.  * Enumerations for COLOROP and ALPHAOP texture blending operations set in
  525.  * texture processing stage controls in D3DRENDERSTATE.
  526.  *)
  527. type
  528.   TD3DTextureOp = LongWord;
  529.  
  530. const
  531.  
  532.   // Control                              
  533.   D3DTOP_DISABLE                   = 1;   // disables stage
  534.   D3DTOP_SELECTARG1                = 2;   // the default
  535.   D3DTOP_SELECTARG2                = 3;
  536.  
  537.   // Modulate
  538.   D3DTOP_MODULATE                  = 4;   // multiply args together
  539.   D3DTOP_MODULATE2X                = 5;   // multiply and  1 bit
  540.   D3DTOP_MODULATE4X                = 6;   // multiply and  2 bits
  541.  
  542.   // Add
  543.   D3DTOP_ADD                       = 7;   // add arguments together
  544.   D3DTOP_ADDSIGNED                 = 8;   // add with -0.5 bias
  545.   D3DTOP_ADDSIGNED2X               = 9;   // as above but left  1 bit
  546.   D3DTOP_SUBTRACT                  = 10;  // Arg1 - Arg2; with no saturation
  547.   D3DTOP_ADDSMOOTH                 = 11;  // add 2 args; subtract product
  548.                                           // Arg1 + Arg2 - Arg1*Arg2
  549.                                           // = Arg1 + (1-Arg1)*Arg2
  550.  
  551.   // Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha)
  552.   D3DTOP_BLENDDIFFUSEALPHA         = 12;  // iterated alpha
  553.   D3DTOP_BLENDTEXTUREALPHA         = 13;  // texture alpha
  554.   D3DTOP_BLENDFACTORALPHA          = 14;  // alpha from D3DRENDERSTATE_TEXTUREFACTOR
  555.  
  556.   // Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha)
  557.   D3DTOP_BLENDTEXTUREALPHAPM       = 15;  // texture alpha
  558.   D3DTOP_BLENDCURRENTALPHA         = 16;  // by alpha of current color
  559.  
  560.   // Specular mapping
  561.   D3DTOP_PREMODULATE               = 17;  // modulate with next texture before use
  562.   D3DTOP_MODULATEALPHA_ADDCOLOR    = 18;  // Arg1.RGB + Arg1.A*Arg2.RGB
  563.                                           // COLOROP only
  564.   D3DTOP_MODULATECOLOR_ADDALPHA    = 19;  // Arg1.RGB*Arg2.RGB + Arg1.A
  565.                                           // COLOROP only
  566.   D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20;  // (1-Arg1.A)*Arg2.RGB + Arg1.RGB
  567.                                           // COLOROP only
  568.   D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21;  // (1-Arg1.RGB)*Arg2.RGB + Arg1.A
  569.                                           // COLOROP only
  570.  
  571.   // Bump mapping
  572.   D3DTOP_BUMPENVMAP                = 22;  // per pixel env map perturbation
  573.   D3DTOP_BUMPENVMAPLUMINANCE       = 23;  // with luminance channel
  574.  
  575.   // This can do either diffuse or specular bump mapping with correct input.
  576.   // Performs the function (Arg1.R*Arg2.R + Arg1.G*Arg2.G + Arg1.B*Arg2.B)
  577.   // where each component has been scaled and offset to make it signed.
  578.   // The result is replicated into all four (including alpha) channels.
  579.   // This is a valid COLOROP only.
  580.   D3DTOP_DOTPRODUCT3          = 24;
  581.  
  582.   // Triadic ops
  583.   D3DTOP_MULTIPLYADD          = 25;       // Arg0 + Arg1*Arg2
  584.   D3DTOP_LERP                 = 26;       // (Arg0)*Arg1 + (1-Arg0)*Arg2
  585.  
  586.   D3DTOP_FORCE_DWORD          = $7fffffff;
  587.  
  588.  
  589.  
  590. (*
  591.  * Values for COLORARG0;1;2; ALPHAARG0;1;2; and RESULTARG texture blending
  592.  * operations set in texture processing stage controls in D3DRENDERSTATE.
  593.  *)
  594.   D3DTA_SELECTMASK        = $0000000f;  // mask for arg selector
  595.   D3DTA_DIFFUSE           = $00000000;  // select diffuse color (read only)
  596.   D3DTA_CURRENT           = $00000001;  // select stage destination register (read/write)
  597.   D3DTA_TEXTURE           = $00000002;  // select texture color (read only)
  598.   D3DTA_TFACTOR           = $00000003;  // select RENDERSTATE_TEXTUREFACTOR (read only)
  599.   D3DTA_SPECULAR          = $00000004;  // select specular color (read only)
  600.   D3DTA_TEMP              = $00000005;  // select temporary register color (read/write)
  601.   D3DTA_COMPLEMENT        = $00000010;  // take 1.0 - x (read modifier)
  602.   D3DTA_ALPHAREPLICATE    = $00000020;  // replicate alpha to color components (read modifier)
  603.  
  604. //
  605. // Values for D3DTSS_***FILTER texture stage states
  606. //
  607. type
  608.    TD3DTextureFilterType = LongWord;
  609.  
  610. const
  611.  
  612.     D3DTEXF_NONE            = 0;          // filtering disabled (valid for mip filter only)
  613.     D3DTEXF_POINT           = 1;          // nearest
  614.     D3DTEXF_LINEAR          = 2;          // linear interpolation
  615.     D3DTEXF_ANISOTROPIC     = 3;          // anisotropic
  616.     D3DTEXF_FLATCUBIC       = 4;          // cubic
  617.     D3DTEXF_GAUSSIANCUBIC   = 5;          // different cubic kernel
  618.     D3DTEXF_FORCE_DWORD     = $7fffffff;  // force 32-bit size enum
  619.  
  620. (* Bits for Flags in ProcessVertices call *)
  621.  
  622.   D3DPV_DONOTCOPYDATA  = 1 shl 0;
  623.  
  624. //-------------------------------------------------------------------
  625.  
  626. // Flexible vertex format bits
  627. //
  628.   D3DFVF_RESERVED0        = $001;
  629.   D3DFVF_POSITION_MASK    = $00E;
  630.   D3DFVF_XYZ              = $002;
  631.   D3DFVF_XYZRHW           = $004;
  632.   D3DFVF_XYZB1            = $006;
  633.   D3DFVF_XYZB2            = $008;
  634.   D3DFVF_XYZB3            = $00a;
  635.   D3DFVF_XYZB4            = $00c;
  636.   D3DFVF_XYZB5            = $00e;
  637.  
  638.   D3DFVF_NORMAL           = $010;
  639.   D3DFVF_PSIZE            = $020;
  640.   D3DFVF_DIFFUSE          = $040;
  641.   D3DFVF_SPECULAR         = $080;
  642.  
  643.   D3DFVF_TEXCOUNT_MASK    = $f00;
  644.   D3DFVF_TEXCOUNT_SHIFT   = 8;
  645.   D3DFVF_TEX0             = $000;
  646.   D3DFVF_TEX1             = $100;
  647.   D3DFVF_TEX2             = $200;
  648.   D3DFVF_TEX3             = $300;
  649.   D3DFVF_TEX4             = $400;
  650.   D3DFVF_TEX5             = $500;
  651.   D3DFVF_TEX6             = $600;
  652.   D3DFVF_TEX7             = $700;
  653.   D3DFVF_TEX8             = $800;
  654.  
  655.   D3DFVF_LASTBETA_UBYTE4  = $1000;
  656.  
  657.   D3DFVF_RESERVED2        = $E000;  // 4 reserved bits
  658.  
  659. //---------------------------------------------------------------------
  660. // Vertex Shaders
  661. //
  662.  
  663. (*
  664.  
  665. Vertex Shader Declaration
  666.  
  667. The declaration portion of a vertex shader defines the static external
  668. interface of the shader.  The information in the declaration includes:
  669.  
  670. - Assignments of vertex shader input registers to data streams.  These
  671. assignments bind a specific vertex register to a single component within a
  672. vertex stream.  A vertex stream element is identified by a byte offset
  673. within the stream and a type.  The type specifies the arithmetic data type
  674. plus the dimensionality (1; 2; 3; or 4 values).  Stream data which is
  675. less than 4 values are always expanded out to 4 values with zero or more
  676. 0.F values and one 1.F value.
  677.  
  678. - Assignment of vertex shader input registers to implicit data from the
  679. primitive tessellator.  This controls the loading of vertex data which is
  680. not loaded from a stream; but rather is generated during primitive
  681. tessellation prior to the vertex shader.
  682.  
  683. - Loading data into the constant memory at the time a shader is set as the
  684. current shader.  Each token specifies values for one or more contiguous 4
  685. DWORD constant registers.  This allows the shader to update an arbitrary
  686. subset of the constant memory; overwriting the device state (which
  687. contains the current values of the constant memory).  Note that these
  688. values can be subsequently overwritten (between DrawPrimitive calls)
  689. during the time a shader is bound to a device via the
  690. SetVertexShaderConstant method.
  691.  
  692.  
  693. Declaration arrays are single-dimensional arrays of DWORDs composed of
  694. multiple tokens each of which is one or more DWORDs.  The single-DWORD
  695. token value = $FFFFFFFF is a special token used to indicate the end of the
  696. declaration array.  The single DWORD token value = $00000000 is a NOP token
  697. with is ignored during the declaration parsing.  Note that = $00000000 is a
  698. valid value for DWORDs following the first DWORD for multiple word tokens.
  699.  
  700. [31:29] TokenType
  701.     = $0 - NOP (requires all DWORD bits to be zero)
  702.     = $1 - stream selector
  703.     = $2 - stream data definition (map to vertex input memory)
  704.     = $3 - vertex input memory from tessellator
  705.     = $4 - constant memory from shader
  706.     = $5 - extension
  707.     = $6 - reserved
  708.     = $7 - end-of-array (requires all DWORD bits to be 1)
  709.  
  710. NOP Token (single DWORD token)
  711.     [31:29] = $0
  712.     [28:00] = $0
  713.  
  714. Stream Selector (single DWORD token)
  715.     [31:29] = $1
  716.     [28]    indicates whether this is a tessellator stream
  717.     [27:04] = $0
  718.     [03:00] stream selector (0..15)
  719.  
  720. Stream Data Definition (single DWORD token)
  721.     Vertex Input Register Load
  722.       [31:29] = $2
  723.       [28]    = $0
  724.       [27:20] = $0
  725.       [19:16] type (dimensionality and data type)
  726.       [15:04] = $0
  727.       [03:00] vertex register address (0..15)
  728.     Data Skip (no register load)
  729.       [31:29] = $2
  730.       [28]    = $1
  731.       [27:20] = $0
  732.       [19:16] count of DWORDS to skip over (0..15)
  733.       [15:00] = $0
  734.     Vertex Input Memory from Tessellator Data (single DWORD token)
  735.       [31:29] = $3
  736.       [28]    indicates whether data is normals or u/v
  737.       [27:24] = $0
  738.       [23:20] vertex register address (0..15)
  739.       [19:16] type (dimensionality)
  740.       [15:04] = $0
  741.       [03:00] vertex register address (0..15)
  742.  
  743. Constant Memory from Shader (multiple DWORD token)
  744.     [31:29] = $4
  745.     [28:25] count of 4*DWORD constants to load (0..15)
  746.     [24:07] = $0
  747.     [06:00] constant memory address (0..95)
  748.  
  749. Extension Token (single or multiple DWORD token)
  750.     [31:29] = $5
  751.     [28:24] count of additional DWORDs in token (0..31)
  752.     [23:00] extension-specific information
  753.  
  754. End-of-array token (single DWORD token)
  755.     [31:29] = $7
  756.     [28:00] = $1fffffff
  757.  
  758. The stream selector token must be immediately followed by a contiguous set of stream data definition tokens.  This token sequence fully defines that stream; including the set of elements within the stream; the order in which the elements appear; the type of each element; and the vertex register into which to load an element.
  759. Streams are allowed to include data which is not loaded into a vertex register; thus allowing data which is not used for this shader to exist in the vertex stream.  This skipped data is defined only by a count of DWORDs to skip over; since the type information is irrelevant.
  760. The token sequence:
  761. Stream Select: stream=0
  762. Stream Data Definition (Load): type=FLOAT3; register=3
  763. Stream Data Definition (Load): type=FLOAT3; register=4
  764. Stream Data Definition (Skip): count=2
  765. Stream Data Definition (Load): type=FLOAT2; register=7
  766.  
  767. defines stream zero to consist of 4 elements; 3 of which are loaded into registers and the fourth skipped over.  Register 3 is loaded with the first three DWORDs in each vertex interpreted as FLOAT data.  Register 4 is loaded with the 4th; 5th; and 6th DWORDs interpreted as FLOAT data.  The next two DWORDs (7th and 8th) are skipped over and not loaded into any vertex input register.   Register 7 is loaded with the 9th and 10th DWORDS interpreted as FLOAT data.
  768. Placing of tokens other than NOPs between the Stream Selector and Stream Data Definition tokens is disallowed.
  769.  
  770. *)
  771. type
  772.   TD3DVSD_TokenType = LongWord;
  773.  
  774. const
  775.                                          
  776.   D3DVSD_TOKEN_NOP         = 0;          // NOP or extension
  777.   D3DVSD_TOKEN_STREAM      = 1;          // stream selector
  778.   D3DVSD_TOKEN_STREAMDATA  = 2;          // stream data definition (map to vertex input memory)
  779.   D3DVSD_TOKEN_TESSELLATOR = 3;          // vertex input memory from tessellator
  780.   D3DVSD_TOKEN_CONSTMEM    = 4;          // constant memory from shader
  781.   D3DVSD_TOKEN_EXT         = 5;          // extension
  782.   D3DVSD_TOKEN_END         = 7;          // end-of-array (requires all DWORD bits to be 1)
  783.   D3DVSD_FORCE_DWORD       = $7fffffff;  // force 32-bit size enum
  784.   
  785.  
  786.   D3DVSD_TOKENTYPESHIFT   = 29;
  787.   D3DVSD_TOKENTYPEMASK    = 7 shl D3DVSD_TOKENTYPESHIFT;
  788.  
  789.   D3DVSD_STREAMNUMBERSHIFT = 0;
  790.   D3DVSD_STREAMNUMBERMASK  = $F shl D3DVSD_STREAMNUMBERSHIFT;
  791.  
  792.   D3DVSD_DATALOADTYPESHIFT = 28;
  793.   D3DVSD_DATALOADTYPEMASK  = $1 shl D3DVSD_DATALOADTYPESHIFT;
  794.  
  795.   D3DVSD_DATATYPESHIFT = 16;
  796.   D3DVSD_DATATYPEMASK  = $F shl D3DVSD_DATATYPESHIFT;
  797.  
  798.   D3DVSD_SKIPCOUNTSHIFT = 16;
  799.   D3DVSD_SKIPCOUNTMASK  = $F shl D3DVSD_SKIPCOUNTSHIFT;
  800.  
  801.   D3DVSD_VERTEXREGSHIFT = 0;
  802.   D3DVSD_VERTEXREGMASK  = $1F shl D3DVSD_VERTEXREGSHIFT;
  803.  
  804.   D3DVSD_VERTEXREGINSHIFT = 20;
  805.   D3DVSD_VERTEXREGINMASK  = $F shl D3DVSD_VERTEXREGINSHIFT;
  806.  
  807.   D3DVSD_CONSTCOUNTSHIFT = 25;
  808.   D3DVSD_CONSTCOUNTMASK  = $F shl D3DVSD_CONSTCOUNTSHIFT;
  809.  
  810.   D3DVSD_CONSTADDRESSSHIFT = 0;
  811.   D3DVSD_CONSTADDRESSMASK  = $7F shl D3DVSD_CONSTADDRESSSHIFT;
  812.  
  813.   D3DVSD_CONSTRSSHIFT = 16;
  814.   D3DVSD_CONSTRSMASK  = $1FFF shl D3DVSD_CONSTRSSHIFT;
  815.  
  816.   D3DVSD_EXTCOUNTSHIFT = 24;
  817.   D3DVSD_EXTCOUNTMASK  = $1F shl D3DVSD_EXTCOUNTSHIFT;
  818.  
  819.   D3DVSD_EXTINFOSHIFT = 0;
  820.   D3DVSD_EXTINFOMASK  = $FFFFFF shl D3DVSD_EXTINFOSHIFT;
  821.  
  822.   function D3DVSD_MAKETOKENTYPE(tokenType : LongWord) : LongWord;
  823.  
  824. // macros for generation of CreateVertexShader Declaration token array
  825.  
  826. // Set current stream
  827. // _StreamNumber [0..(MaxStreams-1)] stream to get data from
  828. //
  829.   function D3DVSD_STREAM(_StreamNumber : LongWord) : LongWord;
  830.  
  831. // Set tessellator stream
  832. //
  833. const
  834.   D3DVSD_STREAMTESSSHIFT = 28;
  835.   D3DVSD_STREAMTESSMASK  = 1 shl D3DVSD_STREAMTESSSHIFT;
  836.  
  837.   D3DVSD_STREAM_TESS = ((D3DVSD_TOKEN_STREAM shl D3DVSD_TOKENTYPESHIFT) and D3DVSD_TOKENTYPEMASK) or D3DVSD_STREAMTESSMASK;
  838.  
  839. // bind single vertex register to vertex element from vertex stream
  840. //
  841. // _VertexRegister [0..15] address of the vertex register
  842. // _Type [D3DVSDT_*] dimensionality and arithmetic data type
  843.  
  844.   function D3DVSD_REG( _VertexRegister, _Type : LongWord) : LongWord;
  845.  
  846. // Skip _DWORDCount DWORDs in vertex
  847. //
  848.   function D3DVSD_SKIP(_DWORDCount : LongWord) : LongWord;
  849.  
  850. // load data into vertex shader constant memory
  851. //
  852. // _ConstantAddress [0..95] - address of constant array to begin filling data
  853. // _Count [0..15] - number of constant vectors to load (4 DWORDs each)
  854. // followed by 4*_Count DWORDS of data
  855. //
  856.   function D3DVSD_CONST( _ConstantAddress, _Count : LongWord) : LongWord;
  857.  
  858. // enable tessellator generated normals
  859. //
  860. // _VertexRegisterIn  [0..15] address of vertex register whose input stream
  861. //                            will be used in normal computation
  862. // _VertexRegisterOut [0..15] address of vertex register to output the normal to
  863. //
  864.   function D3DVSD_TESSNORMAL( _VertexRegisterIn, _VertexRegisterOut : LongWord) : LongWord;
  865.   
  866. // enable tessellator generated surface parameters
  867. //
  868. // _VertexRegister [0..15] address of vertex register to output parameters
  869. //
  870.   function D3DVSD_TESSUV( _VertexRegister : LongWord) : LongWord;
  871.  
  872. // Generates END token
  873. //
  874. const
  875.   D3DVSD_END = $FFFFFFFF;
  876.  
  877. // Generates NOP token
  878.   D3DVSD_NOP = $00000000;
  879.  
  880. // bit declarations for _Type fields
  881.   D3DVSDT_FLOAT1      = $00;    // 1D float expanded to (value; 0.; 0.; 1.)
  882.   D3DVSDT_FLOAT2      = $01;    // 2D float expanded to (value; value; 0.; 1.)
  883.   D3DVSDT_FLOAT3      = $02;    // 3D float expanded to (value; value; value; 1.)
  884.   D3DVSDT_FLOAT4      = $03;    // 4D float
  885.   D3DVSDT_D3DCOLOR    = $04;    // 4D packed unsigned bytes mapped to 0. to 1. range
  886.                                     // Input is in D3DCOLOR format (ARGB) expanded to (R; G; B; A)
  887.   D3DVSDT_UBYTE4      = $05;    // 4D unsigned byte
  888.   D3DVSDT_SHORT2      = $06;    // 2D signed short expanded to (value; value; 0.; 1.)
  889.   D3DVSDT_SHORT4      = $07;    // 4D signed short
  890.  
  891. // assignments of vertex input registers for fixed function vertex shader
  892. //
  893.   D3DVSDE_POSITION      = 0;
  894.   D3DVSDE_BLENDWEIGHT   = 1;
  895.   D3DVSDE_BLENDINDICES  = 2;
  896.   D3DVSDE_NORMAL        = 3;
  897.   D3DVSDE_PSIZE         = 4;
  898.   D3DVSDE_DIFFUSE       = 5;
  899.   D3DVSDE_SPECULAR      = 6;
  900.   D3DVSDE_TEXCOORD0     = 7;
  901.   D3DVSDE_TEXCOORD1     = 8;
  902.   D3DVSDE_TEXCOORD2     = 9;
  903.   D3DVSDE_TEXCOORD3     = 10;
  904.   D3DVSDE_TEXCOORD4     = 11;
  905.   D3DVSDE_TEXCOORD5     = 12;
  906.   D3DVSDE_TEXCOORD6     = 13;
  907.   D3DVSDE_TEXCOORD7     = 14;
  908.   D3DVSDE_POSITION2     = 15;
  909.   D3DVSDE_NORMAL2       = 16;
  910.  
  911. // Maximum supported number of texture coordinate sets
  912.   D3DDP_MAXTEXCOORD = 8;
  913.  
  914.  
  915. //
  916. // Instruction Token Bit Definitions
  917. //
  918.   D3DSI_OPCODE_MASK       = $0000FFFF;
  919.  
  920. type
  921.   TD3DShader_Instruction_Opcode_Type = LongWord;
  922.   TD3DShaderInstructionOpcodeType = LongWord;  
  923.  
  924. const
  925.   D3DSIO_NOP          = 0;      // PS/VS
  926.   D3DSIO_MOV          = 1;      // PS/VS
  927.   D3DSIO_ADD          = 2;      // PS/VS
  928.   D3DSIO_SUB          = 3;      // PS
  929.   D3DSIO_MAD          = 4;      // PS/VS
  930.   D3DSIO_MUL          = 5;      // PS/VS
  931.   D3DSIO_RCP          = 6;      // VS
  932.   D3DSIO_RSQ          = 7;      // VS
  933.   D3DSIO_DP3          = 8;      // PS/VS
  934.   D3DSIO_DP4          = 9;      // PS/VS
  935.   D3DSIO_MIN          = 10;     // VS
  936.   D3DSIO_MAX          = 11;     // VS
  937.   D3DSIO_SLT          = 12;     // VS
  938.   D3DSIO_SGE          = 13;     // VS
  939.   D3DSIO_EXP          = 14;     // VS
  940.   D3DSIO_LOG          = 15;     // VS
  941.   D3DSIO_LIT          = 16;     // VS
  942.   D3DSIO_DST          = 17;     // VS
  943.   D3DSIO_LRP          = 18;     // PS
  944.   D3DSIO_FRC          = 19;     // VS
  945.   D3DSIO_M4x4         = 20;     // VS
  946.   D3DSIO_M4x3         = 21;     // VS
  947.   D3DSIO_M3x4         = 22;     // VS
  948.   D3DSIO_M3x3         = 23;     // VS
  949.   D3DSIO_M3x2         = 24;     // VS
  950.  
  951.   D3DSIO_TEXCOORD     = 64;     // PS
  952.   D3DSIO_TEXKILL      = 65;     // PS
  953.   D3DSIO_TEX          = 66;     // PS
  954.   D3DSIO_TEXBEM       = 67;     // PS
  955.   D3DSIO_TEXBEML      = 68;     // PS
  956.   D3DSIO_TEXREG2AR    = 69;     // PS
  957.   D3DSIO_TEXREG2GB    = 70;     // PS
  958.   D3DSIO_TEXM3x2PAD   = 71;     // PS
  959.   D3DSIO_TEXM3x2TEX   = 72;     // PS
  960.   D3DSIO_TEXM3x3PAD   = 73;     // PS
  961.   D3DSIO_TEXM3x3TEX   = 74;     // PS
  962.   D3DSIO_TEXM3x3DIFF  = 75;     // PS
  963.   D3DSIO_TEXM3x3SPEC  = 76;     // PS
  964.   D3DSIO_TEXM3x3VSPEC = 77;     // PS
  965.   D3DSIO_EXPP         = 78;     // VS
  966.   D3DSIO_LOGP         = 79;     // VS
  967.   D3DSIO_CND          = 80;     // PS
  968.   D3DSIO_DEF          = 81;     // PS
  969.   D3DSIO_COMMENT      = $FFFE;
  970.   D3DSIO_END          = $FFFF;
  971.  
  972.   D3DSIO_FORCE_DWORD  = $7fffffff;   // force 32-bit size enum
  973.  
  974. //
  975. // Co-Issue Instruction Modifier - if set then this instruction is to be
  976. // issued in parallel with the previous instruction(s) for which this bit
  977. // is not set.
  978. //
  979.   D3DSI_COISSUE           = $40000000;
  980.  
  981. //
  982. // Parameter Token Bit Definitions
  983. //
  984.   D3DSP_REGNUM_MASK       = $00000FFF;
  985.  
  986. // destination parameter write mask
  987.   D3DSP_WRITEMASK_0       = $00010000;  // Component 0 (X;Red)
  988.   D3DSP_WRITEMASK_1       = $00020000;  // Component 1 (Y;Green)
  989.   D3DSP_WRITEMASK_2       = $00040000;  // Component 2 (Z;Blue)
  990.   D3DSP_WRITEMASK_3       = $00080000;  // Component 3 (W;Alpha)
  991.   D3DSP_WRITEMASK_ALL     = $000F0000;  // All Components
  992.  
  993. // destination parameter modifiers
  994.   D3DSP_DSTMOD_SHIFT      = 20;
  995.   D3DSP_DSTMOD_MASK       = $00F00000;
  996.  
  997. type
  998.   TD3DShader_Param_DSTMod_Type = LongWord;
  999.   TD3DShaderParamDSTModType = LongWord;  
  1000.  
  1001. const
  1002.   D3DSPDM_NONE        = 0 shl D3DSP_DSTMOD_SHIFT; // nop
  1003.   D3DSPDM_SATURATE    = 1 shl D3DSP_DSTMOD_SHIFT; // clamp to 0. to 1. range
  1004.   D3DSPDM_FORCE_DWORD = $7fffffff;                // force 32-bit size enum
  1005.  
  1006.  
  1007. // destination parameter
  1008.   D3DSP_DSTSHIFT_SHIFT    = 24;
  1009.   D3DSP_DSTSHIFT_MASK     = $0F000000;
  1010.  
  1011. // destination/source parameter register type
  1012.   D3DSP_REGTYPE_SHIFT     = 28;
  1013.   D3DSP_REGTYPE_MASK      = $70000000;
  1014.  
  1015. type
  1016.   TD3DShader_Param_Register_Type = LongWord;
  1017.  
  1018. const
  1019.   D3DSPR_TEMP        = 0 shl D3DSP_REGTYPE_SHIFT; // Temporary Register File
  1020.   D3DSPR_INPUT       = 1 shl D3DSP_REGTYPE_SHIFT; // Input Register File
  1021.   D3DSPR_CONST       = 2 shl D3DSP_REGTYPE_SHIFT; // Constant Register File
  1022.   D3DSPR_ADDR        = 3 shl D3DSP_REGTYPE_SHIFT; // Address Register (VS)
  1023.   D3DSPR_TEXTURE     = 3 shl D3DSP_REGTYPE_SHIFT; // Texture Register File (PS)
  1024.   D3DSPR_RASTOUT     = 4 shl D3DSP_REGTYPE_SHIFT; // Rasterizer Register File
  1025.   D3DSPR_ATTROUT     = 5 shl D3DSP_REGTYPE_SHIFT; // Attribute Output Register File
  1026.   D3DSPR_TEXCRDOUT   = 6 shl D3DSP_REGTYPE_SHIFT; // Texture Coordinate Output Register File
  1027.   D3DSPR_FORCE_DWORD = $7fffffff;                 // force 32-bit size enum
  1028.  
  1029. // Register offsets in the Rasterizer Register File
  1030. //
  1031. type
  1032.   TD3DVS_RastOut_Offsets = LongWord;
  1033.  
  1034. const
  1035.   D3DSRO_POSITION    = 0;
  1036.   D3DSRO_FOG         = 1;
  1037.   D3DSRO_POINT_SIZE  = 2;
  1038.   D3DSRO_FORCE_DWORD = $7fffffff;  // force 32-bit size enum
  1039.  
  1040. // Source operand addressing modes
  1041.  
  1042.   D3DVS_ADDRESSMODE_SHIFT = 13;
  1043.   D3DVS_ADDRESSMODE_MASK  = 1 shl D3DVS_ADDRESSMODE_SHIFT;
  1044.  
  1045. type
  1046.   TD3DVS_AddressMode_Type = LongWord;
  1047.   TD3DVSAddressModeType = LongWord;  
  1048.  
  1049. const
  1050.   D3DVS_ADDRMODE_ABSOLUTE    = 0 shl D3DVS_ADDRESSMODE_SHIFT;
  1051.   D3DVS_ADDRMODE_RELATIVE    = 1 shl D3DVS_ADDRESSMODE_SHIFT;  // Relative to register A0
  1052.   D3DVS_ADDRMODE_FORCE_DWORD = $7fffffff;                      // force 32-bit size enum
  1053.                                                                
  1054. // Source operand swizzle definitions
  1055. //
  1056.   D3DVS_SWIZZLE_SHIFT     = 16;
  1057.   D3DVS_SWIZZLE_MASK      = $00FF0000;
  1058.  
  1059. // The following bits define where to take component X:
  1060.  
  1061.   D3DVS_X_X = 0 shl D3DVS_SWIZZLE_SHIFT;
  1062.   D3DVS_X_Y = 1 shl D3DVS_SWIZZLE_SHIFT;
  1063.   D3DVS_X_Z = 2 shl D3DVS_SWIZZLE_SHIFT;
  1064.   D3DVS_X_W = 3 shl D3DVS_SWIZZLE_SHIFT;
  1065.  
  1066. // The following bits define where to take component Y:
  1067.  
  1068.   D3DVS_Y_X = 0 shl (D3DVS_SWIZZLE_SHIFT + 2);
  1069.   D3DVS_Y_Y = 1 shl (D3DVS_SWIZZLE_SHIFT + 2);
  1070.   D3DVS_Y_Z = 2 shl (D3DVS_SWIZZLE_SHIFT + 2);
  1071.   D3DVS_Y_W = 3 shl (D3DVS_SWIZZLE_SHIFT + 2);
  1072.  
  1073. // The following bits define where to take component Z:
  1074.  
  1075.   D3DVS_Z_X = 0 shl (D3DVS_SWIZZLE_SHIFT + 4);
  1076.   D3DVS_Z_Y = 1 shl (D3DVS_SWIZZLE_SHIFT + 4);
  1077.   D3DVS_Z_Z = 2 shl (D3DVS_SWIZZLE_SHIFT + 4);
  1078.   D3DVS_Z_W = 3 shl (D3DVS_SWIZZLE_SHIFT + 4);
  1079.  
  1080. // The following bits define where to take component W:
  1081.  
  1082.   D3DVS_W_X = 0 shl (D3DVS_SWIZZLE_SHIFT + 6);
  1083.   D3DVS_W_Y = 1 shl (D3DVS_SWIZZLE_SHIFT + 6);
  1084.   D3DVS_W_Z = 2 shl (D3DVS_SWIZZLE_SHIFT + 6);
  1085.   D3DVS_W_W = 3 shl (D3DVS_SWIZZLE_SHIFT + 6);
  1086.  
  1087. // Value when there is no swizzle (X is taken from X; Y is taken from Y;
  1088. // Z is taken from Z; W is taken from W
  1089. //
  1090.   D3DVS_NOSWIZZLE = D3DVS_X_X or D3DVS_Y_Y or D3DVS_Z_Z or D3DVS_W_W;
  1091.  
  1092. // source parameter swizzle
  1093.   D3DSP_SWIZZLE_SHIFT = 16;
  1094.   D3DSP_SWIZZLE_MASK  = $00FF0000;
  1095.  
  1096.   D3DSP_NOSWIZZLE = (0 shl (D3DSP_SWIZZLE_SHIFT + 0)) or
  1097.                     (1 shl (D3DSP_SWIZZLE_SHIFT + 2)) or
  1098.                     (2 shl (D3DSP_SWIZZLE_SHIFT + 4)) or
  1099.                     (3 shl (D3DSP_SWIZZLE_SHIFT + 6));
  1100.  
  1101. // pixel-shader swizzle ops
  1102.   D3DSP_REPLICATEALPHA = (3 shl (D3DSP_SWIZZLE_SHIFT + 0)) or
  1103.                          (3 shl (D3DSP_SWIZZLE_SHIFT + 2)) or
  1104.                          (3 shl (D3DSP_SWIZZLE_SHIFT + 4)) or
  1105.                          (3 shl (D3DSP_SWIZZLE_SHIFT + 6));
  1106.  
  1107. // source parameter modifiers
  1108.   D3DSP_SRCMOD_SHIFT      = 24;
  1109.   D3DSP_SRCMOD_MASK       = $0F000000;
  1110.  
  1111. type
  1112.   TD3DShader_Param_SRCMod_Type = LongWord;
  1113.  
  1114. const
  1115.   D3DSPSM_NONE        = 0 shl D3DSP_SRCMOD_SHIFT; // nop
  1116.   D3DSPSM_NEG         = 1 shl D3DSP_SRCMOD_SHIFT; // negate
  1117.   D3DSPSM_BIAS        = 2 shl D3DSP_SRCMOD_SHIFT; // bias
  1118.   D3DSPSM_BIASNEG     = 3 shl D3DSP_SRCMOD_SHIFT; // bias and negate
  1119.   D3DSPSM_SIGN        = 4 shl D3DSP_SRCMOD_SHIFT; // sign
  1120.   D3DSPSM_SIGNNEG     = 5 shl D3DSP_SRCMOD_SHIFT; // sign and negate
  1121.   D3DSPSM_COMP        = 6 shl D3DSP_SRCMOD_SHIFT; // complement
  1122.   D3DSPSM_FORCE_DWORD = $7fffffff;                // force 32-bit size enum
  1123.  
  1124. // pixel shader version token
  1125.   function D3DPS_VERSION(_Major, _Minor : LongWord) : LongWord;
  1126.  
  1127. // vertex shader version token
  1128.   function D3DVS_VERSION(_Major, _Minor : LongWord) : LongWord;
  1129.  
  1130. // extract major/minor from version cap
  1131.   function D3DSHADER_VERSION_MAJOR(_Version : LongWord) : LongWord;
  1132.   function D3DSHADER_VERSION_MINOR(_Version : LongWord) : LongWord;
  1133.  
  1134.  
  1135. // destination/source parameter register type
  1136. const
  1137.   D3DSI_COMMENTSIZE_SHIFT = 16;
  1138.   D3DSI_COMMENTSIZE_MASK  = $7FFF0000;
  1139.  
  1140.   function  D3DSHADER_COMMENT(_DWordSize : LongWord) : LongWord;
  1141.  
  1142. // pixel/vertex shader end token
  1143. const
  1144.   D3DPS_END  = $0000FFFF;
  1145.   D3DVS_END  = $0000FFFF;
  1146.  
  1147. //---------------------------------------------------------------------
  1148.  
  1149. // High order surfaces
  1150. //
  1151. type
  1152.   TD3DBasisType = LongWord;
  1153.  
  1154. const
  1155.   D3DBASIS_BEZIER      = 0;
  1156.   D3DBASIS_BSPLINE     = 1;
  1157.   D3DBASIS_INTERPOLATE = 2;
  1158.   D3DBASIS_FORCE_DWORD = $7fffffff;
  1159.  
  1160. type
  1161.   TD3DOrderType = LongWord;
  1162.  
  1163. const
  1164.   D3DORDER_LINEAR      = 1;
  1165.   D3DORDER_CUBIC       = 3;
  1166.   D3DORDER_QUINTIC     = 5;
  1167.   D3DORDER_FORCE_DWORD = $7fffffff;
  1168.  
  1169. type
  1170.   TD3DPatchEdgeStyle = LongWord;
  1171.  
  1172. const
  1173.   D3DPATCHEDGE_DISCRETE    = 0;
  1174.   D3DPATCHEDGE_CONTINUOUS  = 1;
  1175.   D3DPATCHEDGE_FORCE_DWORD = $7fffffff;
  1176.  
  1177. type
  1178.   TD3DStateBlockType = LongWord;
  1179.  
  1180. const
  1181.   D3DSBT_ALL           = 1; // capture all state
  1182.   D3DSBT_PIXELSTATE    = 2; // capture pixel state
  1183.   D3DSBT_VERTEXSTATE   = 3; // capture vertex state
  1184.   D3DSBT_FORCE_DWORD   = $7fffffff;
  1185.  
  1186.  
  1187. // The D3DVERTEXBLENDFLAGS type is used with D3DRS_VERTEXBLEND state.
  1188. //
  1189. type
  1190.   TD3DVertexBlendFlags = LongWord;
  1191.  
  1192. const
  1193.   D3DVBF_DISABLE  = 0;            // Disable vertex blending
  1194.   D3DVBF_1WEIGHTS = 1;            // 2 matrix blending
  1195.   D3DVBF_2WEIGHTS = 2;            // 3 matrix blending
  1196.   D3DVBF_3WEIGHTS = 3;            // 4 matrix blending
  1197.   D3DVBF_TWEENING = 255;          // blending using D3DRS_TWEENFACTOR
  1198.   D3DVBF_0WEIGHTS = 256;          // one matrix is used with weight 1.0
  1199.   D3DVBF_FORCE_DWORD = $7fffffff; // force 32-bit size enum
  1200.  
  1201. type
  1202.   TD3DTextureTransformFlags = LongWord;
  1203.  
  1204. const
  1205.     D3DTTFF_DISABLE         = 0;    // texture coordinates are passed directly
  1206.     D3DTTFF_COUNT1          = 1;    // rasterizer should expect 1-D texture coords
  1207.     D3DTTFF_COUNT2          = 2;    // rasterizer should expect 2-D texture coords
  1208.     D3DTTFF_COUNT3          = 3;    // rasterizer should expect 3-D texture coords
  1209.     D3DTTFF_COUNT4          = 4;    // rasterizer should expect 4-D texture coords
  1210.     D3DTTFF_PROJECTED       = 256;  // texcoords to be divided by COUNTth element
  1211.     D3DTTFF_FORCE_DWORD     = $7fffffff;
  1212.  
  1213. // Macros to set texture coordinate format bits in the FVF id
  1214.  
  1215.   D3DFVF_TEXTUREFORMAT2 = 0;         // Two floating point values
  1216.   D3DFVF_TEXTUREFORMAT1 = 3;         // One floating point value
  1217.   D3DFVF_TEXTUREFORMAT3 = 1;         // Three floating point values
  1218.   D3DFVF_TEXTUREFORMAT4 = 2;         // Four floating point values
  1219.  
  1220.   function D3DFVF_TEXCOORDSIZE3(CoordIndex : LongWord) : LongWord;
  1221.   function D3DFVF_TEXCOORDSIZE2(CoordIndex : LongWord) : LongWord;
  1222.   function D3DFVF_TEXCOORDSIZE4(CoordIndex : LongWord) : LongWord;
  1223.   function D3DFVF_TEXCOORDSIZE1(CoordIndex : LongWord) : LongWord;
  1224.  
  1225. //---------------------------------------------------------------------
  1226.  
  1227. (* Direct3D8 Device types *)
  1228.  
  1229. type
  1230.   TD3DDevType = LongWord;
  1231.  
  1232. const
  1233.   D3DDEVTYPE_HAL         = 1;
  1234.   D3DDEVTYPE_REF         = 2;
  1235.   D3DDEVTYPE_SW          = 3;
  1236.  
  1237.   D3DDEVTYPE_FORCE_DWORD  = $7fffffff;
  1238.  
  1239. (* Multi-Sample buffer types *)
  1240. type
  1241.   TD3DMultiSample_Type = LongWord;
  1242.   TD3DMultiSampleType = TD3DMultiSample_Type;
  1243.  
  1244. const
  1245.   D3DMULTISAMPLE_NONE            =  0;
  1246.   D3DMULTISAMPLE_2_SAMPLES       =  2;
  1247.   D3DMULTISAMPLE_3_SAMPLES       =  3;
  1248.   D3DMULTISAMPLE_4_SAMPLES       =  4;
  1249.   D3DMULTISAMPLE_5_SAMPLES       =  5;
  1250.   D3DMULTISAMPLE_6_SAMPLES       =  6;
  1251.   D3DMULTISAMPLE_7_SAMPLES       =  7;
  1252.   D3DMULTISAMPLE_8_SAMPLES       =  8;
  1253.   D3DMULTISAMPLE_9_SAMPLES       =  9;
  1254.   D3DMULTISAMPLE_10_SAMPLES      = 10;
  1255.   D3DMULTISAMPLE_11_SAMPLES      = 11;
  1256.   D3DMULTISAMPLE_12_SAMPLES      = 12;
  1257.   D3DMULTISAMPLE_13_SAMPLES      = 13;
  1258.   D3DMULTISAMPLE_14_SAMPLES      = 14;
  1259.   D3DMULTISAMPLE_15_SAMPLES      = 15;
  1260.   D3DMULTISAMPLE_16_SAMPLES      = 16;
  1261.  
  1262.   D3DMULTISAMPLE_FORCE_DWORD     = $7fffffff;
  1263.  
  1264.  
  1265. (* Formats
  1266.  * Most of these names have the following convention:
  1267.  *      A = Alpha
  1268.  *      R = Red
  1269.  *      G = Green
  1270.  *      B = Blue
  1271.  *      X = Unused Bits
  1272.  *      P = Palette
  1273.  *      L = Luminance
  1274.  *      U = dU coordinate for BumpMap
  1275.  *      V = dV coordinate for BumpMap
  1276.  *      S = Stencil
  1277.  *      D = Depth (e.g. Z or W buffer)
  1278.  *
  1279.  *      Further; the order of the pieces are from MSB first; hence
  1280.  *      D3DFMT_A8L8 indicates that the high byte of this two byte
  1281.  *      format is alpha.
  1282.  *
  1283.  *      D16 indicates:
  1284.  *           - An integer 16-bit value.
  1285.  *           - An app-lockable surface.
  1286.  *
  1287.  *      All Depth/Stencil formats except D3DFMT_D16_LOCKABLE indicate:
  1288.  *          - no particular bit ordering per pixel; and
  1289.  *          - are not app lockable; and
  1290.  *          - the driver is allowed to consume more than the indicated
  1291.  *            number of bits per Depth channel (but not Stencil channel).
  1292.  *)
  1293.  
  1294.   function MAKEFOURCC(ch0, ch1, ch2, ch3 : Char) : LongWord;
  1295.  
  1296. type
  1297.   PD3DFormat = ^TD3DFormat;
  1298.   TD3DFormat = LongWord;
  1299.  
  1300. const
  1301.   D3DFMT_UNKNOWN              = 0;
  1302.  
  1303.   D3DFMT_R8G8B8               = 20;
  1304.   D3DFMT_A8R8G8B8             = 21;
  1305.   D3DFMT_X8R8G8B8             = 22;
  1306.   D3DFMT_R5G6B5               = 23;
  1307.   D3DFMT_X1R5G5B5             = 24;
  1308.   D3DFMT_A1R5G5B5             = 25;
  1309.   D3DFMT_A4R4G4B4             = 26;
  1310.   D3DFMT_R3G3B2               = 27;
  1311.   D3DFMT_A8                   = 28;
  1312.   D3DFMT_A8R3G3B2             = 29;
  1313.   D3DFMT_X4R4G4B4             = 30;
  1314.  
  1315.   D3DFMT_A8P8                 = 40;
  1316.   D3DFMT_P8                   = 41;
  1317.  
  1318.   D3DFMT_L8                   = 50;
  1319.   D3DFMT_A8L8                 = 51;
  1320.   D3DFMT_A4L4                 = 52;
  1321.  
  1322.   D3DFMT_V8U8                 = 60;
  1323.   D3DFMT_L6V5U5               = 61;
  1324.   D3DFMT_X8L8V8U8             = 62;
  1325.   D3DFMT_Q8W8V8U8             = 63;
  1326.   D3DFMT_V16U16               = 64;
  1327.   D3DFMT_W11V11U10            = 65;
  1328.  
  1329.   D3DFMT_UYVY = Byte('U') or (Byte('Y') shl 8) or (Byte('V') shl 16) or (Byte('Y') shl 24 );
  1330.   D3DFMT_YUY2 = Byte('Y') or (Byte('U') shl 8) or (Byte('Y') shl 16) or (Byte('2') shl 24 );
  1331.   D3DFMT_DXT1 = Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('1') shl 24 );
  1332.   D3DFMT_DXT2 = Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('2') shl 24 );
  1333.   D3DFMT_DXT3 = Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('3') shl 24 );
  1334.   D3DFMT_DXT4 = Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('4') shl 24 );
  1335.   D3DFMT_DXT5 = Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('5') shl 24 );
  1336.  
  1337.   D3DFMT_D16_LOCKABLE         = 70;
  1338.   D3DFMT_D32                  = 71;
  1339.   D3DFMT_D15S1                = 73;
  1340.   D3DFMT_D24S8                = 75;
  1341.   D3DFMT_D16                  = 80;
  1342.   D3DFMT_D24X8                = 77;
  1343.   D3DFMT_D24X4S4              = 79;
  1344.  
  1345.  
  1346.   D3DFMT_VERTEXDATA           = 100;
  1347.   D3DFMT_INDEX16              = 101;
  1348.   D3DFMT_INDEX32              = 102;
  1349.  
  1350.   D3DFMT_FORCE_DWORD          = $7fffffff;
  1351.  
  1352. (* Display Modes *)
  1353. type
  1354.   PD3DDisplayMode = ^TD3DDisplayMode;
  1355.   TD3DDisplayMode = packed record
  1356.     Width       : Cardinal;
  1357.     Height      : Cardinal;
  1358.     RefreshRate : Cardinal;
  1359.     Format      : TD3DFormat;
  1360.   end;
  1361.  
  1362. (* Creation Parameters *)
  1363.   PD3DDevice_Creation_Parameters = ^TD3DDevice_Creation_Parameters;
  1364.   TD3DDevice_Creation_Parameters = packed record
  1365.     AdapterOrdinal : Cardinal;
  1366.     DeviceType     : TD3DDevType;
  1367.     hFocusWindow   : HWND;
  1368.     BehaviorFlags  : LongWord;
  1369.   end;
  1370.  
  1371.   PD3DDeviceCreationParameters = ^TD3DDeviceCreationParameters;
  1372.   TD3DDeviceCreationParameters = TD3DDevice_Creation_Parameters; 
  1373.  
  1374. (* SwapEffects *)
  1375. type
  1376.   TD3DSwapEffect = LongWord;
  1377.  
  1378. const
  1379.   D3DSWAPEFFECT_DISCARD           = 1;
  1380.   D3DSWAPEFFECT_FLIP              = 2;
  1381.   D3DSWAPEFFECT_COPY              = 3;
  1382.   D3DSWAPEFFECT_COPY_VSYNC        = 4;
  1383.  
  1384.   D3DSWAPEFFECT_FORCE_DWORD       = $7fffffff;
  1385.  
  1386. (* Pool types *)
  1387. type
  1388.   TD3DPool  = LongWord;
  1389.  
  1390. const
  1391.   D3DPOOL_DEFAULT                 = 0;
  1392.   D3DPOOL_MANAGED                 = 1;
  1393.   D3DPOOL_SYSTEMMEM               = 2;
  1394.  
  1395.   D3DPOOL_FORCE_DWORD             = $7fffffff;
  1396.  
  1397.  
  1398. (* RefreshRate pre-defines *)
  1399.   D3DPRESENT_RATE_DEFAULT         = $00000000;
  1400.   D3DPRESENT_RATE_UNLIMITED       = $7fffffff;
  1401.  
  1402.  
  1403. (* Resize Optional Parameters *)
  1404. type
  1405.   PD3DPresent_Parameters = ^TD3DPresent_Parameters;
  1406.   TD3DPresent_Parameters = packed record
  1407.     BackBufferWidth                 : Cardinal;
  1408.     BackBufferHeight                : Cardinal;
  1409.     BackBufferFormat                : TD3DFormat;
  1410.     BackBufferCount                 : Cardinal;
  1411.  
  1412.     MultiSampleType                 : TD3DMultiSample_Type;
  1413.  
  1414.     SwapEffect                      : TD3DSwapEffect;
  1415.     hDeviceWindow                   : HWND;
  1416.     Windowed                        : BOOL;
  1417.     EnableAutoDepthStencil          : BOOL;
  1418.     AutoDepthStencilFormat          : TD3DFormat;
  1419.     Flags                           : LongWord;
  1420.  
  1421.     (* Following elements must be zero for Windowed mode *)
  1422.     FullScreen_RefreshRateInHz      : Cardinal;
  1423.     FullScreen_PresentationInterval : Cardinal;
  1424.   end;
  1425.  
  1426.   PD3DPresentParameters = ^TD3DPresentParameters;
  1427.   TD3DPresentParameters = TD3DPresent_Parameters;
  1428.  
  1429. // Values for D3DPRESENT_PARAMETERS.Flags
  1430. const
  1431.   D3DPRESENTFLAG_LOCKABLE_BACKBUFFER  = $00000001;
  1432.  
  1433.  
  1434. (* Gamma Ramp: Same as DX7 *)
  1435. type
  1436.   PD3DGammaRamp = ^TD3DGammaRamp;
  1437.   TD3DGammaRamp = packed record
  1438.     red   : array [0..255] of Word;
  1439.     green : array [0..255] of Word;
  1440.     blue  : array [0..255] of Word;
  1441.   end;
  1442.  
  1443. (* Back buffer types *)
  1444. type
  1445.   TD3DBackBuffer_Type = LongWord;
  1446.   TD3DBackBufferType = LongWord;
  1447.  
  1448. const
  1449.   D3DBACKBUFFER_TYPE_MONO         = 0;
  1450.   D3DBACKBUFFER_TYPE_LEFT         = 1;
  1451.   D3DBACKBUFFER_TYPE_RIGHT        = 2;
  1452.  
  1453.   D3DBACKBUFFER_TYPE_FORCE_DWORD  = $7fffffff;
  1454.  
  1455.  
  1456.  
  1457. (* Types *)
  1458. type
  1459.   TD3DResourceType = LongWord;
  1460.  
  1461. const
  1462.   D3DRTYPE_SURFACE                = 1;
  1463.   D3DRTYPE_VOLUME                 = 2;
  1464.   D3DRTYPE_TEXTURE                = 3;
  1465.   D3DRTYPE_VOLUMETEXTURE          = 4;
  1466.   D3DRTYPE_CUBETEXTURE            = 5;
  1467.   D3DRTYPE_VERTEXBUFFER           = 6;
  1468.   D3DRTYPE_INDEXBUFFER            = 7;
  1469.  
  1470.  
  1471.   D3DRTYPE_FORCE_DWORD            = $7fffffff;
  1472.  
  1473. (* Usages *)
  1474.   D3DUSAGE_RENDERTARGET       = $00000001;
  1475.   D3DUSAGE_DEPTHSTENCIL       = $00000002;
  1476.  
  1477. (* Usages for Vertex/Index buffers *)
  1478.   D3DUSAGE_WRITEONLY          = $00000008;
  1479.   D3DUSAGE_SOFTWAREPROCESSING = $00000010;
  1480.   D3DUSAGE_DONOTCLIP          = $00000020;
  1481.   D3DUSAGE_POINTS             = $00000040;
  1482.   D3DUSAGE_RTPATCHES          = $00000080;
  1483.   D3DUSAGE_NPATCHES           = $00000100;
  1484.   D3DUSAGE_DYNAMIC            = $00000200;
  1485.  
  1486. (* CubeMap Face identifiers *)
  1487. type
  1488.   TD3DCubeMap_Faces = LongWord;
  1489.   TD3DCubeMapFaces = TD3DCubeMap_Faces;
  1490.  
  1491. const
  1492.   D3DCUBEMAP_FACE_POSITIVE_X     = 0;
  1493.   D3DCUBEMAP_FACE_NEGATIVE_X     = 1;
  1494.   D3DCUBEMAP_FACE_POSITIVE_Y     = 2;
  1495.   D3DCUBEMAP_FACE_NEGATIVE_Y     = 3;
  1496.   D3DCUBEMAP_FACE_POSITIVE_Z     = 4;
  1497.   D3DCUBEMAP_FACE_NEGATIVE_Z     = 5;
  1498.  
  1499.   D3DCUBEMAP_FACE_FORCE_DWORD    = $7fffffff;
  1500.  
  1501.  
  1502. (* Lock flags *)
  1503.  
  1504.   D3DLOCK_READONLY         = $00000010;
  1505.   D3DLOCK_DISCARD          = $00002000;
  1506.   D3DLOCK_NOOVERWRITE      = $00001000;
  1507.   D3DLOCK_NOSYSLOCK        = $00000800;
  1508.  
  1509.   D3DLOCK_NO_DIRTY_UPDATE  = $00008000;
  1510.  
  1511. (* Vertex Buffer Description *)
  1512. type
  1513.   PD3DVertexBuffer_Desc = ^TD3DVertexBuffer_Desc;
  1514.   TD3DVertexBuffer_Desc = packed record
  1515.     Format : TD3DFormat;
  1516.     _Type  : TD3DResourceType;
  1517.     Usage  : LongWord;
  1518.     Pool   : TD3DPool;
  1519.     Size   : Cardinal;
  1520.     FVF    : LongWord;
  1521.   end;
  1522.  
  1523.   PD3DVertexBufferDesc = ^TD3DVertexBufferDesc;
  1524.   TD3DVertexBufferDesc = TD3DVertexBuffer_Desc;
  1525.  
  1526. (* Index Buffer Description *)
  1527.   PTD3DIndexBuffer_Desc = ^TD3DIndexBuffer_Desc;
  1528.   TD3DIndexBuffer_Desc = packed record
  1529.     Format : TD3DFormat;
  1530.     _Type  : TD3DResourceType;
  1531.     Usage  : LongWord;
  1532.     Pool   : TD3DPool;
  1533.     Size   : Cardinal;
  1534.   end;
  1535.  
  1536.   PTD3DIndexBufferDesc = ^TD3DIndexBufferDesc;
  1537.   TD3DIndexBufferDesc = TD3DIndexBuffer_Desc;
  1538.  
  1539.  
  1540. (* Surface Description *)
  1541.   PD3DSurface_Desc = ^TD3DSurface_Desc;
  1542.   TD3DSurface_Desc = packed record
  1543.     Format          : TD3DFormat;
  1544.     _Type           : TD3DResourceType;
  1545.     Usage           : LongWord;
  1546.     Pool            : TD3DPool;
  1547.     Size            : Cardinal;
  1548.     MultiSampleType : TD3DMultiSample_Type;
  1549.     Width           : Cardinal;
  1550.     Height          : Cardinal;
  1551.   end;
  1552.  
  1553.   PD3DSurfaceDesc = ^TD3DSurfaceDesc;
  1554.   TD3DSurfaceDesc = TD3DSurface_Desc;
  1555.  
  1556.  
  1557.   PD3DVolume_Desc = ^TD3DVolume_Desc;
  1558.   TD3DVolume_Desc = packed record
  1559.     Format : TD3DFormat;
  1560.     _Type  : TD3DResourceType;
  1561.     Usage  : LongWord;
  1562.     Pool   : TD3DPool;
  1563.     Size   : Cardinal;
  1564.     Width  : Cardinal;
  1565.     Height : Cardinal;
  1566.     Depth  : Cardinal;
  1567.   end;
  1568.  
  1569.   PD3DVolumeDesc = ^TD3DVolumeDesc;
  1570.   TD3DVolumeDesc = TD3DVolume_Desc;
  1571.  
  1572.  
  1573. (* Structure for LockRect *)
  1574.   PD3DLocked_Rect = ^TD3DLocked_Rect;
  1575.   TD3DLocked_Rect = packed record
  1576.     Pitch : Integer;
  1577.     pBits : Pointer;//void*
  1578.   end;
  1579.  
  1580.   PD3DLockedRect = ^TD3DLockedRect;
  1581.   TD3DLockedRect = TD3DLocked_Rect;
  1582.  
  1583.  
  1584. (* Structures for LockBox *)
  1585.   PD3DBox = ^TD3DBox;
  1586.   TD3DBox = packed record
  1587.     Left   : Cardinal;
  1588.     Top    : Cardinal;
  1589.     Right  : Cardinal;
  1590.     Bottom : Cardinal;
  1591.     Front  : Cardinal;
  1592.     Back   : Cardinal;
  1593.   end;
  1594.  
  1595.   PD3DLocked_Box = ^TD3DLocked_Box;
  1596.   TD3DLocked_Box = packed record
  1597.     RowPitch   : Integer;
  1598.     SlicePitch : Integer;
  1599.     pBits      : Pointer;
  1600.   end;
  1601.  
  1602.   PD3DLockedBox = ^TD3DLockedBox;
  1603.   TD3DLockedBox = TD3DLocked_Box;
  1604.  
  1605.  
  1606. (* Structures for LockRange *)
  1607.   PD3DRange = ^TD3DRange;
  1608.   TD3DRange = packed record
  1609.     Offset : Cardinal;
  1610.     Size   : Cardinal;
  1611.   end;
  1612.  
  1613. (* Structures for high order primitives *)
  1614.   PD3DRectPatch_Info = ^TD3DRectPatch_Info;
  1615.   TD3DRectPatch_Info = packed record
  1616.     StartVertexOffsetWidth  : Cardinal;
  1617.     StartVertexOffsetHeight : Cardinal;
  1618.     Width                   : Cardinal;
  1619.     Height                  : Cardinal;
  1620.     Stride                  : Cardinal;
  1621.     Basis                   : TD3DBasisType;
  1622.     Order                   : TD3DOrderType;
  1623.   end;
  1624.  
  1625.   PD3DRectPatchInfo = ^TD3DRectPatchInfo;
  1626.   TD3DRectPatchInfo = TD3DRectPatch_Info;
  1627.  
  1628.   
  1629.   PD3DTriPatch_Info = ^TD3DTriPatch_Info;
  1630.   TD3DTriPatch_Info = packed record
  1631.     StartVertexOffset : Cardinal;
  1632.     NumVertices       : Cardinal;
  1633.     Basis             : TD3DBasisType;
  1634.     Order             : TD3DOrderType;
  1635.   end;
  1636.  
  1637.   PD3DTriPatchInfo = ^TD3DTriPatchInfo;
  1638.   TD3DTriPatchInfo = TD3DTriPatch_Info;
  1639.  
  1640.  
  1641. (* Adapter Identifier *)
  1642. const
  1643.   MAX_DEVICE_IDENTIFIER_STRING = 512;
  1644.  
  1645. type
  1646.   PD3DAdapter_Identifier8 = ^TD3DAdapter_Identifier8; 
  1647.   TD3DAdapter_Identifier8 = packed record
  1648.     Driver      : array [0..MAX_DEVICE_IDENTIFIER_STRING-1] of Char;
  1649.     Description : array [0..MAX_DEVICE_IDENTIFIER_STRING-1] of Char;
  1650.  
  1651.     DriverVersionLowPart : LongWord;     (* Defined for 16 bit driver components *)
  1652.     DriverVersionHighPart : LongWord;
  1653.  
  1654.     VendorId : LongWord;
  1655.     DeviceId : LongWord;
  1656.     SubSysId : LongWord;
  1657.     Revision : LongWord;
  1658.  
  1659.     DeviceIdentifier : TGUID;
  1660.  
  1661.     WHQLLevel : LongWord;
  1662.  
  1663.   end;
  1664.  
  1665.   PD3DAdapterIdentifier8 = ^TD3DAdapterIdentifier8;
  1666.   TD3DAdapterIdentifier8 = TD3DAdapter_Identifier8;
  1667.  
  1668.  
  1669. (* Raster Status structure returned by GetRasterStatus *)
  1670.   PD3DRaster_Status = ^TD3DRaster_Status;
  1671.   TD3DRaster_Status = packed record
  1672.     InVBlank : Bool;
  1673.     ScanLine : Cardinal;
  1674.   end;
  1675.  
  1676.   PD3DRasterStatus = ^TD3DRasterStatus;
  1677.   TD3DRasterStatus = TD3DRaster_Status;
  1678.  
  1679. (* Debug monitor tokens (DEBUG only)
  1680.  
  1681.    Note that if D3DRS_DEBUGMONITORTOKEN is set; the call is treated as
  1682.    passing a token to the debug monitor.  For example; if; after passing
  1683.    D3DDMT_ENABLE/DISABLE to D3DRS_DEBUGMONITORTOKEN other token values
  1684.    are passed in; the enabled/disabled state of the debug
  1685.    monitor will still persist.
  1686.  
  1687.    The debug monitor defaults to enabled.
  1688.  
  1689.    Calling GetRenderState on D3DRS_DEBUGMONITORTOKEN is not of any use.
  1690. *)
  1691. type
  1692.   TD3DDebugMonitorTokens = LongWord;
  1693.   
  1694. const
  1695.     D3DDMT_ENABLE          = 0;    // enable debug monitor
  1696.     D3DDMT_DISABLE         = 1;    // disable debug monitor
  1697.     D3DDMT_FORCE_DWORD     = $7fffffff;
  1698.  
  1699.  
  1700. (*==========================================================================;
  1701.  *
  1702.  *  Copyright (C) 1995-2000 Microsoft Corporation.  All Rights Reserved.
  1703.  *
  1704.  *  File:       d3d8caps.h
  1705.  *  Content:    Direct3D capabilities include file
  1706.  *
  1707.  ***************************************************************************)
  1708.  
  1709. type
  1710.   PD3DCaps8 = ^TD3DCaps8;
  1711.   TD3DCaps8 = packed record
  1712.     (* Device Info *)
  1713.     DeviceType                : TD3DDevType;
  1714.     AdapterOrdinal            : LongWord;
  1715.  
  1716.     (* Caps from DX7 Draw *)
  1717.     Caps                      : LongWord;
  1718.     Caps2                     : LongWord;
  1719.     Caps3                     : LongWord;
  1720.     PresentationIntervals     : LongWord;
  1721.  
  1722.     (* Cursor Caps *)
  1723.     CursorCaps                : LongWord;
  1724.  
  1725.     (* 3D Device Caps *)
  1726.     DevCaps                   : LongWord;
  1727.  
  1728.     PrimitiveMiscCaps         : LongWord;
  1729.     RasterCaps                : LongWord;
  1730.     ZCmpCaps                  : LongWord;
  1731.     SrcBlendCaps              : LongWord;
  1732.     DestBlendCaps             : LongWord;
  1733.     AlphaCmpCaps              : LongWord;
  1734.     ShadeCaps                 : LongWord;
  1735.     TextureCaps               : LongWord;
  1736.     TextureFilterCaps         : LongWord;  // D3DPTFILTERCAPS for IDirect3DTexture8's
  1737.     CubeTextureFilterCaps     : LongWord;  // D3DPTFILTERCAPS for IDirect3DCubeTexture8's
  1738.     VolumeTextureFilterCaps   : LongWord;  // D3DPTFILTERCAPS for IDirect3DVolumeTexture8's
  1739.     TextureAddressCaps        : LongWord;  // D3DPTADDRESSCAPS for IDirect3DTexture8's
  1740.     VolumeTextureAddressCaps  : LongWord;  // D3DPTADDRESSCAPS for IDirect3DVolumeTexture8's
  1741.  
  1742.     LineCaps                  : LongWord;  // D3DLINECAPS
  1743.  
  1744.     MaxTextureWidth           : LongWord;
  1745.     MaxTextureHeight          : LongWord;
  1746.     MaxVolumeExtent           : LongWord;
  1747.  
  1748.     MaxTextureRepeat          : LongWord;
  1749.     MaxTextureAspectRatio     : LongWord;
  1750.     MaxAnisotropy             : LongWord;
  1751.     MaxVertexW                : Single;
  1752.  
  1753.     GuardBandLeft             : Single;
  1754.     GuardBandTop              : Single;
  1755.     GuardBandRight            : Single;
  1756.     GuardBandBottom           : Single;
  1757.  
  1758.     ExtentsAdjust             : Single;
  1759.     StencilCaps               : LongWord;
  1760.  
  1761.     FVFCaps                   : LongWord;
  1762.     TextureOpCaps             : LongWord;
  1763.     MaxTextureBlendStages     : LongWord;
  1764.     MaxSimultaneousTextures   : LongWord;
  1765.  
  1766.     VertexProcessingCaps      : LongWord;
  1767.     MaxActiveLights           : LongWord;
  1768.     MaxUserClipPlanes         : LongWord;
  1769.     MaxVertexBlendMatrices    : LongWord;
  1770.     MaxVertexBlendMatrixIndex : LongWord;
  1771.  
  1772.     MaxPointSize              : Single;
  1773.  
  1774.     MaxPrimitiveCount         : LongWord;  // max number of primitives per DrawPrimitive call
  1775.     MaxVertexIndex            : LongWord;
  1776.     MaxStreams                : LongWord;
  1777.     MaxStreamStride           : LongWord;  // max stride for SetStreamSource
  1778.  
  1779.     VertexShaderVersion       : LongWord;
  1780.     MaxVertexShaderConst      : LongWord;  // number of vertex shader constant registers
  1781.  
  1782.     PixelShaderVersion        : LongWord;
  1783.     MaxPixelShaderValue       : Single;    // max value of pixel shader arithmetic component
  1784.   end;
  1785.  
  1786. //
  1787. // BIT DEFINES FOR D3DCAPS8 DWORD MEMBERS
  1788. //
  1789.  
  1790. //
  1791. // Caps
  1792. //
  1793. const
  1794.   D3DCAPS_READ_SCANLINE = $00020000;
  1795.  
  1796. //
  1797. // Caps2
  1798. //
  1799.   D3DCAPS2_NO2DDURING3DSCENE      = $00000002;
  1800.   D3DCAPS2_FULLSCREENGAMMA        = $00020000;
  1801.   D3DCAPS2_CANRENDERWINDOWED      = $00080000;
  1802.   D3DCAPS2_CANCALIBRATEGAMMA      = $00100000;
  1803.   D3DCAPS2_RESERVED               = $02000000;
  1804.  
  1805. //
  1806. // Caps3
  1807. //
  1808.   D3DCAPS3_RESERVED               = $8000001f;
  1809.  
  1810. //
  1811. // PresentationIntervals
  1812. //
  1813.   D3DPRESENT_INTERVAL_DEFAULT     = $00000000;
  1814.   D3DPRESENT_INTERVAL_ONE         = $00000001;
  1815.   D3DPRESENT_INTERVAL_TWO         = $00000002;
  1816.   D3DPRESENT_INTERVAL_THREE       = $00000004;
  1817.   D3DPRESENT_INTERVAL_FOUR        = $00000008;
  1818.   D3DPRESENT_INTERVAL_IMMEDIATE   = $80000000;
  1819.  
  1820. //
  1821. // CursorCaps
  1822. //
  1823. // Driver supports HW color cursor in at least hi-res modes(height >=400)
  1824.   D3DCURSORCAPS_COLOR             = $00000001;
  1825. // Driver supports HW cursor also in low-res modes(height < 400)
  1826.   D3DCURSORCAPS_LOWRES            = $00000002;
  1827.  
  1828. //
  1829. // DevCaps
  1830. //                                   
  1831.   D3DDEVCAPS_EXECUTESYSTEMMEMORY     = $00000010; (* Device can use execute buffers from system memory *)
  1832.   D3DDEVCAPS_EXECUTEVIDEOMEMORY      = $00000020; (* Device can use execute buffers from video memory *)
  1833.   D3DDEVCAPS_TLVERTEXSYSTEMMEMORY    = $00000040; (* Device can use TL buffers from system memory *)
  1834.   D3DDEVCAPS_TLVERTEXVIDEOMEMORY     = $00000080; (* Device can use TL buffers from video memory *)
  1835.   D3DDEVCAPS_TEXTURESYSTEMMEMORY     = $00000100; (* Device can texture from system memory *)
  1836.   D3DDEVCAPS_TEXTUREVIDEOMEMORY      = $00000200; (* Device can texture from device memory *)
  1837.   D3DDEVCAPS_DRAWPRIMTLVERTEX        = $00000400; (* Device can draw TLVERTEX primitives *)
  1838.   D3DDEVCAPS_CANRENDERAFTERFLIP      = $00000800; (* Device can render without waiting for flip to complete *)
  1839.   D3DDEVCAPS_TEXTURENONLOCALVIDMEM   = $00001000; (* Device can texture from nonlocal video memory *)
  1840.   D3DDEVCAPS_DRAWPRIMITIVES2         = $00002000; (* Device can support DrawPrimitives2 *)
  1841.   D3DDEVCAPS_SEPARATETEXTUREMEMORIES = $00004000; (* Device is texturing from separate memory pools *)
  1842.   D3DDEVCAPS_DRAWPRIMITIVES2EX       = $00008000; (* Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver*)
  1843.   D3DDEVCAPS_HWTRANSFORMANDLIGHT     = $00010000; (* Device can support transformation and lighting in hardware and DRAWPRIMITIVES2EX must be also *)
  1844.   D3DDEVCAPS_CANBLTSYSTONONLOCAL     = $00020000; (* Device supports a Tex Blt from system memory to non-local vidmem *)
  1845.   D3DDEVCAPS_HWRASTERIZATION         = $00080000; (* Device has HW acceleration for rasterization *)
  1846.   D3DDEVCAPS_PUREDEVICE              = $00100000; (* Device supports D3DCREATE_PUREDEVICE *)
  1847.   D3DDEVCAPS_QUINTICRTPATCHES        = $00200000; (* Device supports quintic Beziers and BSplines *)
  1848.   D3DDEVCAPS_RTPATCHES               = $00400000; (* Device supports Rect and Tri patches *)
  1849.   D3DDEVCAPS_RTPATCHHANDLEZERO       = $00800000; (* Indicates that RT Patches may be drawn efficiently using handle 0 *)
  1850.   D3DDEVCAPS_NPATCHES                = $01000000; (* Device supports N-Patches *)
  1851.  
  1852. //
  1853. // PrimitiveMiscCaps
  1854. //                                   
  1855.   D3DPMISCCAPS_MASKZ                 = $00000002;
  1856.   D3DPMISCCAPS_LINEPATTERNREP        = $00000004;
  1857.   D3DPMISCCAPS_CULLNONE              = $00000010;
  1858.   D3DPMISCCAPS_CULLCW                = $00000020;
  1859.   D3DPMISCCAPS_CULLCCW               = $00000040;
  1860.   D3DPMISCCAPS_COLORWRITEENABLE      = $00000080;
  1861.   D3DPMISCCAPS_CLIPPLANESCALEDPOINTS = $00000100; (* Device correctly clips scaled points to clip planes *)
  1862.   D3DPMISCCAPS_CLIPTLVERTS           = $00000200; (* device will clip post-transformed vertex primitives *)
  1863.   D3DPMISCCAPS_TSSARGTEMP            = $00000400; (* device supports D3DTA_TEMP for temporary register *)
  1864.   D3DPMISCCAPS_BLENDOP               = $00000800; (* device supports D3DRS_BLENDOP *)
  1865.  
  1866. //
  1867. // LineCaps
  1868. //
  1869.   D3DLINECAPS_TEXTURE             = $00000001;
  1870.   D3DLINECAPS_ZTEST               = $00000002;
  1871.   D3DLINECAPS_BLEND               = $00000004;
  1872.   D3DLINECAPS_ALPHACMP            = $00000008;
  1873.   D3DLINECAPS_FOG                 = $00000010;
  1874.  
  1875. //
  1876. // RasterCaps
  1877. //                                      
  1878.   D3DPRASTERCAPS_DITHER                 = $00000001;
  1879.   D3DPRASTERCAPS_PAT                    = $00000008;
  1880.   D3DPRASTERCAPS_ZTEST                  = $00000010;
  1881.   D3DPRASTERCAPS_FOGVERTEX              = $00000080;
  1882.   D3DPRASTERCAPS_FOGTABLE               = $00000100;
  1883.   D3DPRASTERCAPS_ANTIALIASEDGES         = $00001000;
  1884.   D3DPRASTERCAPS_MIPMAPLODBIAS          = $00002000;
  1885.   D3DPRASTERCAPS_ZBIAS                  = $00004000;
  1886.   D3DPRASTERCAPS_ZBUFFERLESSHSR         = $00008000;
  1887.   D3DPRASTERCAPS_FOGRANGE               = $00010000;
  1888.   D3DPRASTERCAPS_ANISOTROPY             = $00020000;
  1889.   D3DPRASTERCAPS_WBUFFER                = $00040000;
  1890.   D3DPRASTERCAPS_WFOG                   = $00100000;
  1891.   D3DPRASTERCAPS_ZFOG                   = $00200000;
  1892.   D3DPRASTERCAPS_COLORPERSPECTIVE       = $00400000; (* Device iterates colors perspective correct *)
  1893.   D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE  = $00800000;
  1894.  
  1895. //
  1896. // ZCmpCaps, AlphaCmpCaps
  1897. //
  1898.   D3DPCMPCAPS_NEVER               = $00000001;
  1899.   D3DPCMPCAPS_LESS                = $00000002;
  1900.   D3DPCMPCAPS_EQUAL               = $00000004;
  1901.   D3DPCMPCAPS_LESSEQUAL           = $00000008;
  1902.   D3DPCMPCAPS_GREATER             = $00000010;
  1903.   D3DPCMPCAPS_NOTEQUAL            = $00000020;
  1904.   D3DPCMPCAPS_GREATEREQUAL        = $00000040;
  1905.   D3DPCMPCAPS_ALWAYS              = $00000080;
  1906.  
  1907. //
  1908. // SourceBlendCaps, DestBlendCaps
  1909. //
  1910.   D3DPBLENDCAPS_ZERO              = $00000001;
  1911.   D3DPBLENDCAPS_ONE               = $00000002;
  1912.   D3DPBLENDCAPS_SRCCOLOR          = $00000004;
  1913.   D3DPBLENDCAPS_INVSRCCOLOR       = $00000008;
  1914.   D3DPBLENDCAPS_SRCALPHA          = $00000010;
  1915.   D3DPBLENDCAPS_INVSRCALPHA       = $00000020;
  1916.   D3DPBLENDCAPS_DESTALPHA         = $00000040;
  1917.   D3DPBLENDCAPS_INVDESTALPHA      = $00000080;
  1918.   D3DPBLENDCAPS_DESTCOLOR         = $00000100;
  1919.   D3DPBLENDCAPS_INVDESTCOLOR      = $00000200;
  1920.   D3DPBLENDCAPS_SRCALPHASAT       = $00000400;
  1921.   D3DPBLENDCAPS_BOTHSRCALPHA      = $00000800;
  1922.   D3DPBLENDCAPS_BOTHINVSRCALPHA   = $00001000;
  1923.  
  1924. //
  1925. // ShadeCaps
  1926. //
  1927.   D3DPSHADECAPS_COLORGOURAUDRGB       = $00000008;
  1928.   D3DPSHADECAPS_SPECULARGOURAUDRGB    = $00000200;
  1929.   D3DPSHADECAPS_ALPHAGOURAUDBLEND     = $00004000;
  1930.   D3DPSHADECAPS_FOGGOURAUD            = $00080000;
  1931.  
  1932. //
  1933. // TextureCaps
  1934. //                                         
  1935.   D3DPTEXTURECAPS_PERSPECTIVE              = $00000001; (* Perspective-correct texturing is supported *)
  1936.   D3DPTEXTURECAPS_POW2                     = $00000002; (* Power-of-2 texture dimensions are required - applies to non-Cube/Volume textures only. *)
  1937.   D3DPTEXTURECAPS_ALPHA                    = $00000004; (* Alpha in texture pixels is supported *)
  1938.   D3DPTEXTURECAPS_SQUAREONLY               = $00000020; (* Only square textures are supported *)
  1939.   D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE = $00000040; (* Texture indices are not scaled by the texture size prior to interpolation *)
  1940.   D3DPTEXTURECAPS_ALPHAPALETTE             = $00000080; (* Device can draw alpha from texture palettes *)
  1941. // Device can use non-POW2 textures if:
  1942. //  1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage
  1943. //  2) D3DRS_WRAP(N) is zero for this texture's coordinates
  1944. //  3) mip mapping is not enabled (use magnification filter only)
  1945.   D3DPTEXTURECAPS_NONPOW2CONDITIONAL       = $00000100;
  1946.   D3DPTEXTURECAPS_PROJECTED                = $00000400; (* Device can do D3DTTFF_PROJECTED *)
  1947.   D3DPTEXTURECAPS_CUBEMAP                  = $00000800; (* Device can do cubemap textures *)
  1948.   D3DPTEXTURECAPS_VOLUMEMAP                = $00002000; (* Device can do volume textures *)
  1949.   D3DPTEXTURECAPS_MIPMAP                   = $00004000; (* Device can do mipmapped textures *)
  1950.   D3DPTEXTURECAPS_MIPVOLUMEMAP             = $00008000; (* Device can do mipmapped volume textures *)
  1951.   D3DPTEXTURECAPS_MIPCUBEMAP               = $00010000; (* Device can do mipmapped cube maps *)
  1952.   D3DPTEXTURECAPS_CUBEMAP_POW2             = $00020000; (* Device requires that cubemaps be power-of-2 dimension *)
  1953.   D3DPTEXTURECAPS_VOLUMEMAP_POW2           = $00040000; (* Device requires that volume maps be power-of-2 dimension *)
  1954.  
  1955. //
  1956. // TextureFilterCaps
  1957. //
  1958.   D3DPTFILTERCAPS_MINFPOINT           = $00000100; (* Min Filter *)
  1959.   D3DPTFILTERCAPS_MINFLINEAR          = $00000200;
  1960.   D3DPTFILTERCAPS_MINFANISOTROPIC     = $00000400;
  1961.   D3DPTFILTERCAPS_MIPFPOINT           = $00010000; (* Mip Filter *)
  1962.   D3DPTFILTERCAPS_MIPFLINEAR          = $00020000;
  1963.   D3DPTFILTERCAPS_MAGFPOINT           = $01000000; (* Mag Filter *)
  1964.   D3DPTFILTERCAPS_MAGFLINEAR          = $02000000;
  1965.   D3DPTFILTERCAPS_MAGFANISOTROPIC     = $04000000;
  1966.   D3DPTFILTERCAPS_MAGFAFLATCUBIC      = $08000000;
  1967.   D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC   = $10000000;
  1968.  
  1969. //
  1970. // TextureAddressCaps
  1971. //
  1972.   D3DPTADDRESSCAPS_WRAP           = $00000001;
  1973.   D3DPTADDRESSCAPS_MIRROR         = $00000002;
  1974.   D3DPTADDRESSCAPS_CLAMP          = $00000004;
  1975.   D3DPTADDRESSCAPS_BORDER         = $00000008;
  1976.   D3DPTADDRESSCAPS_INDEPENDENTUV  = $00000010;
  1977.   D3DPTADDRESSCAPS_MIRRORONCE     = $00000020;
  1978.  
  1979. //
  1980. // StencilCaps
  1981. //
  1982.   D3DSTENCILCAPS_KEEP             = $00000001;
  1983.   D3DSTENCILCAPS_ZERO             = $00000002;
  1984.   D3DSTENCILCAPS_REPLACE          = $00000004;
  1985.   D3DSTENCILCAPS_INCRSAT          = $00000008;
  1986.   D3DSTENCILCAPS_DECRSAT          = $00000010;
  1987.   D3DSTENCILCAPS_INVERT           = $00000020;
  1988.   D3DSTENCILCAPS_INCR             = $00000040;
  1989.   D3DSTENCILCAPS_DECR             = $00000080;
  1990.  
  1991. //
  1992. // TextureOpCaps
  1993. //
  1994.   D3DTEXOPCAPS_DISABLE                    = $00000001;
  1995.   D3DTEXOPCAPS_SELECTARG1                 = $00000002;
  1996.   D3DTEXOPCAPS_SELECTARG2                 = $00000004;
  1997.   D3DTEXOPCAPS_MODULATE                   = $00000008;
  1998.   D3DTEXOPCAPS_MODULATE2X                 = $00000010;
  1999.   D3DTEXOPCAPS_MODULATE4X                 = $00000020;
  2000.   D3DTEXOPCAPS_ADD                        = $00000040;
  2001.   D3DTEXOPCAPS_ADDSIGNED                  = $00000080;
  2002.   D3DTEXOPCAPS_ADDSIGNED2X                = $00000100;
  2003.   D3DTEXOPCAPS_SUBTRACT                   = $00000200;
  2004.   D3DTEXOPCAPS_ADDSMOOTH                  = $00000400;
  2005.   D3DTEXOPCAPS_BLENDDIFFUSEALPHA          = $00000800;
  2006.   D3DTEXOPCAPS_BLENDTEXTUREALPHA          = $00001000;
  2007.   D3DTEXOPCAPS_BLENDFACTORALPHA           = $00002000;
  2008.   D3DTEXOPCAPS_BLENDTEXTUREALPHAPM        = $00004000;
  2009.   D3DTEXOPCAPS_BLENDCURRENTALPHA          = $00008000;
  2010.   D3DTEXOPCAPS_PREMODULATE                = $00010000;
  2011.   D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR     = $00020000;
  2012.   D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA     = $00040000;
  2013.   D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR  = $00080000;
  2014.   D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA  = $00100000;
  2015.   D3DTEXOPCAPS_BUMPENVMAP                 = $00200000;
  2016.   D3DTEXOPCAPS_BUMPENVMAPLUMINANCE        = $00400000;
  2017.   D3DTEXOPCAPS_DOTPRODUCT3                = $00800000;
  2018.   D3DTEXOPCAPS_MULTIPLYADD                = $01000000;
  2019.   D3DTEXOPCAPS_LERP                       = $02000000;
  2020.  
  2021. //
  2022. // FVFCaps
  2023. //
  2024.   D3DFVFCAPS_TEXCOORDCOUNTMASK    = $0000ffff; (* mask for texture coordinate count field *)
  2025.   D3DFVFCAPS_DONOTSTRIPELEMENTS   = $00080000; (* Device prefers that vertex elements not be stripped *)
  2026.   D3DFVFCAPS_PSIZE                = $00100000; (* Device can receive point size *)
  2027.  
  2028. //
  2029. // VertexProcessingCaps
  2030. //
  2031.   D3DVTXPCAPS_TEXGEN              = $00000001; (* device can do texgen *)
  2032.   D3DVTXPCAPS_MATERIALSOURCE7     = $00000002; (* device can do DX7-level colormaterialsource ops *)
  2033.   D3DVTXPCAPS_DIRECTIONALLIGHTS   = $00000008; (* device can do directional lights *)
  2034.   D3DVTXPCAPS_POSITIONALLIGHTS    = $00000010; (* device can do positional lights (includes point and spot) *)
  2035.   D3DVTXPCAPS_LOCALVIEWER         = $00000020; (* device can do local viewer *)
  2036.   D3DVTXPCAPS_TWEENING            = $00000040; (* device can do vertex tweening *)
  2037.   D3DVTXPCAPS_NO_VSDT_UBYTE4      = $00000080; (* device does not support D3DVSDT_UBYTE4 *)
  2038.  
  2039.  
  2040.  
  2041. (*==========================================================================;
  2042.  *
  2043.  *
  2044.  *  File:   d3d8.h
  2045.  *  Content:    Direct3D include file
  2046.  *
  2047.  ****************************************************************************)
  2048.  
  2049. (* This identifier is passed to Direct3DCreate8 in order to ensure that an
  2050.  * application was built against the correct header files. This number is
  2051.  * incremented whenever a header (or other) change would require applications
  2052.  * to be rebuilt. If the version doesn't match, Direct3DCreate8 will fail.
  2053.  * (The number itself has no meaning.)*)
  2054.  
  2055. const
  2056.   D3D_SDK_VERSION = 120;
  2057.  
  2058. type
  2059.   HMonitor = THandle;
  2060.  
  2061. const
  2062.   IID_IDirect3D8              : TGUID = '{1DD9E8DA-1C77-4d40-B0CF-98FEFDFF9512}';
  2063.   IID_IDirect3DDevice8        : TGUID = '{7385E5DF-8FE8-41D5-86B6-D7B48547B6CF}';
  2064.   IID_IDirect3DResource8      : TGUID = '{1B36BB7B-09B7-410a-B445-7D1430D7B33F}';
  2065.   IID_IDirect3DBaseTexture8   : TGUID = '{B4211CFA-51B9-4a9f-AB78-DB99B2BB678E}';
  2066.   IID_IDirect3DTexture8       : TGUID = '{E4CDD575-2866-4f01-B12E-7EECE1EC9358}';
  2067.   IID_IDirect3DCubeTexture8   : TGUID = '{3EE5B968-2ACA-4c34-8BB5-7E0C3D19B750}';
  2068.   IID_IDirect3DVolumeTexture8 : TGUID = '{4B8AAAFA-140F-42ba-9131-597EAFAA2EAD}';
  2069.   IID_IDirect3DVertexBuffer8  : TGUID = '{8AEEEAC7-05F9-44d4-B591-000B0DF1CB95}';
  2070.   IID_IDirect3DIndexBuffer8   : TGUID = '{0E689C9A-053D-44a0-9D92-DB0E3D750F86}';
  2071.   IID_IDirect3DSurface8       : TGUID = '{B96EEBCA-B326-4ea5-882F-2FF5BAE021DD}';
  2072.   IID_IDirect3DVolume8        : TGUID = '{BD7349F5-14F1-42e4-9C79-972380DB40C0}';
  2073.   IID_IDirect3DSwapChain8     : TGUID = '{928C088B-76B9-4C6B-A536-A590853876CD}';
  2074.  
  2075. (*
  2076.  * Direct3D interfaces
  2077.  *)
  2078.  
  2079. type
  2080.   IDirect3D8              = interface;
  2081.   IDirect3DDevice8        = interface;
  2082.  
  2083.   IDirect3DResource8      = interface;
  2084.   IDirect3DBaseTexture8   = interface;
  2085.   IDirect3DTexture8       = interface;
  2086.   IDirect3DVolumeTexture8 = interface;
  2087.   IDirect3DCubeTexture8   = interface;
  2088.  
  2089.   IDirect3DVertexBuffer8  = interface;
  2090.   IDirect3DIndexBuffer8   = interface;
  2091.  
  2092.   IDirect3DSurface8       = interface;
  2093.   IDirect3DVolume8        = interface;
  2094.  
  2095.   IDirect3DSwapChain8     = interface;
  2096.  
  2097.  
  2098.   IDirect3D8 = interface (IUnknown)
  2099.     ['{1DD9E8DA-1C77-4d40-B0CF-98FEFDFF9512}']
  2100.     (*** IDirect3D8 methods ***)
  2101.     function RegisterSoftwareDevice(pInitializeFunction : Pointer) : HResult; stdcall;
  2102.     function GetAdapterCount : Cardinal; stdcall;
  2103.     function GetAdapterIdentifier(const Adapter : Cardinal; const Flags : LongWord; out pIdentifier : TD3DAdapter_Identifier8) : HResult; stdcall;
  2104.     function GetAdapterModeCount(Adapter : Cardinal) : Cardinal; stdcall;
  2105.     function EnumAdapterModes(const Adapter, Mode : Cardinal; var pMode : TD3DDisplayMode) : HResult; stdcall;
  2106.     function GetAdapterDisplayMode(const Adapter : Cardinal; var pMode : TD3DDisplayMode) : HResult; stdcall;
  2107.     function CheckDeviceType(const Adapter : Cardinal; const CheckType : TD3DDevType; const DisplayFormat, BackBufferFormat : TD3DFormat; const Windowed : BOOL) : HResult; stdcall;
  2108.     function CheckDeviceFormat(const Adapter : Cardinal; const DeviceType : TD3DDevType; const AdapterFormat : TD3DFormat; const Usage : LongWord; const RType : TD3DResourceType; const CheckFormat : TD3DFormat) : HResult; stdcall;
  2109.     function CheckDeviceMultiSampleType(const Adapter : Cardinal; const DeviceType : TD3DDevType; const SurfaceFormat : TD3DFormat; const Windowed : BOOL; const MultiSampleType : TD3DMultiSample_Type) : HResult; stdcall;
  2110.     function CheckDepthStencilMatch(const Adapter : Cardinal; const DeviceType : TD3DDevType; const AdapterFormat, RenderTargetFormat, DepthStencilFormat : TD3DFormat) : HResult; stdcall;
  2111.     function GetDeviceCaps(const Adapter : Cardinal; const DeviceType : TD3DDevType; out pCaps : TD3DCaps8) : HResult; stdcall;
  2112.     function GetAdapterMonitor(const Adapter : Cardinal) : HMONITOR; stdcall;
  2113.     function CreateDevice(const Adapter : Cardinal; const DeviceType : TD3DDevType; hFocusWindow : HWND; BehaviorFlags : LongWord; var pPresentationParameters : TD3DPresent_Parameters; out ppReturnedDeviceInterface : IDirect3DDevice8) : HResult; stdcall;
  2114.   end;
  2115.  
  2116.   IDirect3DDevice8 = interface (IUnknown)
  2117.     ['{7385E5DF-8FE8-41D5-86B6-D7B48547B6CF}']
  2118.      (*** IDirect3DDevice8 methods ***)
  2119.     function TestCooperativeLevel : HResult; stdcall;
  2120.     function GetAvailableTextureMem : Cardinal; stdcall;
  2121.     function ResourceManagerDiscardBytes(const Bytes : LongWord) : HResult; stdcall;
  2122.     function GetDirect3D(out ppD3D8 : IDirect3D8) : HResult; stdcall;
  2123.     function GetDeviceCaps(out pCaps : TD3DCaps8) : HResult; stdcall;
  2124.     function GetDisplayMode(out pMode : TD3DDisplayMode) : HResult; stdcall;
  2125.     function GetCreationParameters(out pParameters : TD3DDevice_Creation_Parameters) : HResult; stdcall;
  2126.     function SetCursorProperties(const XHotSpot, YHotSpot : Cardinal; const pCursorBitmap : IDirect3DSurface8) : HResult; stdcall;
  2127.     procedure SetCursorPosition(const XScreenSpace, YScreenSpace : Cardinal; const Flags : LongWord); stdcall;
  2128.     function ShowCursor(const bShow : BOOL) : BOOL; stdcall;
  2129.     function CreateAdditionalSwapChain(var pPresentationParameters : TD3DPresent_Parameters; out pSwapChain : IDirect3DSwapChain8) : HResult; stdcall;
  2130.     function Reset(var pPresentationParameters : TD3DPresent_Parameters) : HResult; stdcall;
  2131.     function Present(pSourceRect, pDestRect : PRect; const hDestWindowOverride : HWND; pDirtyRegion : PRgnData) : HResult; stdcall;
  2132.     function GetBackBuffer(const BackBuffer : Cardinal; const _Type : TD3DBackBuffer_Type; out ppBackBuffer : IDirect3DSurface8) : HResult; stdcall;
  2133.     function GetRasterStatus(out pRasterStatus : TD3DRaster_Status) : HResult; stdcall;
  2134.     procedure SetGammaRamp(Flags : LongWord; var pRamp : TD3DGammaRamp); stdcall;
  2135.     procedure GetGammaRamp(out pRamp : TD3DGammaRamp); stdcall;
  2136.     function CreateTexture(const Width, Height, Levels : Cardinal; const Usage : LongWord; const Format : TD3DFormat; const Pool : TD3DPool; out ppTexture : IDirect3DTexture8) : HResult; stdcall;
  2137.     function CreateVolumeTexture(const Width, Height, Depth, Levels : Cardinal; const Usage : LongWord; const Format : TD3DFormat; const Pool : TD3DPool; out ppVolumeTexture : IDirect3DVolumeTexture8) : HResult; stdcall;
  2138.     function CreateCubeTexture(const EdgeLength, Levels : Cardinal; const Usage : LongWord; const Format : TD3DFormat; const Pool : TD3DPool; out ppCubeTexture : IDirect3DCubeTexture8) : HResult; stdcall;
  2139.     function CreateVertexBuffer(const Length : Cardinal; const Usage, FVF : LongWord; const Pool : TD3DPool; out ppVertexBuffer : IDirect3DVertexBuffer8) : HResult; stdcall;
  2140.     function CreateIndexBuffer(const Length : Cardinal; Usage : LongWord; const Format : TD3DFormat; Pool : TD3DPool; out ppIndexBuffer : IDirect3DIndexBuffer8) : HResult; stdcall;
  2141.     function CreateRenderTarget(const Width, Height : Cardinal; const Format : TD3DFormat; const MultiSample : TD3DMultiSample_Type; const Lockable : BOOL; out ppSurface : IDirect3DSurface8) : HResult; stdcall;
  2142.     function CreateDepthStencilSurface(const Width, Height : Cardinal; const Format : TD3DFormat; const MultiSample : TD3DMultiSample_Type; out ppSurface : IDirect3DSurface8) : HResult; stdcall;
  2143.     function CreateImageSurface(const Width, Height : Cardinal; const Format : TD3DFormat; out ppSurface : IDirect3DSurface8) : HResult; stdcall;
  2144.     function CopyRects(const pSourceSurface : IDirect3DSurface8; pSourceRectsArray : PRect; const cRects : Cardinal; var pDestinationSurface : IDirect3DSurface8; pDestPointsArray : PPoint) : HResult; stdcall;
  2145.     function UpdateTexture(pSourceTexture, pDestinationTexture : IDirect3DBaseTexture8) : HResult; stdcall;
  2146.     function GetFrontBuffer(pDestSurface : IDirect3DSurface8) : HResult; stdcall;
  2147.     function SetRenderTarget(pRenderTarget, pNewZStencil : IDirect3DSurface8) : HResult; stdcall;
  2148.     function GetRenderTarget(out ppRenderTarget : IDirect3DSurface8) : HResult; stdcall;
  2149.     function GetDepthStencilSurface(out ppZStencilSurface : IDirect3DSurface8) : HResult; stdcall;
  2150.     function BeginScene : HResult; stdcall;
  2151.     function EndScene : HResult; stdcall;
  2152.     function Clear(const Count : LongWord; pRects : PD3DRect; const Flags : LongWord; const Color : TD3DColor; const Z : Single; const Stencil : LongWord) : HResult; stdcall;
  2153.     function SetTransform(const State : TD3DTransformStateType; const pMatrix : TD3DMatrix) : HResult; stdcall;
  2154.     function GetTransform(const State : TD3DTransformStateType; out pMatrix : TD3DMatrix) : HResult; stdcall;
  2155.     function MultiplyTransform(const State : TD3DTransformStateType; const pMatrix : TD3DMatrix) : HResult; stdcall;
  2156.     function SetViewport(var pViewport : TD3DViewport8) : HResult; stdcall;
  2157.     function GetViewport(out pViewport : TD3DViewport8) : HResult; stdcall;
  2158.     function SetMaterial(var pMaterial : TD3DMaterial8) : HResult; stdcall;
  2159.     function GetMaterial(out pMaterial : TD3DMaterial8) : HResult; stdcall;
  2160.     function SetLight(const Index : LongWord; var pLight : TD3DLight8) : HResult; stdcall;
  2161.     function GetLight(const Index : LongWord; out pLight : TD3DLight8) : HResult; stdcall;
  2162.     function LightEnable(const Index : LongWord; const Enable : BOOL) : HResult; stdcall;
  2163.     function GetLightEnable(const Index : LongWord; out pEnable : BOOL) : HResult; stdcall;
  2164.     function SetClipPlane(const Index : LongWord; pPlane : PSingle) : HResult; stdcall;
  2165.     function GetClipPlane(const Index : LongWord; out pPlane : Single) : HResult; stdcall;
  2166.     function SetRenderState(const State : TD3DRenderStateType; const Value : LongWord) : HResult; stdcall;
  2167.     function GetRenderState(const State : TD3DRenderStateType; out pValue : LongWord) : HResult; stdcall;
  2168.     function BeginStateBlock : HResult; stdcall;
  2169.     function EndStateBlock(out pToken : LongWord) : HResult; stdcall;
  2170.     function ApplyStateBlock(const Token : LongWord) : HResult; stdcall;
  2171.     function CaptureStateBlock(const Token : LongWord) : HResult; stdcall;
  2172.     function DeleteStateBlock(const Token : LongWord) : HResult; stdcall;
  2173.     function CreateStateBlock(const _Type : TD3DStateBlockType; out Token : LongWord) : HResult; stdcall;
  2174.     function SetClipStatus(var pClipStatus : TD3DClipStatus8) : HResult; stdcall;
  2175.     function GetClipStatus(out pClipStatus : TD3DClipStatus8) : HResult; stdcall;
  2176.     function GetTexture(const Stage : LongWord; out ppTexture : IDirect3DBaseTexture8) : HResult; stdcall;
  2177.     function SetTexture(const Stage : LongWord; pTexture : IDirect3DBaseTexture8) : HResult; stdcall;
  2178.     function GetTextureStageState(const Stage : LongWord; const _Type : TD3DTextureStageStateType; out pValue : LongWord) : HResult; stdcall;
  2179.     function SetTextureStageState(const Stage : LongWord; const _Type : TD3DTextureStageStateType; const Value : LongWord) : HResult; stdcall;
  2180.     function ValidateDevice(out pNumPasses : LongWord) : HResult; stdcall;
  2181.     function GetInfo(const DevInfoID : LongWord; pDevInfoStruct : Pointer; const DevInfoStructSize : LongWord) : HResult; stdcall;
  2182.     function SetPaletteEntries(const PaletteNumber : Cardinal; var pEntries : TPaletteEntry) : HResult; stdcall;
  2183.     function GetPaletteEntries(const PaletteNumber : Cardinal; out pEntries : TPaletteEntry) : HResult; stdcall;
  2184.     function SetCurrentTexturePalette(const PaletteNumber : Cardinal) : HResult; stdcall;
  2185.     function GetCurrentTexturePalette(out PaletteNumber : Cardinal) : HResult; stdcall;
  2186.     function DrawPrimitive(const PrimitiveType : TD3DPrimitiveType; const StartVertex, PrimitiveCount : Cardinal) : HResult; stdcall;
  2187.     function DrawIndexedPrimitive(const _Type : TD3DPrimitiveType; const minIndex, NumVertices, startIndex, primCount : Cardinal) : HResult; stdcall;
  2188.     function DrawPrimitiveUP(const PrimitiveType : TD3DPrimitiveType; const PrimitiveCount : Cardinal; pVertexStreamZeroData : Pointer; const VertexStreamZeroStride : Cardinal) : HResult; stdcall;
  2189.     function DrawIndexedPrimitiveUP(const PrimitiveType : TD3DPrimitiveType; const MinVertexIndex, NumVertexIndices, PrimitiveCount : Cardinal; pIndexData : Pointer; IndexDataFormat : TD3DFormat; pVertexStreamZeroData : Pointer; const VertexStreamZeroStride : Cardinal) : HResult; stdcall;
  2190.     function ProcessVertices(const SrcStartIndex, DestIndex, VertexCount : Cardinal; pDestBuffer : IDirect3DVertexBuffer8; const Flags : LongWord) : HResult; stdcall;
  2191. //    function CreateVertexShader(var pDeclaration, pFunction : LongWord; var pHandle : LongWord; const Usage : LongWord) : HResult; stdcall;
  2192.     function CreateVertexShader(var pDeclaration : LongWord; pFunction : PLongWord; var pHandle : LongWord; const Usage : LongWord) : HResult; stdcall;
  2193.     function SetVertexShader(const Handle : LongWord) : HResult; stdcall;
  2194.     function GetVertexShader(out pHandle : LongWord) : HResult; stdcall;
  2195.     function DeleteVertexShader(const Handle : LongWord) : HResult; stdcall;
  2196.     function SetVertexShaderConstant(const _Register : LongWord; {const} pConstantData : Pointer; const ConstantCount : LongWord) : HResult; stdcall;
  2197.     function GetVertexShaderConstant(const _Register : LongWord; {out} pConstantData : Pointer; const ConstantCount : LongWord) : HResult; stdcall;
  2198.     function GetVertexShaderDeclaration(const Handle : LongWord; {const} pData : Pointer; var pSizeOfData : LongWord) : HResult; stdcall;
  2199.     function GetVertexShaderFunction(const Handle : LongWord; {out} pData : Pointer; var pSizeOfData : LongWord) : HResult; stdcall;
  2200.     function SetStreamSource(const StreamNumber : Cardinal; const pStreamData : IDirect3DVertexBuffer8; const Stride : Cardinal) : HResult; stdcall;
  2201.     function GetStreamSource(const StreamNumber : Cardinal; out ppStreamData : IDirect3DVertexBuffer8; var pStride : Cardinal) : HResult; stdcall;
  2202.     function SetIndices(const pIndexData : IDirect3DIndexBuffer8; const BaseVertexIndex : Cardinal) : HResult; stdcall;
  2203.     function GetIndices(out ppIndexData : IDirect3DIndexBuffer8; out pBaseVertexIndex : Cardinal) : HResult; stdcall;
  2204.     function CreatePixelShader(var pFunction : LongWord; out pHandle : LongWord) : HResult; stdcall;
  2205.     function SetPixelShader(const Handle : LongWord) : HResult; stdcall;
  2206.     function GetPixelShader(out Handle : LongWord) : HResult; stdcall;
  2207.     function DeletePixelShader(const Handle : LongWord) : HResult; stdcall;
  2208.     function SetPixelShaderConstant(const _Register : LongWord; {const} pConstantData : Pointer; const ConstantCount : LongWord) : HResult; stdcall;
  2209.     function GetPixelShaderConstant(const _Register : LongWord; {out} pConstantData : Pointer; const ConstantCount : LongWord) : HResult; stdcall;
  2210.     function GetPixelShaderFunction(const Handle : LongWord; pData : Pointer; var pSizeOfData : LongWord) : HResult; stdcall;
  2211.     function DrawRectPatch(const Handle : Cardinal; pNumSegs : PSingle; pRectPatchInfo : PD3DRectPatch_Info) : HResult; stdcall;
  2212.     function DrawTriPatch(const Handle : Cardinal; pNumSegs : PSingle; pTriPatchInfo : PD3DTriPatch_Info) : HResult; stdcall;
  2213.     function DeletePatch(const Handle : Cardinal) : HResult; stdcall;
  2214.   end;
  2215.  
  2216.   IDirect3DSwapChain8 = interface (IUnknown)
  2217.     ['{928C088B-76B9-4C6B-A536-A590853876CD}']
  2218.     (*** IDirect3DSwapChain8 methods ***)
  2219.     function Present(pSourceRect, pDestRect : PRect; const hDestWindowOverride : HWND; pDirtyRegion : PRgnData) : HResult; stdcall;
  2220.     function GetBackBuffer(const BackBuffer : Cardinal; const _Type : TD3DBackBuffer_Type; out ppBackBuffer : IDirect3DSurface8) : HResult; stdcall;
  2221.   end;
  2222.  
  2223.  
  2224.   IDirect3DResource8 = interface (IUnknown)
  2225.     ['{1B36BB7B-09B7-410a-B445-7D1430D7B33F}']
  2226.     (*** IDirect3DResource8 methods ***)
  2227.     function GetDevice(out ppDevice : IDirect3DDevice8) : HResult; stdcall;
  2228.     function SetPrivateData(const refguid : TGUID; {const} pData : Pointer; const SizeOfData, Flags : LongWord) : HResult; stdcall;
  2229.     function GetPrivateData(const refguid : TGUID; {out} pData : Pointer; out pSizeOfData : LongWord) : HResult; stdcall;
  2230.     function FreePrivateData(const refguid : TGUID) : HResult; stdcall;
  2231.     function SetPriority(const PriorityNew : LongWord) : LongWord; stdcall;
  2232.     function GetPriority : LongWord; stdcall;
  2233.     procedure PreLoad stdcall;
  2234.     function GetType : TD3DResourceType; stdcall;
  2235.   end;
  2236.  
  2237.   IDirect3DBaseTexture8 = interface (IDirect3DResource8)
  2238.     ['{B4211CFA-51B9-4a9f-AB78-DB99B2BB678E}']
  2239.     (*** IDirect3DBaseTexture8 methods ***)
  2240.     function SetLOD(const LODNew : LongWord) : LongWord; stdcall;
  2241.     function GetLOD : LongWord; stdcall;
  2242.     function GetLevelCount : LongWord; stdcall;
  2243.   end;
  2244.  
  2245.   IDirect3DTexture8 = interface (IDirect3DBaseTexture8)
  2246.     ['{E4CDD575-2866-4f01-B12E-7EECE1EC9358}']
  2247.     (*** IDirect3DTexture8 methods ***)
  2248.     function GetLevelDesc(const Level : Cardinal; out pDesc : TD3DSurface_Desc) : HResult; stdcall;
  2249.     function GetSurfaceLevel(const Level : Cardinal; out ppSurfaceLevel : IDirect3DSurface8) : HResult; stdcall;
  2250.     function LockRect(const Level : Cardinal; out pLockedRect : TD3DLocked_Rect; pRect : PRect; const Flags : LongWord) : HResult; stdcall;
  2251.     function UnlockRect(const Level : Cardinal) : HResult; stdcall;
  2252.     function AddDirtyRect(pDirtyRect : PRect) : HResult; stdcall;
  2253.   end;
  2254.  
  2255.   IDirect3DVolumeTexture8 = interface (IDirect3DBaseTexture8)
  2256.     ['{E4CDD575-2866-4f01-B12E-7EECE1EC9358}']
  2257.     (*** IDirect3DVolumeTexture8 methods ***)
  2258.     function GetLevelDesc(const Level : Cardinal; out pDesc : TD3DVolume_Desc) : HResult; stdcall;
  2259.     function GetVolumeLevel(const Level : Cardinal; out ppVolumeLevel : IDirect3DVolume8) : HResult; stdcall;
  2260.     function LockBox(const Level : Cardinal; out pLockedVolume : TD3DLocked_Box; pBox : PD3DBox; const Flags : LongWord) : HResult; stdcall;
  2261.     function UnlockBox(const Level : Cardinal) : HResult; stdcall;
  2262.     function AddDirtyBox(pDirtyBox : PD3DBox) : HResult; stdcall;
  2263.   end;
  2264.  
  2265.   IDirect3DCubeTexture8 = interface (IDirect3DBaseTexture8)
  2266.     ['{3EE5B968-2ACA-4c34-8BB5-7E0C3D19B750}']
  2267.     (*** IDirect3DCubeTexture8 methods ***)
  2268.     function GetLevelDesc(const Level : Cardinal; out pDesc : TD3DSurface_Desc) : HResult; stdcall;
  2269.     function GetCubeMapSurface(const FaceType : TD3DCubeMap_Faces; const Level : Cardinal; out ppCubeMapSurface : IDirect3DSurface8) : HResult; stdcall;
  2270.     function LockRect(const FaceType : TD3DCubeMap_Faces; const Level : Cardinal; out pLockedRect : TD3DLocked_Rect; pRect : PRect; const Flags : LongWord) : HResult; stdcall;
  2271.     function UnlockRect(const FaceType : TD3DCubeMap_Faces; const Level : Cardinal) : HResult; stdcall;
  2272.     function AddDirtyRect(const FaceType : TD3DCubeMap_Faces; pDirtyRect : PRect) : HResult; stdcall;
  2273.   end;
  2274.  
  2275.   IDirect3DVertexBuffer8 = interface (IDirect3DResource8)
  2276.     ['{8AEEEAC7-05F9-44d4-B591-000B0DF1CB95}']
  2277.     (*** IDirect3DVertexBuffer8 methods ***)
  2278.     function Lock(const OffsetToLock, SizeToLock : Cardinal; var ppbData : PByte; const Flags : LongWord) : HResult; stdcall;
  2279.     function Unlock : HResult; stdcall;
  2280.     function GetDesc(out pDesc : TD3DVertexBuffer_Desc) : HResult; stdcall;
  2281.   end;
  2282.  
  2283.   IDirect3DIndexBuffer8 = interface (IDirect3DResource8)
  2284.     ['{0E689C9A-053D-44a0-9D92-DB0E3D750F86}']
  2285.     (*** IDirect3DIndexBuffer8 methods ***)
  2286.     function Lock(const OffsetToLock, SizeToLock : LongWord; var ppbData : PByte; const Flags : LongWord) : HResult; stdcall;
  2287.     function Unlock : HResult; stdcall;
  2288.     function GetDesc(out pDesc : TD3DIndexBuffer_Desc) : HResult; stdcall;
  2289.   end;
  2290.  
  2291.  
  2292.  
  2293.   IDirect3DSurface8 = interface (IUnknown)
  2294.     ['{B96EEBCA-B326-4ea5-882F-2FF5BAE021DD}']
  2295.     (*** IDirect3DSurface8 methods ***)
  2296.     function GetDevice(out ppDevice : IDirect3DDevice8) : HResult; stdcall;
  2297.     function SetPrivateData(const refguid : TGUID; {const} pData : Pointer; const SizeOfData, Flags : LongWord) : HResult; stdcall;
  2298.     function GetPrivateData(const refguid : TGUID; {out} pData : Pointer; out pSizeOfData : LongWord) : HResult; stdcall;
  2299.     function FreePrivateData(const refguid : TGUID) : HResult; stdcall;
  2300.     function GetContainer(const riid : TGUID; var ppContainer : Pointer) : HResult; stdcall;
  2301.     function GetDesc(out pDesc : TD3DSurface_Desc) : HResult; stdcall;
  2302.     function LockRect(out pLockedRect : TD3DLocked_Rect; pRect : PRect; const Flags : LongWord) : HResult; stdcall;
  2303.     function UnlockRect : HResult; stdcall;
  2304.   end;
  2305.  
  2306.  
  2307.  
  2308.   IDirect3DVolume8 = interface (IUnknown)
  2309.     ['{BD7349F5-14F1-42e4-9C79-972380DB40C0}']
  2310.     (*** IDirect3DVolume8 methods ***)
  2311.     function GetDevice(out ppDevice : IDirect3DDevice8) : HResult; stdcall;
  2312.     function SetPrivateData(const refguid : TGUID; {const} pData : Pointer; const SizeOfData, Flags : LongWord) : HResult; stdcall;
  2313.     function GetPrivateData(const refguid : TGUID; {out} pData : Pointer; out pSizeOfData : LongWord) : HResult; stdcall;
  2314.     function FreePrivateData(const refguid : TGUID) : HResult; stdcall;
  2315.     function GetContainer(const riid : TGUID; var ppContainer : Pointer) : HResult; stdcall;
  2316.     function GetDesc(out pDesc : TD3DVolume_Desc) : HResult; stdcall;
  2317.     function LockBox(out pLockedVolume : TD3DLocked_Box; pBox : PD3DBox; const Flags : LongWord) : HResult; stdcall;
  2318.     function UnlockBox : HResult; stdcall;
  2319.   end;
  2320.  
  2321.  
  2322. (****************************************************************************
  2323.  * Flags for SetPrivateData method on all D3D8 interfaces
  2324.  *
  2325.  * The passed pointer is an IUnknown ptr. The SizeOfData argument to SetPrivateData
  2326.  * must be set to sizeof( IUnknown* ). Direct3D will call AddRef through this
  2327.  * pointer and Release when the private data is destroyed. The data will be
  2328.  * destroyed when another SetPrivateData with the same GUID is set, when
  2329.  * FreePrivateData is called, or when the D3D8 object is freed.
  2330.  ****************************************************************************)
  2331. const
  2332.   D3DSPD_IUNKNOWN                         = $00000001;
  2333.  
  2334. (****************************************************************************
  2335.  *
  2336.  * Parameter for IDirect3D8 Enum and GetCaps8 functions to get the info for
  2337.  * the current mode only.
  2338.  *
  2339.  ****************************************************************************)
  2340.  
  2341.   D3DCURRENT_DISPLAY_MODE                 = $00EFFFFF;
  2342.  
  2343. (****************************************************************************
  2344.  *
  2345.  * Flags for IDirect3D8::CreateDevice's BehaviorFlags
  2346.  *
  2347.  ****************************************************************************)
  2348.  
  2349.   D3DCREATE_FPU_PRESERVE                  = $00000002;
  2350.   D3DCREATE_MULTITHREADED                 = $00000004;
  2351.  
  2352.   D3DCREATE_PUREDEVICE                    = $00000010;
  2353.   D3DCREATE_SOFTWARE_VERTEXPROCESSING     = $00000020;
  2354.   D3DCREATE_HARDWARE_VERTEXPROCESSING     = $00000040;
  2355.   D3DCREATE_MIXED_VERTEXPROCESSING        = $00000080;
  2356.  
  2357.  
  2358. (****************************************************************************
  2359.  *
  2360.  * Parameter for IDirect3D8::CreateDevice's iAdapter
  2361.  *
  2362.  ****************************************************************************)
  2363.  
  2364.   D3DADAPTER_DEFAULT                      = 0;
  2365.  
  2366. (****************************************************************************
  2367.  *
  2368.  * Flags for IDirect3D8::EnumAdapters
  2369.  *
  2370.  ****************************************************************************)
  2371.  
  2372.   D3DENUM_NO_WHQL_LEVEL                   = $00000002;
  2373.  
  2374. (****************************************************************************
  2375.  *
  2376.  * Maximum number of back-buffers supported in DX8
  2377.  *
  2378.  ****************************************************************************)
  2379.  
  2380.   D3DPRESENT_BACK_BUFFERS_MAX             = 3;
  2381.  
  2382. (****************************************************************************
  2383.  *
  2384.  * Flags for IDirect3DDevice8::SetGammaRamp
  2385.  *
  2386.  ****************************************************************************)
  2387.  
  2388.   D3DSGR_NO_CALIBRATION                  = $00000000;
  2389.   D3DSGR_CALIBRATE                       = $00000001;
  2390.  
  2391. (****************************************************************************
  2392.  *
  2393.  * Flags for IDirect3DDevice8::SetCursorPosition
  2394.  *
  2395.  ****************************************************************************)
  2396.  
  2397.   D3DCURSOR_IMMEDIATE_UPDATE             = $00000001;
  2398.  
  2399. (****************************************************************************
  2400.  *
  2401.  * Flags for DrawPrimitive/DrawIndexedPrimitive
  2402.  *   Also valid for Begin/BeginIndexed
  2403.  *   Also valid for VertexBuffer::CreateVertexBuffer
  2404.  ****************************************************************************)
  2405.  
  2406.  
  2407. (*
  2408.  *  DirectDraw error codes
  2409.  *)
  2410.  
  2411. const
  2412.   _FACD3D = $876;
  2413.   MAKE_D3DHRESULT = (1 shl 31) or (_FACD3D shl 16);
  2414.  
  2415. (*
  2416.  * Direct3D Errors
  2417.  *)
  2418.   D3D_OK                                  = S_OK;
  2419.  
  2420.   D3DERR_WRONGTEXTUREFORMAT               = HResult(MAKE_D3DHRESULT + 2072);
  2421.   D3DERR_UNSUPPORTEDCOLOROPERATION        = HResult(MAKE_D3DHRESULT + 2073);
  2422.   D3DERR_UNSUPPORTEDCOLORARG              = HResult(MAKE_D3DHRESULT + 2074);
  2423.   D3DERR_UNSUPPORTEDALPHAOPERATION        = HResult(MAKE_D3DHRESULT + 2075);
  2424.   D3DERR_UNSUPPORTEDALPHAARG              = HResult(MAKE_D3DHRESULT + 2076);
  2425.   D3DERR_TOOMANYOPERATIONS                = HResult(MAKE_D3DHRESULT + 2077);
  2426.   D3DERR_CONFLICTINGTEXTUREFILTER         = HResult(MAKE_D3DHRESULT + 2078);
  2427.   D3DERR_UNSUPPORTEDFACTORVALUE           = HResult(MAKE_D3DHRESULT + 2079);
  2428.   D3DERR_CONFLICTINGRENDERSTATE           = HResult(MAKE_D3DHRESULT + 2081);
  2429.   D3DERR_UNSUPPORTEDTEXTUREFILTER         = HResult(MAKE_D3DHRESULT + 2082);
  2430.   D3DERR_CONFLICTINGTEXTUREPALETTE        = HResult(MAKE_D3DHRESULT + 2086);
  2431.   D3DERR_DRIVERINTERNALERROR              = HResult(MAKE_D3DHRESULT + 2087);
  2432.  
  2433.   D3DERR_NOTFOUND                         = HResult(MAKE_D3DHRESULT + 2150);
  2434.   D3DERR_MOREDATA                         = HResult(MAKE_D3DHRESULT + 2151);
  2435.   D3DERR_DEVICELOST                       = HResult(MAKE_D3DHRESULT + 2152);
  2436.   D3DERR_DEVICENOTRESET                   = HResult(MAKE_D3DHRESULT + 2153);
  2437.   D3DERR_NOTAVAILABLE                     = HResult(MAKE_D3DHRESULT + 2154);
  2438.   D3DERR_OUTOFVIDEOMEMORY                 = HResult(MAKE_D3DHRESULT + 380);
  2439.   D3DERR_INVALIDDEVICE                    = HResult(MAKE_D3DHRESULT + 2155);
  2440.   D3DERR_INVALIDCALL                      = HResult(MAKE_D3DHRESULT + 2156);
  2441.   D3DERR_DRIVERINVALIDCALL                = HResult(MAKE_D3DHRESULT + 2157);
  2442.  
  2443.  
  2444. (*
  2445.  * DLL Function for creating a Direct3D8 object. This object supports
  2446.  * enumeration and allows the creation of Direct3DDevice8 objects.
  2447.  * Pass the value of the constant D3D_SDK_VERSION to this function, so
  2448.  * that the run-time can validate that your application was compiled
  2449.  * against the right headers.
  2450.  *)
  2451.  
  2452. var
  2453.   _Direct3DCreate8 : function (SDKVersion : Cardinal) : Pointer; stdcall;
  2454.  
  2455. function DXGErrorString(Value: HResult) : string;
  2456.  
  2457. function Direct3DCreate8(SDKVersion : Cardinal) : IDirect3D8;
  2458.  
  2459. implementation
  2460.  
  2461. uses DXCommon;
  2462.  
  2463. function D3DCOLOR_ARGB(a, r, g, b : Cardinal) : TD3DColor;
  2464. begin
  2465.   Result := (a shl 24) or (r shl 16) or (g shl 8) or b;
  2466. end;
  2467.  
  2468. function D3DCOLOR_RGBA(r, g, b, a : Cardinal) : TD3DColor;
  2469. begin
  2470.   Result := D3DCOLOR_ARGB(a, r, g, b);
  2471. end;
  2472.  
  2473. function D3DCOLOR_XRGB(r, g, b : Cardinal) : TD3DColor;
  2474. begin
  2475.   Result := D3DCOLOR_ARGB($ff, r, g, b);
  2476. end;
  2477.  
  2478. function D3DCOLOR_COLORVALUE(r, g, b, a : Single) : TD3DColor;
  2479. begin
  2480.   Result := D3DCOLOR_RGBA(Byte(Round(r * 255)), Byte(Round(g * 255)), Byte(Round(b * 255)), Byte(Round(a * 255)))
  2481. end;
  2482.  
  2483. function D3DTS_WORLDMATRIX(index : LongWord) : LongWord;
  2484. begin
  2485.  Result := index + 256;
  2486. end;
  2487.  
  2488. function D3DVSD_MAKETOKENTYPE(tokenType : LongWord) : LongWord;
  2489. begin
  2490.   Result := (tokenType shl D3DVSD_TOKENTYPESHIFT) and D3DVSD_TOKENTYPEMASK;
  2491. end;
  2492.  
  2493. function D3DVSD_STREAM(_StreamNumber : LongWord) : LongWord;
  2494. begin
  2495.   Result := D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) or _StreamNumber;
  2496. end;
  2497.  
  2498. function D3DVSD_REG( _VertexRegister, _Type : LongWord) : LongWord;
  2499. begin
  2500.   Result := D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) or ((_Type shl D3DVSD_DATATYPESHIFT) or _VertexRegister)
  2501. end;
  2502.  
  2503. function D3DVSD_SKIP( _DWORDCount : LongWord) : LongWord;
  2504. begin
  2505.   Result := D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) or $10000000 or (_DWORDCount shl D3DVSD_SKIPCOUNTSHIFT)
  2506. end;
  2507.  
  2508. function D3DVSD_CONST( _ConstantAddress, _Count : LongWord)  : LongWord;
  2509. begin
  2510.   Result := D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_CONSTMEM) or (_Count shl D3DVSD_CONSTCOUNTSHIFT) or _ConstantAddress
  2511. end;
  2512.  
  2513. function D3DVSD_TESSNORMAL( _VertexRegisterIn, _VertexRegisterOut : LongWord) : LongWord;
  2514. begin
  2515.   Result := D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) or
  2516.             (_VertexRegisterIn shl D3DVSD_VERTEXREGINSHIFT) or
  2517.             ($02 shl D3DVSD_DATATYPESHIFT) or _VertexRegisterOut;
  2518. end;
  2519.  
  2520. function D3DVSD_TESSUV( _VertexRegister : LongWord) : LongWord;
  2521. begin
  2522.   Result := D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) or $10000000 or
  2523.             ($01 shl D3DVSD_DATATYPESHIFT) or _VertexRegister;
  2524. end;
  2525.  
  2526. function D3DPS_VERSION(_Major, _Minor : LongWord) : LongWord;
  2527. begin
  2528.   Result := $FFFF0000 or (_Major shl 8 ) or _Minor;
  2529. end;
  2530.  
  2531. function D3DVS_VERSION(_Major, _Minor : LongWord) : LongWord;
  2532. begin
  2533.   Result := $FFFE0000 or (_Major shl 8 ) or _Minor;
  2534. end;
  2535.  
  2536. function D3DSHADER_VERSION_MAJOR(_Version : LongWord) : LongWord;
  2537. begin
  2538.   Result := (_Version shr 8 ) and $FF;
  2539. end;
  2540.  
  2541. function D3DSHADER_VERSION_MINOR(_Version : LongWord) : LongWord;
  2542. begin
  2543.   Result := (_Version shr 0) and $FF;
  2544. end;
  2545.  
  2546. function  D3DSHADER_COMMENT(_DWordSize : LongWord)  : LongWord;
  2547. begin
  2548.   Result := ((_DWordSize shl D3DSI_COMMENTSIZE_SHIFT) and D3DSI_COMMENTSIZE_MASK) or D3DSIO_COMMENT;
  2549. end;
  2550.  
  2551. function D3DFVF_TEXCOORDSIZE3(CoordIndex : LongWord) : LongWord;
  2552. begin
  2553.   Result := D3DFVF_TEXTUREFORMAT3 shl (CoordIndex * 2 + 16)
  2554. end;
  2555.  
  2556. function D3DFVF_TEXCOORDSIZE2(CoordIndex : LongWord) : LongWord;
  2557. begin
  2558.   Result := D3DFVF_TEXTUREFORMAT2;
  2559. end;
  2560.  
  2561. function D3DFVF_TEXCOORDSIZE4(CoordIndex : LongWord) : LongWord;
  2562. begin
  2563.   Result := D3DFVF_TEXTUREFORMAT4 shl (CoordIndex * 2 + 16)
  2564. end;
  2565.  
  2566. function D3DFVF_TEXCOORDSIZE1(CoordIndex : LongWord) : LongWord;
  2567. begin
  2568.   Result := D3DFVF_TEXTUREFORMAT1 shl (CoordIndex * 2 + 16)
  2569. end;
  2570.  
  2571. function MAKEFOURCC(ch0, ch1, ch2, ch3 : Char) : LongWord;
  2572. begin
  2573.   Result := Byte(ch0) or (Byte(ch1) shl 8) or (Byte(ch2) shl 16) or (Byte(ch3) shl 24 );
  2574. end;
  2575.  
  2576. function DXGErrorString(Value: HResult) : string;
  2577. begin
  2578.   case Value of
  2579.  
  2580.     HResult(D3D_OK)                           : Result := 'No error occurred.';
  2581.     HResult(D3DERR_CONFLICTINGRENDERSTATE)    : Result := 'The currently set render states cannot be used together.';
  2582.     HResult(D3DERR_CONFLICTINGTEXTUREFILTER)  : Result := 'The current texture filters cannot be used together.';
  2583.     HResult(D3DERR_CONFLICTINGTEXTUREPALETTE) : Result := 'The current textures cannot be used simultaneously. This generally occurs when a multitexture device requires that all palletized textures simultaneously enabled also share the same palette.';
  2584.     HResult(D3DERR_DEVICELOST)                : Result := 'The device is lost and cannot be restored at the current time, so rendering is not possible.';
  2585.     HResult(D3DERR_DEVICENOTRESET)            : Result := 'The device cannot be reset.';
  2586.     HResult(D3DERR_DRIVERINTERNALERROR)       : Result := 'Internal driver error.';
  2587.     HResult(D3DERR_INVALIDCALL)               : Result := 'The method call is invalid. For example, a method''s parameter may have an invalid value.';
  2588.     HResult(D3DERR_INVALIDDEVICE)             : Result := 'The requested device type is not valid.';
  2589.     HResult(D3DERR_MOREDATA)                  : Result := 'There is more data available than the specified buffer size can hold.';
  2590.     HResult(D3DERR_NOTAVAILABLE)              : Result := 'This device does not support the queried technique.';
  2591.     HResult(D3DERR_NOTFOUND)                  : Result := 'The requested item was not found.';
  2592.     HResult(D3DERR_OUTOFVIDEOMEMORY)          : Result := 'Direct3D does not have enough display memory to perform the operation.';
  2593.     HResult(D3DERR_TOOMANYOPERATIONS)         : Result := 'The application is requesting more texture-filtering operations than the device';
  2594.     HResult(D3DERR_UNSUPPORTEDALPHAARG)       : Result := 'The device does not support a specified texture-blending argument for the alpha channel.';
  2595.     HResult(D3DERR_UNSUPPORTEDALPHAOPERATION) : Result := 'The device does not support a specified texture-blending operation for the alpha channel.';
  2596.     HResult(D3DERR_UNSUPPORTEDCOLORARG)       : Result := 'The device does not support a specified texture-blending argument for color values.';
  2597.     HResult(D3DERR_UNSUPPORTEDCOLOROPERATION) : Result := 'The device does not support a specified texture-blending operation for color values.';
  2598.     HResult(D3DERR_UNSUPPORTEDFACTORVALUE)    : Result := 'The device does not support the specified texture factor value.';
  2599.     HResult(D3DERR_UNSUPPORTEDTEXTUREFILTER)  : Result := 'The device does not support the specified texture filter.';
  2600.     HResult(D3DERR_WRONGTEXTUREFORMAT)        : Result := 'The pixel format of the texture surface is not valid.';
  2601.     HResult(E_FAIL)                           : Result := 'An undetermined error occurred inside the Direct3D subsystem.';
  2602.     HResult(E_INVALIDARG)                     : Result := 'An invalid parameter was passed to the returning function';
  2603. //    HResult(E_INVALIDCALL)                    : Result := 'The method call is invalid. For example, a method''s parameter may have an invalid value.';
  2604.     HResult(E_OUTOFMEMORY)                    : Result := 'Direct3D could not allocate sufficient memory to complete the call.';
  2605.  
  2606.     else Result := 'Unrecognized Error';
  2607.   end;
  2608. end;
  2609.  
  2610. function Direct3DCreate8(SDKVersion : Cardinal) : IDirect3D8;
  2611. begin
  2612.   Result := IDirect3D8(_Direct3DCreate8(SDKVersion));
  2613.   if Result <> nil then Result._Release;
  2614. end;
  2615.  
  2616. initialization
  2617. begin
  2618.   if not IsNTandDelphiRunning then
  2619.   begin
  2620.     D3D8DLL := LoadLibrary('D3d8.dll');
  2621.  
  2622.     if D3D8DLL <> 0 then _Direct3DCreate8 := GetProcAddress(D3D8DLL, 'Direct3DCreate8');
  2623.   end;
  2624. end;
  2625.  
  2626. finalization
  2627. begin
  2628.   FreeLibrary(D3D8DLL);
  2629. end;
  2630. end.
  2631.