📄 direct3d9.pas
字号:
(*)
[------------------------------------------------------------------------------
[ _ _ _ _ _ _ ___ _ ___
[ _| |___| |___| |_|_| _| |_ _ _| |_ |_| | . |
[ | . | -_| | . | | |_| . |_'_|_| . |_ | . |_ |
[ |___|___|_| _|_|_|_|_|___|_,_|_|___|___|___|___|
[ |_|
[
[------------------------------------------------------------------------------
[ Direct3D 9 Delphi Adaptation (c) by Tim Baumgarten
[------------------------------------------------------------------------------
[ Files : d3d9.h
[ d3d9types.h
[ d3d9caps.h
[ Modified : 10-Jul-2003
[ E-Mail : ampaze at gmx dot net
[ Download : http://www.crazyentertainment.net
[------------------------------------------------------------------------------
(*)
(*)
[------------------------------------------------------------------------------
[ History :
[----------
[ 10-Jul-2003 (Tim Baumgarten) : Changed some Enum Stuff that was broken
[ 23-Jan-2003 (Tim Baumgarten) : out out out, anyone need outs ?
[ 12-Jan-2003 (Tim Baumgarten) : Improved some parts.
[ 20-Dec-2002 (Tim Baumgarten) : first public version
[ most likely to contains bugs, please report
[------------------------------------------------------------------------------
(*)
unit Direct3D9;
{$INCLUDE jedi.inc}
{$MINENUMSIZE 4}
{$ALIGN ON}
//Remove dot to make all enums to be const's
{$DEFINE NOENUMS}
//Remove dot to enable static linking
{$DEFINE STATIC_LINKING}
{$IFDEF DELPHI7_UP}
{$WARN UNSAFE_CODE OFF}
{$WARN UNSAFE_TYPE OFF}
{$WARN UNSAFE_CAST OFF}
{$ENDIF}
{$IFNDEF DELPHI6_UP}
{$DEFINE NOENUMS}
{$ENDIF}
interface
uses
Windows;
{$IFNDEF STATIC_LINKING}
var
d3d9dll : HMODULE = 0;
{$ENDIF}
const
d3d9dllname = 'd3d9.dll';
type
PLongWord = ^LongWord;
(*)
*******************************************************************************
*
* Copyright (C) Microsoft Corporation. All Rights Reserved.
*
* File : d3d9types.h
* Content : Direct3D capabilities include file
*
*******************************************************************************
(*)
const
DIRECT3D_VERSION = $0900;
type
// D3DCOLOR is equivalent to D3DFMT_A8R8G8B8
TD3DColor = LongWord;
// maps unsigned 8 bits/channel to D3DCOLOR
function D3DCOLOR_ARGB(a, r, g, b : Cardinal) : TD3DColor;
function D3DCOLOR_RGBA(r, g, b, a : Cardinal) : TD3DColor;
function D3DCOLOR_XRGB(r, g, b : Cardinal) : TD3DColor;
function D3DCOLOR_XYUV(y, u, v : Cardinal) : TD3DColor;
function D3DCOLOR_AYUV(a, y, u, v : Cardinal) : TD3DColor;
// maps floating point channels (0.f to 1.f range) to D3DCOLOR
function D3DCOLOR_COLORVALUE(r, g, b, a : Single) : TD3DColor;
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 : (_00, _01, _02, _03,
_10, _11, _12, _13,
_20, _21, _22, _23,
_30, _31, _32, _33 : Single);
1 : (m : array [0..3, 0..3] of Single);
end;
PD3DViewport9 = ^TD3DViewport9;
TD3DViewport9 = 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.*)
const
// Max number of user clipping planes; supported in D3D.
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
PD3DClipStatus9 = ^TD3DClipStatus9;
TD3DClipStatus9 = packed record
ClipUnion : LongWord;
ClipIntersection : LongWord;
end;
PD3DMaterial9 = ^TD3DMaterial9;
TD3DMaterial9 = 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;
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}){$ENDIF};
type
PD3DLight9 = ^TD3DLight9;
TD3DLight9 = packed record
_Type : TD3DLightType; (* Type of light source *)
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 *)
type
TD3DShadeMode = {$IFNDEF NOENUMS}({$ELSE}LongWord;{$ENDIF}
{$IFDEF NOENUMS}const{$ENDIF}
D3DSHADE_FLAT = 1{$IFNDEF NOENUMS},{$ELSE};{$ENDIF}
D3DSHADE_GOURAUD = 2{$IFNDEF NOENUMS},{$ELSE};{$ENDIF}
D3DSHADE_PHONG = 3{$IFNDEF NOENUMS}){$ENDIF};
type
TD3DFillMode = {$IFNDEF NOENUMS}({$ELSE}LongWord;{$ENDIF}
{$IFDEF NOENUMS}const{$ENDIF}
D3DFILL_POINT = 1{$IFNDEF NOENUMS},{$ELSE};{$ENDIF}
D3DFILL_WIREFRAME = 2{$IFNDEF NOENUMS},{$ELSE};{$ENDIF}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -