Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ianic

rendering prolem of vertex buffer

This topic is 5205 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey tried to creat my self a room class, only i see nothing.... here''s the cpp file, can anyone point out what im doing wrong.. thanx struct WALLVERTEX { D3DXVECTOR3 p; FLOAT tu1, tv1; FLOAT tu2, tv2; }; #define D3DFVF_WALLVERTEX (D3DFVF_XYZ | D3DFVF_TEX2 ) Croom::Croom(LPDIRECT3DDEVICE9 pd3dD) { pd3dDevice = pd3dD; m_pVBWalls = NULL; m_pVBCeiling= NULL; m_pVBFloor = NULL; scale= 100; x=y=z=-50; matFloor = NULL; matCeiling = NULL; matSides = NULL; fillSides(); fillceiling(); fillfloor(); setMaterials(); } Croom::~Croom(void) { } HRESULT Croom :: fillSides(){ if( FAILED( pd3dDevice->CreateVertexBuffer( WALL_VERT_NUM * sizeof(WALLVERTEX), 0, D3DFVF_WALLVERTEX, D3DPOOL_MANAGED, &m_pVBWalls, NULL ) ) ) { return E_FAIL; } WALLVERTEX* pVertices; m_pVBWalls->Lock( 0, 0, (void**)&pVertices, 0 ); FILL_WALLVERTEX( pVertices[ 0], -1.0f,-1.0f, 1.0f, 0.00f, 1.0f, 0.00f, 1.0f ); FILL_WALLVERTEX( pVertices[ 1], -1.0f, 1.0f, 1.0f, 0.00f, 0.0f, 0.00f, 0.0f ); FILL_WALLVERTEX( pVertices[ 2], 1.0f,-1.0f, 1.0f, 1.00f, 1.0f, 1.00f, 1.0f ); FILL_WALLVERTEX( pVertices[ 3], 1.0f, 1.0f, 1.0f, 1.00f, 0.0f, 1.00f, 0.0f ); FILL_WALLVERTEX( pVertices[ 4], 1.0f,-1.0f,-1.0f, 0.00f, 1.0f, 0.00f, 1.0f ); FILL_WALLVERTEX( pVertices[ 5], 1.0f, 1.0f,-1.0f, 0.00f, 0.0f, 0.00f, 0.0f ); FILL_WALLVERTEX( pVertices[ 6], -1.0f,-1.0f,-1.0f, 1.00f, 1.0f, 1.00f, 1.0f ); FILL_WALLVERTEX( pVertices[ 7], -1.0f, 1.0f,-1.0f, 1.00f, 0.0f, 1.00f, 0.0f ); FILL_WALLVERTEX( pVertices[ 8], -1.0f,-1.0f, 1.0f, 0.00f, 1.0f, 0.00f, 1.0f ); FILL_WALLVERTEX( pVertices[ 9], -1.0f, 1.0f, 1.0f, 0.00f, 0.0f, 0.00f, 0.0f ); m_pVBWalls->Unlock(); return S_OK; } HRESULT Croom :: fillfloor(){ // Create the floor/ceiling vertex buffer if( FAILED( pd3dDevice->CreateVertexBuffer( FLOORCEILING_VERT_NUM * sizeof(WALLVERTEX), 0, D3DFVF_WALLVERTEX, D3DPOOL_MANAGED, &m_pVBFloor, NULL ) ) ) { return E_FAIL; } WALLVERTEX* pFloorVertices; m_pVBWalls->Lock( 0, 0, (void**)&pFloorVertices, 0 ); FILL_WALLVERTEX( pFloorVertices[0], -1,-1, 1, 0.0f, 0.0f, 0.0f, 0.0f ); FILL_WALLVERTEX( pFloorVertices[1], 1,-1, 1, 0.0f, 1.0f, 0.0f, 1.0f ); FILL_WALLVERTEX( pFloorVertices[2], 1,-1,-1, 1.0f, 1.0f, 1.0f, 1.0f ); FILL_WALLVERTEX( pFloorVertices[3], 1,-1,-1, 1.0f, 1.0f, 1.0f, 1.0f ); FILL_WALLVERTEX( pFloorVertices[4], -1,-1,-1, 1.0f, 0.0f, 1.0f, 0.0f ); FILL_WALLVERTEX( pFloorVertices[5], -1,-1, 1, 0.0f, 0.0f, 0.0f, 0.0f ); m_pVBWalls->Unlock(); return S_OK; } HRESULT Croom :: fillceiling(){ // Create the floor/ceiling vertex buffer if( FAILED( pd3dDevice->CreateVertexBuffer( FLOORCEILING_VERT_NUM * sizeof(WALLVERTEX), 0, D3DFVF_WALLVERTEX, D3DPOOL_MANAGED, &m_pVBCeiling, NULL ) ) ) { return E_FAIL; } WALLVERTEX* pFloorVertices; m_pVBWalls->Lock( 0, 0, (void**)&pFloorVertices, 0 ); FILL_WALLVERTEX( pFloorVertices[0], 1, 1,-1, 1.0f, 1.0f, 1.0f, 1.0f ); FILL_WALLVERTEX( pFloorVertices[1], 1, 1, 1, 0.0f, 1.0f, 0.0f, 1.0f ); FILL_WALLVERTEX( pFloorVertices[2], -1, 1, 1, 0.0f, 0.0f, 0.0f, 0.0f ); FILL_WALLVERTEX( pFloorVertices[3], -1, 1, 1, 0.0f, 0.0f, 0.0f, 0.0f ); FILL_WALLVERTEX( pFloorVertices[4], -1, 1,-1, 1.0f, 0.0f, 1.0f, 0.0f ); FILL_WALLVERTEX( pFloorVertices[5], 1, 1,-1, 1.0f, 1.0f, 1.0f, 1.0f ); m_pVBWalls->Unlock(); return S_OK; } void Croom :: FILL_WALLVERTEX(WALLVERTEX v,float ax,float ay,float az,float atu1,float atv1,float atu2,float atv2 ) { v.p.x = ax; v.p.y = ay; v.p.z = az; v.tu1 = atu1; v.tv1 = atv1; v.tu2 = atu2; v.tv2 = atv2; } void Croom::render() { setPositionPipe(); pd3dDevice->SetRenderState( D3DRS_FILLMODE , D3DFILL_WIREFRAME ); pd3dDevice->SetTexture(0,matSides); pd3dDevice->SetTexture(1,matSides); pd3dDevice->SetFVF( D3DFVF_WALLVERTEX ); pd3dDevice->SetStreamSource( 0, m_pVBWalls, 0, sizeof(WALLVERTEX) ); pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, WALL_VERT_NUM); pd3dDevice->SetTexture(0,matCeiling); pd3dDevice->SetTexture(1,matCeiling); pd3dDevice->SetFVF( D3DFVF_WALLVERTEX ); pd3dDevice->SetStreamSource( 0, m_pVBCeiling, 0, sizeof(WALLVERTEX) ); pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, FLOORCEILING_VERT_NUM); pd3dDevice->SetTexture(0,matFloor); pd3dDevice->SetTexture(1,matFloor); pd3dDevice->SetFVF( D3DFVF_WALLVERTEX ); pd3dDevice->SetStreamSource( 0, m_pVBFloor, 0, sizeof(WALLVERTEX) ); pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, FLOORCEILING_VERT_NUM); pd3dDevice->SetTexture(0,NULL); pd3dDevice->SetTexture(1,NULL); } void Croom :: setMaterials(){ if( FAILED( D3DXCreateTextureFromFile( pd3dDevice, "./tiger.bmp", &matFloor ) ) ) { matFloor= NULL; } if( FAILED( D3DXCreateTextureFromFile( pd3dDevice, "./MV2.bmp", &matSides ) ) ) { matSides = NULL; } if( FAILED( D3DXCreateTextureFromFile( pd3dDevice, "./cathy.jpg", &matCeiling ) ) ) { matCeiling = NULL; } } void Croom:: setPositionPipe(){ D3DXMATRIXA16 matWorld, matScale; D3DXMatrixTranslation( &matWorld, x, y, z); D3DXMatrixScaling(&matScale, scale, scale, scale); D3DXMatrixMultiply(&matWorld, &matScale, &matWorld); pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); }

Share this post


Link to post
Share on other sites
Advertisement
One thing that could help you find out what is wrong is to check every return value you get. For example the calls to fillSides, fillceiling, fillfloor and all calls to DirectX return a HRESULT indicating if they succeeded. Do a simple check after each call to see if any of them fails. The DirectX debug runtime could also help.

/EliasAE

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!