Jump to content
  • Advertisement


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


VBO + glDrawRangeElements

This topic is 5236 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 guys Hoping you can help me with a little problem with VBOs and glDrawRangeElements. I''m trying to replace a standard vertex array (using glXPointers) with VBOs. I can''t use glDrawElements because that causes major memory reallocations (check nv docs), nor can I use glDrawArrays because that is no different than using a display list. In fact, its worse because you can''t change texture bindings. Loading code:
		glGenBuffersARB(2, m_vertexBufferObjects);

		glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vertexBufferObjects[VERTEX_BUFFER]);
		glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(BSPVertex) * m_numOfVerts, m_pVerts, GL_STATIC_DRAW_ARB);
		glVertexPointer(3, GL_FLOAT, sizeof(BSPVertex), (char*)NULL);
		//glNormalPointer(GL_FLOAT, sizeof(BSPVertex), (char*)(sizeof(CVector2) * 2 + sizeof(CVector3)));

		int size;
		glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size);
		CONSOLE.AddLine("Vertex Buffer size: %i", size);
		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_vertexBufferObjects[INDEX_BUFFER]);
		glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(int) * m_numOfIndices, m_pIndexArray, GL_STATIC_DRAW_ARB);
		glIndexPointer(GL_UNSIGNED_INT, sizeof(int), (char*)NULL);
		glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vertexBufferObjects[VERTEX_BUFFER]);
		CONSOLE.AddLine("Index Buffer size: %i", size);
BSPVertex encompasses texture coords, normals, colours, and the vertices themselves. It is a 64bit structure. Rendering code:
        glDrawRangeElementsEXT(GL_TRIANGLES, pFace->meshVertIndex, pFace->meshVertIndex + pFace->numOfVerts, pFace->numMeshVerts, GL_UNSIGNED_INT, 0);
I know that the glDrawRangeElementsExt statement is wrong, but I''ve tried so many possible values, that is the latest. If I put in a pointer (or rather offset) to the indices, then the computer hangs, requiring a reset. Original code for the normal vertex array:
glDrawElements(GL_TRIANGLES, pFace->numMeshVerts, GL_UNSIGNED_INT, &m_pIndexArray[pFace->meshVertIndex]);
Any help would be very appreciated In fact, just a summary of how glDrawRangeElements works, when using a separate buffer for Index Arrays should help me figure this out

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!