⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmd3dtyp.pas

📁 一套及时通讯的原码
💻 PAS
📖 第 1 页 / 共 3 页
字号:
    D3DRENDERSTATE_STIPPLEPATTERN26     = 90;
    D3DRENDERSTATE_STIPPLEPATTERN27     = 91;
    D3DRENDERSTATE_STIPPLEPATTERN28     = 92;
    D3DRENDERSTATE_STIPPLEPATTERN29     = 93;
    D3DRENDERSTATE_STIPPLEPATTERN30     = 94;
    D3DRENDERSTATE_STIPPLEPATTERN31     = 95; 

function    D3DRENDERSTATE_STIPPLEPATTERN(y: D3DRENDERSTATETYPE): D3DRENDERSTATETYPE; 

type
    TStateType                          = record
        case Byte of
            0: (dtstTransformStateType      : D3DTRANSFORMSTATETYPE);
            1: (dlstLightStateType          : D3DLIGHTSTATETYPE);
            2: (drstRenderStateType         : D3DRENDERSTATETYPE);
    end;

    PD3DSTATE                           = ^TD3DSTATE;
    TD3DSTATE                           = record
        stType                          : TStateType;
        case Byte of
            0: (dwArg: array[0..0] of DWORD);
            1: (dvArg: array[0..0] of D3DVALUE);
    end;

{-- Operation used to load matrices (hDstMat = hSrcMat) ----------------------}

    PD3DMATRIXLOAD                      = ^TD3DMATRIXLOAD;
    TD3DMATRIXLOAD                      = record
        hDestMatrix                     : D3DMATRIXHANDLE;  // Destination matrix
        hSrcMatrix                      : D3DMATRIXHANDLE;  // Source matrix
    end;

{-- Operation used to multiply matrices (hDstMat = hSrcMat1 * hSrcMat2) ------}

    PD3DMATRIXMULTIPLY                  = ^TD3DMATRIXMULTIPLY;
    TD3DMATRIXMULTIPLY                  = record
        hDestMatrix                     : D3DMATRIXHANDLE;  // Destination matrix
        hSrcMatrix1                     : D3DMATRIXHANDLE;  // First source matrix
        hSrcMatrix2                     : D3DMATRIXHANDLE;  // Second source matrix
    end;

{-- Operation used to transform and light vertices ---------------------------}

    PD3DPROCESSVERTICES                 = ^TD3DPROCESSVERTICES;
    TD3DPROCESSVERTICES                 = record
        dwFlags                         : DWORD;            // Do we transform or light or just copy?
        wStart                          : WORD;             // Index to first vertex in source 
        wDest                           : WORD;             // Index to first vertex in local buffer 
        dwCount                         : DWORD;            // Number of vertices to be processed 
        dwReserved                      : DWORD;            // Must be zero 
    end;

const
    D3DPROCESSVERTICES_TRANSFORMLIGHT   = $00000000;
    D3DPROCESSVERTICES_TRANSFORM        = $00000001;
    D3DPROCESSVERTICES_COPY             = $00000002;
    D3DPROCESSVERTICES_OPMASK           = $00000007;

    D3DPROCESSVERTICES_UPDATEEXTENTS    = $00000008;
    D3DPROCESSVERTICES_NOCOLOR          = $00000010;

{== Triangle flags ===========================================================}

{-- Tri strip and fan flags --------------------------------------------------}

//
// START loads all three vertices
// EVEN and ODD load just v3 with even or odd culling
// START_FLAT contains a count from 0 to 29 that allows the
// whole strip or fan to be culled in one hit.
// e.g. for a quad len = 1
//
const
    D3DTRIFLAG_START                        = $00000000;

// 0 < len < 30
function    D3DTRIFLAG_STARTFLAT(len: DWORD): DWORD;

const
    D3DTRIFLAG_ODD                          = $0000001e;
    D3DTRIFLAG_EVEN                         = $0000001f;

{-- Triangle edge flags - enable edges for wireframe or antialiasing ---------}

const
    D3DTRIFLAG_EDGEENABLE1                  = $00000100;    // v0-v1 edge
    D3DTRIFLAG_EDGEENABLE2                  = $00000200;    // v1-v2 edge
    D3DTRIFLAG_EDGEENABLE3                  = $00000400;    // v2-v0 edge
    D3DTRIFLAG_EDGEENABLETRIANGLE           = D3DTRIFLAG_EDGEENABLE1 or D3DTRIFLAG_EDGEENABLE2 or D3DTRIFLAG_EDGEENABLE3;

{== Primitive structures and related defines =================================}

// Vertex offsets are to types D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX.

{-- Triangle list primitive structure ----------------------------------------}

type
    PD3DTRIANGLE                            = ^TD3DTRIANGLE;
    TD3DTRIANGLE                            = record
        case Byte of
            0: (v1, v2, v3: WORD);          // Vertex indices
            1: (wV1, wV2, wV3,
                wFlags: WORD);              // Edge (and other) flags
    end;

{-- Line strip structure - the instr count - 1 defines the num of line segs --}

    PD3DLINE                                = ^TD3DLINE;
    TD3DLINE                                = record
        case Byte of
            0: (v1, v2: WORD);              // Vertex indices
            1: (wV1, wV2: WORD);
    end;

{-- Span structure -----------------------------------------------------------}

// Spans join a list of points with the same y value.
// If the y value changes, a new span is started.

    PD3DSPAN                                = ^TD3DSPAN;
    TD3DSPAN                                = record
        wCount                              : WORD;     // Number of spans
        wFirst                              : WORD;     // Index to first vertex
    end;

{-- Point structure ----------------------------------------------------------}

    PD3DPOINT                               = ^TD3DPOINT;
    TD3DPOINT                               = record
        wCount                              : WORD;     // number of points
        wFirst                              : WORD;     // index to first vertex
    end;

{-- Forward branch structure -------------------------------------------------}

// Mask is logically anded with the driver status mask
// if the result equals 'value', the branch is taken.

    PD3DBRANCH                              = ^TD3DBRANCH;
    TD3DBRANCH                              = record
        dwMask                              : DWORD;    // Bitmask against D3D status
        dwValue                             : DWORD;
        bNegate                             : BOOL;     // TRUE to negate comparison
        dwOffset                            : DWORD;    // How far to branch forward (0 for exit)
    end;

{-- Status used for set status instruction -----------------------------------}

// The D3D status is initialised on device creation
// and is modified by all execute calls.

    PD3DSTATUS                              = ^TD3DSTATUS;
    TD3DSTATUS                              = record
        dwFlags                             : DWORD;    // Do we set extents or status
        dwStatus                            : DWORD;    // D3D status
        drExtent                            : TD3DRECT;
    end;

const
    D3DSETSTATUS_STATUS                     = $00000001;
    D3DSETSTATUS_EXTENTS                    = $00000002;
    D3DSETSTATUS_ALL                        = (D3DSETSTATUS_STATUS or D3DSETSTATUS_EXTENTS);

{-- Statistics structure -----------------------------------------------------}

type
    PD3DSTATS                               = ^TD3DSTATS;
    TD3DSTATS                               = record
        dwSize                              : DWORD;
        dwTrianglesDrawn                    : DWORD;
        dwLinesDrawn                        : DWORD;
        dwPointsDrawn                       : DWORD;
        dwSpansDrawn                        : DWORD;
        dwVerticesProcessed                 : DWORD;
    end;

{-- Execute options ----------------------------------------------------------}

// When calling using D3DEXECUTE_UNCLIPPED all the primitives
// inside the buffer must be contained within the viewport.

const
    D3DEXECUTE_CLIPPED                      = $00000001;
    D3DEXECUTE_UNCLIPPED                    = $00000002;

type
    PD3DEXECUTEDATA                         = ^TD3DEXECUTEDATA;
    TD3DEXECUTEDATA                         = record
        dwSize                              : DWORD;
        dwVertexOffset                      : DWORD;
        dwVertexCount                       : DWORD;
        dwInstructionOffset                 : DWORD;
        dwInstructionLength                 : DWORD;
        dwHVertexOffset                     : DWORD;
        dsStatus                            : TD3DSTATUS;   // Status after execute
    end;

{-- Palette flags ------------------------------------------------------------}

// This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw.

const
    D3DPAL_FREE                             = $00;  // Renderer may use this entry freely
    D3DPAL_READONLY                         = $40;  // Renderer may not set this entry
    D3DPAL_RESERVED                         = $80;  // Renderer may not use this entry

function D3DVector(vX,vY,vZ: D3DValue): TD3DVECTOR;

implementation

function D3DVector(vX,vY,vZ: D3DValue): TD3DVECTOR;
begin
   with Result do
   begin
      X := vX;
      Y := vY;
      Z := vZ;
   end;
end;

function    D3DVALP(val: Extended; prec: Integer): D3DVALUE;
begin
    Result  := val;
end;

function    D3DVAL(val: Extended): D3DVALUE;
begin
    Result  := val;
end;

function    D3DDivide(a, b: D3DVALUE): D3DVALUE;
begin
    Result  := a / b;
end;

function    D3DMultiply(a, b: D3DVALUE): D3DVALUE;
begin
    Result  := a * b;
end;

function    CI_GETALPHA(ci: D3DCOLOR): Byte;
begin
    Result  := ci shr 24;
end;

function    CI_GETINDEX(ci: D3DCOLOR): Word;
begin
    Result  := (ci shr 8) and $ffff;
end;

function    CI_GETFRACTION(ci: D3DCOLOR): Byte;
begin
    Result  := ci and $ff;
end;

function    CI_ROUNDINDEX(ci: D3DCOLOR): Word;
begin
    Result  := CI_GETINDEX(ci + $80);
end;

function    CI_MASKALPHA(ci: D3DCOLOR): DWord;
begin
    Result  := ci and $ffffff;
end;

function    CI_MAKE(a: Byte; i: Word; f: Byte): D3DCOLOR;
begin
    Result  := (a shl 24) or (i shl 8) or f;
end;

function    RGBA_GETALPHA(rgb: D3DCOLOR): Byte;
begin
    Result  := rgb shr 24;
end;

function    RGBA_GETRED(rgb: D3DCOLOR): Byte;
begin
    Result  := (rgb shr 16) and $ff;
end;

function    RGBA_GETGREEN(rgb: D3DCOLOR): Byte;
begin
    Result  := (rgb shr 8) and $ff;
end;

function    RGBA_GETBLUE(rgb: D3DCOLOR): Byte;
begin
    Result  := rgb and $ff;
end;

function    RGBA_MAKE(r, g, b, a: Byte): D3DCOLOR;
begin
    Result  := (a shl 24) or (r shl 16) or (g shl 8) or b;
end;

function    D3DRGB(r, g, b: D3DVALUE): D3DCOLOR;
begin
    Result  := $ff000000 or (Trunc(r * 255) shl 16) or (Trunc(g * 255) shl 8) or Trunc(b * 255);
end;

function    D3DRGBA(r, g, b, a: D3DVALUE): D3DCOLOR;
begin
    Result  := (Trunc(a * 255) shl 24) or (Trunc(r * 255) shl 16) or (Trunc(g * 255) shl 8) or Trunc(b * 255);
end;

function    RGB_GETRED(rgb: D3DCOLOR): Byte;
begin
    Result  := (rgb shr 16) and $ff;
end;

function    RGB_GETGREEN(rgb: D3DCOLOR): Byte;
begin
    Result  := (rgb shr 8) and $ff;
end;

function    RGB_GETBLUE(rgb: D3DCOLOR): Byte;
begin
    Result  := rgb and $ff;
end;

function    RGBA_SETALPHA(rgba: D3DCOLOR; x: Byte): D3DCOLOR;
begin
    Result  := (x shl 24) or (rgba and $00ffffff);
end;

function    RGB_MAKE(r, g, b: Byte): D3DCOLOR;
begin
    Result  := (r shl 16) or (g shl 8) or b;
end;

function    RGBA_TORGB(rgba: D3DCOLOR): D3DCOLOR;
begin
    Result  := rgba and $ffffff;
end;

function    RGB_TORGBA(rgb: D3DCOLOR): D3DCOLOR;
begin
    Result  := rgb or $ff000000;
end;

{-- A state which sets the override flag for the specified state type --------}

function    D3DSTATE_OVERRIDE(_type: DWORD): DWORD;
begin
    Result  := _type + D3DSTATE_OVERRIDE_BIAS;
end;

function    D3DRENDERSTATE_STIPPLEPATTERN(y: D3DRENDERSTATETYPE): D3DRENDERSTATETYPE;
begin
    Result  := D3DRENDERSTATE_STIPPLEPATTERN00 + y;
end;

function    D3DTRIFLAG_STARTFLAT(len: DWORD): DWORD;
begin
    Result  := len;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -