Graphics |
在这一部分完成初始化DX,并且完成固定流水线,然后在进行渲染。
在这一部分会用到的数据结构和参数有:
参数:
D3DPRESENT_PARAMETERS* d3dpp; D3DPRESENT_PARAMETERS d3dppW; D3DPRESENT_PARAMETERS d3dppFS; IDirect3D8* pD3D; IDirect3DDevice8* pD3DDevice; IDirect3DVertexBuffer8* pVB; IDirect3DIndexBuffer8* pIB; IDirect3DSurface8* pScreenSurf; IDirect3DSurface8* pScreenDepth; CRenderTargetList* pTargets; CRenderTargetList* pCurTarget; D3DXMATRIX matView; D3DXMATRIX matProj; CTextureList* textures; hgeVertex* VertArray; int nPrim; int CurPrimType; int CurBlendMode; HTEXTURE CurTexture;
其中还有这些结构:
hgevertex
/* ** HGE Vertex structure */ struct hgeVertex { float x, y; // screen position float z; // Z-buffer depth 0..1 DWORD col; // color float tx, ty; // texture coordinates }; //对应的定点设置 #define D3DFVF_HGEVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1) #define VERTEX_BUFFER_SIZE 4000
CRenderTargetList
struct CRenderTargetList { int width; int height; IDirect3DTexture8* pTex; IDirect3DSurface8* pDepth; CRenderTargetList* next; };
CTextureList
struct CTextureList { HTEXTURE tex; int width; int height; CTextureList* next; };
渲染的图元
/* ** HGE Primitive type constants */ #define HGEPRIM_LINES 2 #define HGEPRIM_TRIPLES 3 #define HGEPRIM_QUADS 4 /* ** HGE Vertex structure */ struct hgeVertex { float x, y; // screen position float z; // Z-buffer depth 0..1 DWORD col; // color float tx, ty; // texture coordinates }; /* ** HGE Triple structure */ struct hgeTriple { hgeVertex v[3]; HTEXTURE tex; int blend; }; /* ** HGE Quad structure */ struct hgeQuad { hgeVertex v[4]; HTEXTURE tex; int blend; };
BLEND类型
/* ** HGE Blending constants */ #define BLEND_COLORADD 1 #define BLEND_COLORMUL 0 #define BLEND_ALPHABLEND 2 #define BLEND_ALPHAADD 0 #define BLEND_ZWRITE 4 #define BLEND_NOZWRITE 0 #define BLEND_DEFAULT (BLEND_COLORMUL | BLEND_ALPHABLEND | BLEND_NOZWRITE) #define BLEND_DEFAULT_Z (BLEND_COLORMUL | BLEND_ALPHABLEND | BLEND_ZWRITE)