The cube example in this chapter differs from the previous, using the canonical class definition.
Note One: the problem with the class const static member variable in the header file:
Vertex.h:
structvertext{Vertext () {} vertext (floatXfloatYfloatZfloatNxfloatNyfloatnzfloatU,floatv) {_x= X;_y = y;_z=Z; _nx= NX; _ny = NY; _nz =NZ; _u=u;_v=v; } float_x,_y,_z; float_nx,_ny,_nz; float_u,_v; Static ConstDWORD fvft;};//Const DWORD vertext::fvft= (D3DFVF_XYZ | D3dfvf_normal | D3DFVF_TEX1);// mode 2 //#define VERTEX_FVF (d3dfvf_xyz | D3dfvf_normal | D3DFVF_TEX1)// mode 1 #endif //!__vertexh__
The example given is mode 1; when I use Mode 2, there is a link error, error link1169 multiple redefined symbols .
Then I define it in the Vertex.cpp, right:
" vertex.h " Const DWORD vertext::fvft= (d3dfvf_xyz | D3dfvf_normal | D3DFVF_TEX1);
Note: 1. Do not attempt to define variables in the header file. h ( except extern global) 2. Static variables defined in the. h, in different CPP files, because of the static local, each CPP will open its own static variables; For example, I defined the static int a=0 in the a.h; in B.cpp, C.cpp, # include A.H Then, the static a variable in b.cpp and C.cpp has no relation.
Reference: Http://bbs.csdn.net/topics/390720572?page=1
3. Compiling is to turn the source code into a machine instruction; pre-compilation is just the process of coding, #include预编译; the function is to copy the contents of the file to the current; static keyword
4. #ifndef #endif only prevents duplicate copies of the same header files at the time of precompilation;
Note two: mipmaps and filter of textures
Cause: The size of the texture is inconsistent with the size of the screen triangle.
First, set up the Mipmaps chain, set different texture levels, select the grade, determine the texture I need, and secondly, the texture and screen triangle can be matched by setting the filter mode.
Like what:
Device->setsamplerstate (0, D3dsamp_magfilter, d3dtexf_linear);//Third step Device- Setsamplerstate (0, D3dsamp_minfilter, d3dtexf_linear);//The second step texture is reduced by Device->setsamplerstate ( 0, D3dsamp_mipfilter, d3dtexf_point);// First step
Texture: 256*256 build mipmaps chain: 128*128,64*64,32*32 ... If the triangle is 100*100 level;
According to the first step : Mipmap filter is set to D3dtexf_point (the most recent choice), now select 128*128; texture in accordance with the second step , a plurality of texture cells corresponding to a triangular unit, d3dtexf_ Linear linear texture filtering method; Each triangle pixel samples the closest 2*2 texture point and averages it;
Reference: http://blog.csdn.net/kkk328/article/details/7055934
question: But I do not know, if is the texture magnification mode (third step), D3dtexf_linear mode, this time a texture unit corresponding to a plurality of pixels, how to choose the texture 2*2 take the mean?
Note Three : four modes of addressing for textures,
Cause: Texture coordinates can exceed 1 of the range.
Several modes: wrap (surround), Border border mode (self-setting), clamp (intercept (capture texture in the range 0 to 1, and extend the edge color), mirror mode
Dragon Book DX9 Texture