📄 mmd3dtyp.pas
字号:
{========================================================================}
{= (c) 1995-98 SwiftSoft Ronald Dittrich =}
{========================================================================}
{= All Rights Reserved =}
{========================================================================}
{= D 01099 Dresden = Tel.: +0351-8012255 =}
{= Loewenstr.7a = info@swiftsoft.de =}
{========================================================================}
{= Actual versions on http://www.swiftsoft.de/mmtools.html =}
{========================================================================}
{= This code is for reference purposes only and may not be copied or =}
{= distributed in any format electronic or otherwise except one copy =}
{= for backup purposes. =}
{= =}
{= No Delphi Component Kit or Component individually or in a collection=}
{= subclassed or otherwise from the code in this unit, or associated =}
{= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
{= without express permission from SwiftSoft. =}
{= =}
{= For more licence informations please refer to the associated =}
{= HelpFile. =}
{========================================================================}
{= $Date: 20.01.1998 - 18:00:00 $ =}
{========================================================================}
{= Aufgabe: Direct3D types Unit =}
{========================================================================}
{= This code is for reference purposes only and may not be copied or =}
{= distributed in any format electronic or otherwise except one copy =}
{= for backup purposes. =}
{= =}
{= No Delphi Component Kit or Component individually or in a collection=}
{= subclassed or otherwise from the code in this unit, or associated =}
{= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
{= without express permission from SwiftSoft. =}
{= =}
{= For more licence informations please refer to the associated =}
{= HelpFile. =}
{========================================================================}
unit MMD3DTyp;
{$I COMPILER.INC}
interface
uses
Windows,
MMDDraw;
type
FLOAT = Single;
LONG = LongInt;
PVOID = Pointer;
D3DENUM = DWORD;
{-- D3DVALUE is the fundamental Direct3D fractional data type ----------------}
type
PD3DVALUE = ^D3DVALUE;
D3DVALUE = FLOAT;
function D3DVALP(val: Extended; prec: Integer): D3DVALUE;
function D3DVAL(val: Extended): D3DVALUE;
function D3DDivide(a, b: D3DVALUE): D3DVALUE;
function D3DMultiply(a, b: D3DVALUE): D3DVALUE;
type
D3DFIXED = LONG;
PD3DCOLOR = ^D3DCOLOR;
D3DCOLOR = DWORD;
//
// Format of CI colors is
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | alpha | color index | fraction |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
function CI_GETALPHA(ci: D3DCOLOR): Byte;
function CI_GETINDEX(ci: D3DCOLOR): Word;
function CI_GETFRACTION(ci: D3DCOLOR): Byte;
function CI_ROUNDINDEX(ci: D3DCOLOR): Word;
function CI_MASKALPHA(ci: D3DCOLOR): DWord;
function CI_MAKE(a: Byte; i: Word; f: Byte): D3DCOLOR;
//
// Format of RGBA colors is
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | alpha | red | green | blue |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
function RGBA_GETALPHA(rgb: D3DCOLOR): Byte;
function RGBA_GETRED(rgb: D3DCOLOR): Byte;
function RGBA_GETGREEN(rgb: D3DCOLOR): Byte;
function RGBA_GETBLUE(rgb: D3DCOLOR): Byte;
function RGBA_MAKE(r, g, b, a: Byte): D3DCOLOR;
//
// D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs
// The float values must be in the range 0..1
//
function D3DRGB(r, g, b: D3DVALUE): D3DCOLOR;
function D3DRGBA(r, g, b, a: D3DVALUE): D3DCOLOR;
//
// Format of RGB colors is
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | ignored | red | green | blue |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
function RGB_GETRED(rgb: D3DCOLOR): Byte;
function RGB_GETGREEN(rgb: D3DCOLOR): Byte;
function RGB_GETBLUE(rgb: D3DCOLOR): Byte;
function RGBA_SETALPHA(rgba: D3DCOLOR; x: Byte): D3DCOLOR;
function RGB_MAKE(r, g, b: Byte): D3DCOLOR;
function RGBA_TORGB(rgba: D3DCOLOR): D3DCOLOR;
function RGB_TORGBA(rgb: D3DCOLOR): D3DCOLOR;
{== Flags for Enumerate functions ============================================}
const
{-- Stop the enumeration -----------------------------------------------------}
D3DENUMRET_CANCEL = DDENUMRET_CANCEL;
{-- Continue the enumeration -------------------------------------------------}
D3DENUMRET_OK = DDENUMRET_OK;
type
TD3DVALIDATECALLBACK = function(lpUserArg: PVOID; dwOffset: DWORD): HRESULT; stdcall;
TD3DENUMTEXTUREFORMATSCALLBACK = function(lpDdsd: PDDSURFACEDESC; lpContext: PVOID): HRESULT; stdcall;
PD3DMATERIALHANDLE = ^D3DMATERIALHANDLE;
D3DMATERIALHANDLE = DWORD;
PD3DTEXTUREHANDLE = ^D3DTEXTUREHANDLE;
D3DTEXTUREHANDLE = DWORD;
PD3DMATRIXHANDLE = ^D3DMATRIXHANDLE;
D3DMATRIXHANDLE = DWORD;
TD3DCOLORVALUE = record
case Byte of
0: (r, g, b, a : D3DVALUE);
1: (dvR, dvG, dvB, dvA : D3DVALUE);
end;
PD3DRECT = ^TD3DRECT;
TD3DRECT = record
case Byte of
0: (x1, y1, x2, y2: LONG);
1: (lX1, lY1, lX2, lY2: LONG);
end;
PD3DVECTOR = ^TD3DVECTOR;
TD3DVECTOR = record
case Byte of
0: (x, y, z: D3DVALUE);
1: (dvX, dvY, dvZ: D3DVALUE);
end;
{== Vertext data types supported in an ExecuteBuffer =========================}
{-- Homogenous vertices ------------------------------------------------------}
type
PD3DHVERTEX = ^TD3DHVERTEX;
TD3DHVERTEX = record
dwFlags : DWORD; // Homogeneous clipping flags
case Byte of
0: (hx, hy, hz: D3DVALUE);
1: (dvHX, dvHY, dvHZ: D3DVALUE);
end;
{-- Transformed/lit vertices -------------------------------------------------}
PD3DTLVERTEX = ^TD3DTLVERTEX;
TD3DTLVERTEX = record
case Byte of
0: (
sx : D3DVALUE; // Screen coordinates
sy : D3DVALUE;
sz : D3DVALUE;
rhw : D3DVALUE; // Reciprocal of homogeneous w
color : D3DCOLOR; // Vertex color
specular : D3DCOLOR; // Specular component of vertex
tu : D3DVALUE; // Texture coordinates
tv : D3DVALUE
);
1: (
dvSX : D3DVALUE;
dvSY : D3DVALUE;
dvSZ : D3DVALUE;
dvRHW : D3DVALUE;
dcColor : D3DCOLOR;
dcSpecular : D3DCOLOR;
dvTU : D3DVALUE;
dvTV : D3DVALUE
);
end;
{-- Untransformed/lit vertices -----------------------------------------------}
PD3DLVERTEX = ^TD3DLVERTEX;
TD3DLVERTEX = record
case Byte of
0: (
x : D3DVALUE; // Screen coordinates
y : D3DVALUE;
z : D3DVALUE;
dwReserved : DWORD;
color : D3DCOLOR; // Vertex color
specular : D3DCOLOR; // Specular component of vertex
tu : D3DVALUE; // Texture coordinates
tv : D3DVALUE
);
1: (
dvX : D3DVALUE;
dvY : D3DVALUE;
dvZ : D3DVALUE;
_dwReserved : DWORD;
dcColor : D3DCOLOR;
dcSpecular : D3DCOLOR;
dvTU : D3DVALUE;
dvTV : D3DVALUE
);
end;
{-- Untransformed/unlit vertices ---------------------------------------------}
PD3DVERTEX = ^TD3DVERTEX;
TD3DVERTEX = record
case Byte of
0: (
x : D3DVALUE; // Screen coordinates
y : D3DVALUE;
z : D3DVALUE;
nx : D3DVALUE; // Normal
ny : D3DVALUE;
nz : D3DVALUE;
tu : D3DVALUE; // Texture coordinates
tv : D3DVALUE
);
1: (
dvX : D3DVALUE;
dvY : D3DVALUE;
dvZ : D3DVALUE;
dvNX : D3DVALUE;
dvNY : D3DVALUE;
dvNZ : D3DVALUE;
dvTU : D3DVALUE;
dvTV : D3DVALUE
);
end;
{-- Matrix, viewport, and transformation structures and definitions ----------}
PD3DMATRIX = ^TD3DMATRIX;
TD3DMATRIX = record
_11, _12, _13, _14 : D3DVALUE;
_21, _22, _23, _24 : D3DVALUE;
_31, _32, _33, _34 : D3DVALUE;
_41, _42, _43, _44 : D3DVALUE;
end;
PD3DVIEWPORT = ^TD3DVIEWPORT;
TD3DVIEWPORT = record
dwSize : DWORD;
dwX : DWORD;
dwY : DWORD; // Top left
dwWidth : DWORD;
dwHeight : DWORD; // Dimensions
dvScaleX : D3DVALUE; // Scale homogeneous to screen
dvScaleY : D3DVALUE; // Scale homogeneous to screen
dvMaxX : D3DVALUE; // Min/max homogeneous x coord
dvMaxY : D3DVALUE; // Min/max homogeneous y coord
dvMinZ : D3DVALUE;
dvMaxZ : D3DVALUE; // Min/max homogeneous z coord
end;
{-- Values for clip fields ---------------------------------------------------}
const
D3DCLIP_LEFT = $00000001 ;
D3DCLIP_RIGHT = $00000002 ;
D3DCLIP_TOP = $00000004 ;
D3DCLIP_BOTTOM = $00000008 ;
D3DCLIP_FRONT = $00000010 ;
D3DCLIP_BACK = $00000020 ;
D3DCLIP_GEN0 = $00000040 ;
D3DCLIP_GEN1 = $00000080 ;
D3DCLIP_GEN2 = $00000100 ;
D3DCLIP_GEN3 = $00000200 ;
D3DCLIP_GEN4 = $00000400 ;
D3DCLIP_GEN5 = $00000800 ;
{-- Values for D3D status ----------------------------------------------------}
D3DSTATUS_CLIPUNIONLEFT = D3DCLIP_LEFT;
D3DSTATUS_CLIPUNIONRIGHT = D3DCLIP_RIGHT;
D3DSTATUS_CLIPUNIONTOP = D3DCLIP_TOP;
D3DSTATUS_CLIPUNIONBOTTOM = D3DCLIP_BOTTOM;
D3DSTATUS_CLIPUNIONFRONT = D3DCLIP_FRONT;
D3DSTATUS_CLIPUNIONBACK = D3DCLIP_BACK;
D3DSTATUS_CLIPUNIONGEN0 = D3DCLIP_GEN0;
D3DSTATUS_CLIPUNIONGEN1 = D3DCLIP_GEN1;
D3DSTATUS_CLIPUNIONGEN2 = D3DCLIP_GEN2;
D3DSTATUS_CLIPUNIONGEN3 = D3DCLIP_GEN3;
D3DSTATUS_CLIPUNIONGEN4 = D3DCLIP_GEN4;
D3DSTATUS_CLIPUNIONGEN5 = D3DCLIP_GEN5;
D3DSTATUS_CLIPINTERSECTIONLEFT = $00001000;
D3DSTATUS_CLIPINTERSECTIONRIGHT = $00002000;
D3DSTATUS_CLIPINTERSECTIONTOP = $00004000;
D3DSTATUS_CLIPINTERSECTIONBOTTOM= $00008000;
D3DSTATUS_CLIPINTERSECTIONFRONT = $00010000;
D3DSTATUS_CLIPINTERSECTIONBACK = $00020000;
D3DSTATUS_CLIPINTERSECTIONGEN0 = $00040000;
D3DSTATUS_CLIPINTERSECTIONGEN1 = $00080000;
D3DSTATUS_CLIPINTERSECTIONGEN2 = $00100000;
D3DSTATUS_CLIPINTERSECTIONGEN3 = $00200000;
D3DSTATUS_CLIPINTERSECTIONGEN4 = $00400000;
D3DSTATUS_CLIPINTERSECTIONGEN5 = $00800000;
D3DSTATUS_ZNOTVISIBLE = $01000000;
D3DSTATUS_CLIPUNIONALL =
D3DSTATUS_CLIPUNIONLEFT or
D3DSTATUS_CLIPUNIONRIGHT or
D3DSTATUS_CLIPUNIONTOP or
D3DSTATUS_CLIPUNIONBOTTOM or
D3DSTATUS_CLIPUNIONFRONT or
D3DSTATUS_CLIPUNIONBACK or
D3DSTATUS_CLIPUNIONGEN0 or
D3DSTATUS_CLIPUNIONGEN1 or
D3DSTATUS_CLIPUNIONGEN2 or
D3DSTATUS_CLIPUNIONGEN3 or
D3DSTATUS_CLIPUNIONGEN4 or
D3DSTATUS_CLIPUNIONGEN5
;
D3DSTATUS_CLIPINTERSECTIONALL =
D3DSTATUS_CLIPINTERSECTIONLEFT or
D3DSTATUS_CLIPINTERSECTIONRIGHT or
D3DSTATUS_CLIPINTERSECTIONTOP or
D3DSTATUS_CLIPINTERSECTIONBOTTOM or
D3DSTATUS_CLIPINTERSECTIONFRONT or
D3DSTATUS_CLIPINTERSECTIONBACK or
D3DSTATUS_CLIPINTERSECTIONGEN0 or
D3DSTATUS_CLIPINTERSECTIONGEN1 or
D3DSTATUS_CLIPINTERSECTIONGEN2 or
D3DSTATUS_CLIPINTERSECTIONGEN3 or
D3DSTATUS_CLIPINTERSECTIONGEN4 or
D3DSTATUS_CLIPINTERSECTIONGEN5
;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -