Original Post
I have been doing the initialization of my shape classes a certain way for a while and I now want to move on to a better way of doing it. I currently have five vertex types. I was creating a new vertex declaration every time the classes were created. Now I want to just make them each one time, then assign them to a class variable. My first thought of this was the fact that they are globals, and even though they are used only once, would this still be bad? Right now in my vertex types header I have the following code: Inside of InitializeVertexTypes I will initialize all of the vertex declarations and set the sizes for gcVertexSizes. Then inside of my shape class I will have the following My question is, is there a better way to do this? I am currently doing this and I call InitializeVertexTypes, all the data becomes valid but then later in my code all of the variables become erased back to (0x00000) like they were reset.
enum eVertexType { VertexBase, VertexLN, VertexLTEX, VertexLNTEX, VertexLNTEXTAN, _SIZE };
static IDirect3DVertexDeclaration9 *gcVertexDefinitions[_SIZE];
static size_t gcVertexSizes[_SIZE];
void InitializeVertexTypes(LPDIRECT3DDEVICE9 lpD3Device);
IDirect3DVertexDeclaration9 *m_VD;
tVertexBase m_vtVertexType;
size_t m_nSizeOfType;