D3DFVF vertex format C ++ description (VC.NET version)

zhaozj2021-02-08  208

The following code compiled in VC 7.1 (vs.net2003).

Use template offset implementation

#ifndef _ai_d3dfvf_h_ # define _ai_d3dfvf_h _ // D3D9FVF Struct Generate Templates // Author Kevinqing // # include // ---------- Posopeion-- ----------- Namespace_D3DFVF {Template Struct Pos_t; Template <> Struct POS_T {UNITION {D3DVector V; Struct {Float X, Y, Z;}; ; // ----------- RHW ------------------- Template Struct RHW_T; Template <> Struct RHW_T {}; template <> struct rhw_t {float rhw;}; // ----------- W ------------------- --Template struct w_t; template <> struct w_t {}; template <> struct w_t {dWord W;}; // ----------- Normal- --------------- Template struct n_t; template <> struct n_t {}; template <> struct n_t {d3dvector n;}; // ----------- psize ----------------- Template Struct Psize_t; Template <> struct psize_t {}; template < > struct psize_t {float psize;}; // ----------- DIFF ------------------- Template Struct diff_t; template <> struct diff_t {}; template <> struct diff_t {d3dcol OR DIFF;}; // ----------- Spec ------------------ Template STRUCT SPEC_T; Template <> struct SPEC_T {}; template <> struct spec_t {d3dcolor spec;}; # define testflag (a, b, m) (Bool ((A & M) == b) # define TP (A, B) Testflag (A, B, D3DFVF_POSITION_MASK) #define Testmask (A, B) (Bool ((A & B)! =

0)))) // ---------- B / I ---------------------- # define isxyzbn (a) (TP (A , D3DFVF_XYZB1) || / TP (A, D3DFVF_XYZB2) || / TP (A, D3DFVF_XYZB3) || / TP (A, D3DFVF_XYZB4) || / TP (A, D3DFVF_XYZB5) # define xyzbn (a) (TP (A) , D3DFVF_XYZB1)? 1: (/ TP (A, D3DFVF_XYZB2)? 2: (/ TP (A, D3DFVF_XYZB3)? 3: (/ TP (A, D3DFVF_XYZB4)? 4: (/ TP (A, D3DFVF_XYZB5)? 5: 0))))) Template Struct B_t; Template Struct B_T {}; template <> struct b_t {union {float b; dword i };}; Template <> struct b_t {union {float b [2]; DWORD i [2];};}; template <> struct b_t {union {float b [ 3]; DWORD i [3];};}; template <> struct b_t {union {float b [4]; dword i [4];};}; template <> struct b_t {union {float b [5]; dword i [5];};}; // ------------ TEX ----------- # Define TEXN (A) (A & D3DFVF_TEXCOUNT_MASK >> D3DFVF_TEXCOUNT_SHIFT) #define_d3dfvf_texfmt (A, L) ((A >> (L * 2 16)) & 3) #define tex_cordn (A, L) ((_d3dfvf_texfmt (A, L) == D3DFVF_TEXTUREFORMAT1)? 1: (/ (_ D3DFVF_TEXFMT (A, L) == D3DFVF_TEXTUREFORMAT2)? 2: (/ (_ D3DFVF_TEXFMT (A, L) == D3DFVF_TEXTUREFORMAT3)? 3: 4)) # de Fine Decl_Texcord_t (n) / template struct texcord ## n ##_ t; / template struct texcord ## n ## _ t {}; / template <> struct Texcord ## n ## _ t {/ float tu ## n; /}; / template <> struct texcord ## n ## _ T {/ float tu ## n; / float Tv ## n; /}; / template <> struct texcord ## n ## _ T {/ float tu ## n; / float ta ## n; / float ta ## n; /}; / template <> struct texcord ## n ## _ t {/ float tu ## n; / float ta ## n; / float ta ## n; / float tb ## n; /};

转载请注明原文地址:https://www.9cbs.com/read-1955.html

New Post(0)