Hi
My plan was to right a simple basemesh class from which all my renderable classes are based off. That class should be abstract because it contains a virtual render function...my grid class is a child of this basemesh class and i defined a Grid::render() function but i can't create an instance of this class...and the compiler says the grid class would be abstract though i defined the render function and i don't understand why...
CBaseMesh:
class CBaseMesh
{
public:
DWORD FVF;
LPDIRECT3DVERTEXBUFFER9 pVBuffer;
LPDIRECT3DINDEXBUFFER9 pIBuffer;
virtual void render() const=0;
CBaseMesh(void);
~CBaseMesh(void);
};
Grid.h:
class Grid :
public CBaseMesh
{
private:
ngEngine *m_pEngine;
int GetIndex(int x,int z){ return z*m_xRes+x;}
void CreateVertices(D3DXVECTOR3 StartPoint,float RowHeight,float ColWidth,int xCount,int zCount);
void CreateIndices(int xRes,int yRes);
void ConstructBuffers();
public:
int m_xRes,m_zRes;
std::vector<GridVert> Verts;
std::vector<short> Indices;
void Create(ngEngine *engine,D3DXVECTOR3 StartPoint,float XSize,float ZSize,int xRes,int yRes);
void render();
Grid(void);
~Grid(void);
};
[/soruce]
Grid::render:
void Grid::render()
{ m_pEngine->g_pD3DDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
m_pEngine->g_pD3DDevice->SetFVF(FVF);
m_pEngine->g_pD3DDevice->SetStreamSource(0,pVBuffer,0,sizeof(std::vector<GridVert>::value_type));
m_pEngine->g_pD3DDevice->SetIndices(pIBuffer);
m_pEngine->g_pD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,Verts.size(),0,(m_xRes-1)*(m_zRes-1)*2);
//m_pEngine->g_pD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,4,0,2);
//m_pEngine->g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,1);
}
regards,
m4gnus
"There are 10 types of people in the world... those who understand binary and those who don't."