Jump to content
  • Advertisement

Archived

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

ZenGeneral

Vertex Array Problem, help!

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

I have been working (with OSG) and trying to get a vertex array version of my mesh to render, and I have code that (appears) to work. And code that doesn't work, it generates an exception, if I don't handle it crash, If I do handle it I have a counter going up per frame, and when the catch is reached, the counter is printed and reset to zero. Here is the output: 59, 294, 4, 1, 1, 22, 104, 1, 87, 1, 81, 1, 8, 5, 16, more numbers without a pattern. Code that is working now, but not ideal (edit: now it crasheed at frame 111858).
GLfloat * vb = new GLfloat[ZDM->_meshes[i].VertexCount * 3];
GLfloat * nm = new GLfloat[ZDM->_meshes[i].VertexCount * 3];
memcpy(vb, VB->_vertexBuffer[i].vertexData, ZDM->_meshes[i].VertexCount * 3 * sizeof(float));
memcpy(nm, VB->_vertexBuffer[i].normalData, ZDM->_meshes[i].VertexCount * 3 * sizeof(float));

glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);

glVertexPointer(3, GL_FLOAT, 0, vb);
glNormalPointer(GL_FLOAT, 0, nm);

glColor3f(1.0f,1.0f,1.0f);

glDrawElements(GL_TRIANGLES, 3 * (ZDM->_meshes[i].TriangleCount), GL_UNSIGNED_INT, VB->_indexBuffer[i].indexData);

delete [] vb;
delete [] nm;


code that produces artifacts and crashs:
   
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);

glVertexPointer(3, GL_FLOAT, 0, VB->_vertexBuffer[i].vertexData);
glNormalPointer(GL_FLOAT, 0, VB->_vertexBuffer[i].normalData);

glColor3f(1.0f,1.0f,1.0f);

glDrawElements(GL_TRIANGLES, 3 * (ZDM->_meshes[i].TriangleCount), GL_UNSIGNED_INT, VB->_indexBuffer[i].indexData);
Does anyone know what is going on? [edited by - ZenGeneral on April 10, 2004 7:00:05 AM] [edited by - ZenGeneral on April 10, 2004 10:24:24 AM]

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!