I am trying to forward declare stucts that I am using from directX so that I don't have to #include <D3DX9math.h> every time I want to use one in a header.
I am having some trouble forward declaring some classes (structs) from DirectX. My Vertex and index buffer(s) declarations work and I can use the members in my .cpp file but the Vertex declaration and shader don't work in my .cpp.
Is there a convention for using DirectX objects in custom classes or is there another way I can do this.
Below is what I current have.
[source lang="cpp"]#ifndef SPRITEMANAGER_H#define SPRITEMANAGER_H#include <vector>//Custom (sprite) vertex for our Vertex Bufferstruct SpriteVertex;//forward declaration#define D3DFVF_SPRITEVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)//-----------------------------------------------------------------------------------------------------------------//Forward Declarations://-----------------------------------------------------------------------------------------------------------------typedef struct IDirect3DVertexBuffer9 *LPDIRECT3DVERTEXBUFFER9, *PDIRECT3DVERTEXBUFFER9;typedef struct IDirect3DIndexBuffer9 *LPDIRECT3DINDEXBUFFER9, *PDIRECT3DINDEXBUFFER9;typedef struct IDirect3DVertexDeclaration9 *LPDIRECT3DVERTEXDECLARATION9, *PDIRECT3DVERTEXDECLARATION9;typedef interface ID3DXEffect LPD3DXEFFECT;class Sprite;class SpriteManager{public:SpriteManager(void);~SpriteManager(void);private://A Vector of all sprites createdstd::vector<Sprite*> m_sprites;//A dynamic Vertex Buffer that changes with each fram to make is hold the co-ordinates of each spriteLPDIRECT3DVERTEXBUFFER9 m_pVB; // Buffer to hold vertices//A Index buffer to go with the Vertex bufferLPDIRECT3DINDEXBUFFER9 m_pIB; // Buffer to hold Indicies//Vertex DeclarationIDirect3DVertexDeclaration9 m_pVertexDecl;//Our shaderLPD3DXEFFECT g_pSpriteShader; //=== OUR SHADER EFFECT:};[/source]
Thanks
Edited by AussieSpoon, 17 December 2012 - 12:46 AM.






