Advertisement Jump to content


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


Something wrong with index buffer

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

Ok, i can't found bug, in my index buffer, when i render through DrawPrimitiveUP and pass my indiex and vertex lists it is work, but when i try to tender through index buffer, it is not work. I try to debug index and vertex buffers, when i render my model through vertex buffer and D3DPT_POINTLIST all is ok, but when i render from vertex buffer with indices something wrong, this is my code: For j=0 all TotalMeshes Indices += TotalFaces[j]; RenderDevice->CreateIndexBuffer(Indices*sizeof(unsigned short)*3 , D3DUSAGE_DYNAMIC,D3DFMT_INDEX16,D3DPOOL_DEFAULT,&IndexBuffer); void *pIndices; i=0; For j=0 all TotalMeshes{ IndexBuffer->Lock(i,sizeof(unsigned short)*TotalFaces[j]*3,(BYTE**)&pIndices,0); memcpy(pIndices,Index[j],sizeof(unsigned short)*TotalFaces[j]*3); IndexBuffer->Unlock(); i+=sizeof(unsigned short)*TotalFaces[j]*3; } TotalMeshes - total models, TotalFaces[j] - total faces in my sub model, Index[j] - indices of my sub model, i multiply TotalFaces[j] by 3 cause face has A,B,C vertices. [edited by - Vulc777 on February 1, 2003 7:29:07 AM]

Share this post

Link to post
Share on other sites
Enable the debug runtime, turn up the ouput level in the control panel and run your code again. The debug output window should contain details of any problems.

Unfortunately we need more information than "when I render from vertex buffer with indices something wrong"

WHAT is wrong - can you show us a screenshot?, can you show us a simple part of your data?, can you show us the exact error message? or crash you get?... etc

Simon O''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites
Ok, here is my problem. I have some structures which include information about my model(s), i have array of structures, and the number of structures is “TotalMeshes”. This structure is
Typedef struct{
D3DVECTOR vector; //Vertex vector;
D3DCOLOR diffuse; //Vertex color;
FLOAT u, v; //Mapping coordinates;
When I’ve read this information from 3ds, then I’ve create vertex and index buffer:
TotalFaces[j]– total faces of the j model; type unsigned long;
Total[j]- total vertices of the j model; type unsigned long;
i,j- counters; type unsigned long;
Vertex[j]- array of j model of vertices; type float;
Index[j]- array of j model of indices; type unsigned short;(WORD)

//Calculate total faces;
for(j=0; j//Create index buffer;

//Calculate total vertices;
for(j=0; j//Create vertex buffer;

VOID *pIndices,*pVertices;

//Then i put all information to my buffers(index and vertex buffer);
for(j=0,i=0; j buffer(by pieces);
i+=sizeof(WORD)*TotalFaces[j]*3;//To the next memory block;

for(j=0,i=0; j buffer(by pieces);
i+=sizeof(D3DVERTEX)*Total[j];//To the next memory block;
Then i call my procedure render();

RenderDevice->DrawPrimitive(D3DPT_POINTLIST,0,Vertices); (1)
//When I call that method (1) all vertices are read from vertex
//buffer well;
//When I call that method (2) all vertices are read bad (first
//model render and other models are not rendered)
//There is one interesting thing when model contains a lot of
//vertices and faces, I didn’t see it.
//Even if render with (1) method
//This method (3) render through arrays and work well for all
//model(s), even if the model contains a lot of submodels.
for(int j=0; j RenderDevice->DrawIndexedPrimitiveUP (D3DPT_TRIANGLELIST,0,

I don’t understand where is the bug, I locked entire index and vertex buffer, and tested every byte and every byte same as in the arrays, what’s the problem I need your help, I can’t find this bug, maybe someone can help me. Thanks.

Share this post

Link to post
Share on other sites
And one more question, if you know how 3ds stores vertex ambient, diffuse and specualar component of the color. I know that chunks, but chunk lenght only 15 bytes. Does it store information only in one byte? It''s not so interesting for me now like problem with index buffer, and prbably with vertex buffer.....

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!