Jump to content
  • Advertisement


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


Direct3D9: (ERROR) :Index stream does not have required number of indices.

This topic is 5322 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

hi everyone, I am newbie on DirectX. I want to draw a pyramid. But all of this pyramid''s side must be triangle. I wrote those codes, but an error was occured, and no shape was drawn. Error Code: Direct3D9: (ERROR) :Index stream does not have required number of indices. DrawIndexedPrimitive failed. My codes: *************************************************************** Device->CreateVertexBuffer( 4 * sizeof(Vertex), D3DUSAGE_WRITEONLY, Vertex::FVF, D3DPOOL_MANAGED, &VB, 0); Device->CreateIndexBuffer( 12 * sizeof(WORD), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_MANAGED, &IB, 0); // // Fill the buffers with the cube data. // // define unique vertices: Vertex* vertices; VB->Lock(0, 0, (void**)&vertices, 0); vertices[0] = Vertex(-1.0f,-1.0f,-1.0f); vertices[1] = Vertex( 0.0f, 1.0f, 0.0f); vertices[2] = Vertex( 1.0f, 1.0f,-1.0f); vertices[3] = Vertex( 0.0f,-1.0f, 1.0f); VB->Unlock(); // define the triangles of the cube: WORD* indices = 0; IB->Lock(0, 0, (void**)&indices, 0); // front indices[0] = 0; indices[1] = 1; indices[2] = 2; // right indices[3] = 1; indices[4] = 2; indices[5] = 3; // left indices[6] = 1; indices[7] = 3; indices[8] = 0; // bottom indices[9] = 0; indices[10] = 3; indices[11] = 2; IB->Unlock(); // // Position and aim the camera. // D3DXVECTOR3 position(0.0f, 0.0f, -5.0f); D3DXVECTOR3 target(0.0f, 0.0f, 0.0f); D3DXVECTOR3 up(0.0f, 1.0f, 0.0f); D3DXMATRIX V; D3DXMatrixLookAtLH(&V, &position, &target, &up); Device->SetTransform(D3DTS_VIEW, &V); // // Set the projection matrix. // D3DXMATRIX proj; D3DXMatrixPerspectiveFovLH( &proj, D3DX_PI * 0.5f, // 90 - degree (float)Width / (float)Height, 1.0f, 1000.0f); Device->SetTransform(D3DTS_PROJECTION, &proj); // // Switch to wireframe mode. // Device->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); ***************************************************************

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!