📄 directxgraphics.pas
字号:
(*)
[------------------------------------------------------------------------------
[ DirectXGraphics 8[.1] Delphi Adaptation (c) by Tim Baumgarten
[------------------------------------------------------------------------------
[ Files : d3d8types.h
[ d3d8caps.h
[ d3d8.h
[ Modified : 10-Nov-2001
[ E-Mail : Ampaze@gmx.net
[ Download : http://www.crazyentertainment.net
[------------------------------------------------------------------------------
(*)
(*)
[------------------------------------------------------------------------------
[ History :
[----------
[ 10-Nov-2001 (Tim Baumgarten) : Added DX 8.1, and still testing,
[ Define DX8 to make it work with dx8 runtime.
[------------------------------------------------------------------------------
[ 05-Nov-2001 (Tim Baumgarten) : Changed the EnumTypes for D6, so you might
[ have to typecast to LongWord in some cases.
[------------------------------------------------------------------------------
[ 28-Jul-2001 (Tim Baumgarten) : Changed "var pDestinationSurface : IDirect3DSurface8" to
[ "const pDestinationSurface : IDirect3DSurface8" in
[ IDirect3DDevice8.CopyRects
[------------------------------------------------------------------------------
[ 14-Mar-2001 (Tim Baumgarten) : Changed CreateVertexShader as pFunction can
[ be nil.
[------------------------------------------------------------------------------
[ 28-Jan-2001 (Tim Baumgarten) : Added TD3DMultiSampleType = TD3DMultiSample_Type;
[------------------------------------------------------------------------------
[ 23-Dec-2000 (Tim Baumgarten) : Changed all types that are declared as UInt
[ in C to be Cardinal in Delphi
[------------------------------------------------------------------------------
[ 23-Dec-2000 (Tim Baumgarten) : Changed all types that are declared as DWord
[ in C to be LongWord in Delphi
[------------------------------------------------------------------------------
[ 14-Dec-2000 (Tim Baumgarten) : Changed some parameters of IDirect3DDevice8.DrawRectPatch
[ and IDirect3DDevice8.DrawTriPatch to Pointers.
[------------------------------------------------------------------------------
[ 14-Dec-2000 (Tim Baumgarten) : Added versions without underlines of some structures
[------------------------------------------------------------------------------
[ 14-Dec-2000 (Tim Baumgarten) : Added "Pointer to Structure" (PStructure = ^TStructure)
[ to all structures.
[------------------------------------------------------------------------------
[ 26-Nov-2000 (Tim Baumgarten) : Returncodes are now typecasted with HResult
[------------------------------------------------------------------------------
(*)
unit DirectXGraphics;
{$MINENUMSIZE 4}
{$ALIGN ON}
//Remove dot to make all enums to be const's
{$DEFINE NOENUMS}
//Remove dot to revert to dx8
{.$DEFINE DX8}
//Remove dot to enable static linking, your app will halt with a error message
//when the d3d8.dll cannot be found.
{$DEFINE STATIC_LINKING}
{$IFDEF VER140}
{$DEFINE DELPHI6}
{$ENDIF}
{$IFDEF DELPHI6}
{$DEFINE DELPHI6_AND_HIGHER}
{$DEFINE D6UP}
{$ENDIF}
{$IFNDEF DELPHI6_AND_HIGHER}
{$DEFINE NOENUMS}
{$ENDIF}
interface
uses
Windows;
{$IFNDEF STATIC_LINKING}
var D3D8DLL : HMODULE = 0;
{$ENDIF}
const D3D8DLLName = 'd3d8.dll';
(*==========================================================================;
*
* Copyright (C) 1995-2000 Microsoft Corporation. All Rights Reserved.
*
* File: d3d8types.h
* Content: Direct3D capabilities include file
*
***************************************************************************)
const DIRECT3D_VERSION = $0800;
const iTrue = DWord(True);
iFalse = DWord(False);
type TD3DColor = type LongWord;
// maps unsigned 8 bits/channel to D3DCOLOR
function D3DCOLOR_ARGB(a, r, g, b : Cardinal) : TD3DColor; // ((D3DCOLOR)((((a)&= $ff)<<24)|(((r)&= $ff)<<16)|(((g)&= $ff)<<8)|((b)&= $ff)))
function D3DCOLOR_RGBA(r, g, b, a : Cardinal) : TD3DColor; // D3DCOLOR_ARGB(a;r;g;b)
function D3DCOLOR_XRGB(r, g, b : Cardinal) : TD3DColor; // D3DCOLOR_ARGB(= $ff;r;g;b)
// maps floating point channels (0.f to 1.f range) to D3DCOLOR
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))
type
PD3DVector = ^TD3DVector;
TD3DVector = packed record
x : Single;
y : Single;
z : Single;
end;
PD3DColorValue = ^TD3DColorValue;
TD3DColorValue = packed record
r : Single;
g : Single;
b : Single;
a : Single;
end;
PD3DRect = ^TD3DRect;
TD3DRect = packed record
x1 : LongInt;
y1 : LongInt;
x2 : LongInt;
y2 : LongInt;
end;
PD3DMatrix = ^TD3DMatrix;
TD3DMatrix = packed record
case Integer of
0 : (_11, _12, _13, _14 : Single;
_21, _22, _23, _24 : Single;
_31, _32, _33, _34 : Single;
_41, _42, _43, _44 : Single);
1 : (m : array [0..3, 0..3] of Single);
end;
PD3DViewport8 = ^TD3DViewport8;
TD3DViewport8 = packed record
X : LongWord;
Y : LongWord; (* Viewport Top left *)
Width : LongWord;
Height : LongWord; (* Viewport Dimensions *)
MinZ : Single; (* Min/max of clip Volume *)
MaxZ : Single
end;
(* Values for clip fields.*)
// Max number of user clipping planes; supported in D3D.
const
D3DMAXUSERCLIPPLANES = 32;
// These bits could be ORed together to use with D3DRS_CLIPPLANEENABLE
D3DCLIPPLANE0 = 1; // (1 << 0)
D3DCLIPPLANE1 = 2; // (1 << 1)
D3DCLIPPLANE2 = 4; // (1 << 2)
D3DCLIPPLANE3 = 8; // (1 << 3)
D3DCLIPPLANE4 = 16; // (1 << 4)
D3DCLIPPLANE5 = 32; // (1 << 5)
// The following bits are used in the ClipUnion and ClipIntersection
// members of the D3DCLIPSTATUS8
D3DCS_LEFT = $00000001;
D3DCS_RIGHT = $00000002;
D3DCS_TOP = $00000004;
D3DCS_BOTTOM = $00000008;
D3DCS_FRONT = $00000010;
D3DCS_BACK = $00000020;
D3DCS_PLANE0 = $00000040;
D3DCS_PLANE1 = $00000080;
D3DCS_PLANE2 = $00000100;
D3DCS_PLANE3 = $00000200;
D3DCS_PLANE4 = $00000400;
D3DCS_PLANE5 = $00000800;
D3DCS_ALL = (D3DCS_LEFT or D3DCS_RIGHT or D3DCS_TOP or
D3DCS_BOTTOM or D3DCS_FRONT or D3DCS_BACK or
D3DCS_PLANE0 or D3DCS_PLANE1 or D3DCS_PLANE2 or
D3DCS_PLANE3 or D3DCS_PLANE4 or D3DCS_PLANE5);
type
PD3DClipStatus8 = ^TD3DClipStatus8;
TD3DClipStatus8 = packed record
ClipUnion : LongWord;
ClipIntersection : LongWord;
end;
PD3DMaterial8 = ^TD3DMaterial8;
TD3DMaterial8 = packed record
Diffuse : TD3DColorValue; (* Diffuse color RGBA *)
Ambient : TD3DColorValue; (* Ambient color RGB *)
Specular : TD3DColorValue; (* Specular 'shininess' *)
Emissive : TD3DColorValue; (* Emissive color RGB *)
Power : Single; (* Sharpness if specular highlight *)
end;
//{$IFDEF D6UP}({$ELSE}LongWord;{$ENDIF}
type TD3DLightType = {$IFNDEF NOENUMS}({$ELSE}LongWord;{$ENDIF}
{$IFDEF NOENUMS}const{$ENDIF}
D3DLIGHT_POINT = 1{$IFNDEF NOENUMS},{$ELSE};{$ENDIF}
D3DLIGHT_SPOT = 2{$IFNDEF NOENUMS},{$ELSE};{$ENDIF}
D3DLIGHT_DIRECTIONAL = 3{$IFNDEF NOENUMS},{$ELSE};{$ENDIF}
D3DLIGHT_FORCE_DWORD = $7fffffff{$IFNDEF NOENUMS}){$ENDIF}; (* force 32-bit size enum *)
type
PD3DLight8 = ^TD3DLight8;
TD3DLight8 = packed record
_Type : TD3DLightType; (* Type of light source *) //D3DLIGHTTYPE
Diffuse : TD3DColorValue; (* Diffuse color of light *)
Specular : TD3DColorValue; (* Specular color of light *)
Ambient : TD3DColorValue; (* Ambient color of light *)
Position : TD3DVector; (* Position in world space *)
Direction : TD3DVector; (* Direction in world space *)
Range : Single; (* Cutoff range *)
Falloff : Single; (* Falloff *)
Attenuation0 : Single; (* Constant attenuation *)
Attenuation1 : Single; (* Linear attenuation *)
Attenuation2 : Single; (* Quadratic attenuation *)
Theta : Single; (* Inner angle of spotlight cone *)
Phi : Single; (* Outer angle of spotlight cone *)
end;
(* Options for clearing *)
const
D3DCLEAR_TARGET = $00000001; (* Clear target surface *)
D3DCLEAR_ZBUFFER = $00000002; (* Clear target z buffer *)
D3DCLEAR_STENCIL = $00000004; (* Clear stencil planes *)
(* The following defines the rendering states *)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -