Original Post
Hi,
I am trying to forward declare stucts that I am using from directX so that I don't have to #include 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
//Custom (sprite) vertex for our Vertex Buffer
struct 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 created
std::vector m_sprites;
//A dynamic Vertex Buffer that changes with each fram to make is hold the co-ordinates of each sprite
LPDIRECT3DVERTEXBUFFER9 m_pVB; // Buffer to hold vertices
//A Index buffer to go with the Vertex buffer
LPDIRECT3DINDEXBUFFER9 m_pIB; // Buffer to hold Indicies
//Vertex Declaration
IDirect3DVertexDeclaration9 m_pVertexDecl;
//Our shader
LPD3DXEFFECT g_pSpriteShader; //=== OUR SHADER EFFECT:
};[/source]
Thanks
I am trying to forward declare stucts that I am using from directX so that I don't have to #include
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
//Custom (sprite) vertex for our Vertex Buffer
struct 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 created
std::vector
//A dynamic Vertex Buffer that changes with each fram to make is hold the co-ordinates of each sprite
LPDIRECT3DVERTEXBUFFER9 m_pVB; // Buffer to hold vertices
//A Index buffer to go with the Vertex buffer
LPDIRECT3DINDEXBUFFER9 m_pIB; // Buffer to hold Indicies
//Vertex Declaration
IDirect3DVertexDeclaration9 m_pVertexDecl;
//Our shader
LPD3DXEFFECT g_pSpriteShader; //=== OUR SHADER EFFECT:
};[/source]
Thanks