Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualMJP

Posted 17 December 2012 - 01:04 PM

What I meant was that I would do it like this:

#ifndef SPRITEMANAGER_H
#define SPRITEMANAGER_H

#include <vector>

//Custom (sprite) vertex for our Vertex Buffer
struct SpriteVertex;//forward declaration

#define D3DFVF_SPRITEVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)

//-----------------------------------------------------------------------------------------------------------------
//Forward Declarations:
//-----------------------------------------------------------------------------------------------------------------
struct IDirect3DVertexBuffer9;
struct IDirect3DIndexBuffer9;
struct IDirect3DVertexDeclaration9;
struct ID3DXEffect;

class Sprite;

class SpriteManager
{

public:
	SpriteManager(void);
	~SpriteManager(void);

private:

	//A Vector of all sprites created
	std::vector<Sprite*> m_sprites;

	//A dynamic Vertex Buffer that changes with each fram to make is hold the co-ordinates of each sprite
	IDirect3DVertexBuffer9* m_pVB; // Buffer to hold vertices

	//A Index buffer to go with the Vertex buffer
	IDirect3DIndexBuffer9* m_pIB; // Buffer to hold Indicies

	//Vertex Declaration
	IDirect3DVertexDeclaration9* m_pVertexDecl;

	//Shader pointer  
	ID3DXEffect* g_pSpriteShader;
};

#endif//SPRITEMANAGER_H


Your problem with the effect appears to be that you've declared a pointer to a pointer to an ID3DXEffect. You have this:

LPD3DXEFFECT* g_pSpriteShader;

which is equivalent to this:

ID3DXEffect** g_pSpriteShader;

This is why I recommended not using those typedefs: they can be confusing.

#2MJP

Posted 17 December 2012 - 01:04 PM

What I meant was that I would do it like this:

#ifndef SPRITEMANAGER_H
#define SPRITEMANAGER_H

#include <vector>

//Custom (sprite) vertex for our Vertex Buffer
struct SpriteVertex;//forward declaration

#define D3DFVF_SPRITEVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)

//-----------------------------------------------------------------------------------------------------------------
//Forward Declarations:
//-----------------------------------------------------------------------------------------------------------------
struct IDirect3DVertexBuffer9;
struct IDirect3DIndexBuffer9;
struct IDirect3DVertexDeclaration9;
struct ID3DXEffect;

class Sprite;

class SpriteManager
{

public:
	SpriteManager(void);
	~SpriteManager(void);

private:

	//A Vector of all sprites created
	std::vector<Sprite*> m_sprites;

	//A dynamic Vertex Buffer that changes with each fram to make is hold the co-ordinates of each sprite
	IDirect3DVertexBuffer9* m_pVB; // Buffer to hold vertices

	//A Index buffer to go with the Vertex buffer
	IDirect3DIndexBuffer9* m_pIB; // Buffer to hold Indicies

	//Vertex Declaration
	IDirect3DVertexDeclaration9* m_pVertexDecl;

	//Shader pointer  
	ID3DXEffect* g_pSpriteShader;
};

#endif//SPRITEMANAGER_H

Your problem with the effect appears to be that you've declared a pointer to a pointer to an ID3DXEffect. You have this:

LPD3DXEFFECT* g_pSpriteShader;

which is equivalent to this:

ID3DXEffect** g_pSpriteShader;

This is why I recommended not using those typedefs: they can be confusing.

#1MJP

Posted 17 December 2012 - 12:55 PM

Just do this:

#ifndef SPRITEMANAGER_H
#define SPRITEMANAGER_H

#include <vector>

//Custom (sprite) vertex for our Vertex Buffer
struct SpriteVertex;//forward declaration

#define D3DFVF_SPRITEVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)

//-----------------------------------------------------------------------------------------------------------------
//Forward Declarations:
//-----------------------------------------------------------------------------------------------------------------
struct IDirect3DVertexBuffer9;
struct IDirect3DIndexBuffer9;
struct IDirect3DVertexDeclaration9;
struct ID3DXEffect;

class Sprite;

class SpriteManager
{

public:
    SpriteManager(void);
    ~SpriteManager(void);

private:

    //A Vector of all sprites created
    std::vector<Sprite*> m_sprites;

    //A dynamic Vertex Buffer that changes with each fram to make is hold the co-ordinates of each sprite
    IDirect3DVertexBuffer9* m_pVB; // Buffer to hold vertices

    //A Index buffer to go with the Vertex buffer
    IDirect3DIndexBuffer9* m_pIB; // Buffer to hold Indicies

    //Vertex Declaration
    IDirect3DVertexDeclaration9* m_pVertexDecl;

    //Shader pointer  
    ID3DXEffect* g_pSpriteShader;
};


#endif//SPRITEMANAGER_H

PARTNERS