Jump to content
  • Advertisement
Sign in to follow this  

Worthwile using compiled vertex arrays??

This topic is 5061 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, I'm currently working on rendering terrain from a heightmap as fast as possible. I started off just using the old classic glBegin(GL_TRIANGLES). As you can imagine it went pretty slow, so then i moved onto using triangle strips which was an improvement but still poor, anyways after a long process of gradual improvents im now using indexed triangle strips with vertex arrays. Heres how i draw my terrain:
	glTexCoordPointer(2, GL_FLOAT, 0, m_Object.m_pTextureCoords);
	glVertexPointer(3, GL_FLOAT, 0, m_Object.m_pVertices);
	glDrawElements(GL_TRIANGLE_STRIP, m_Object.m_numOfTriangles, GL_UNSIGNED_INT, m_Object.m_pIndices);

This is a big improvement from how i was originally rendering the scene, but my laptop is kinda shitty and im only getting around 35 fps with 64 * 64 vertices. Should I be compiling the vertex array or are there better ways of drawing the terrain? I dont have a clue how to use compiled arrays cos I think they use extensions and I havent looked into them yet. Thanks for your time and help. Djamel.

Share this post

Link to post
Share on other sites
i dont think compiled is worth it, go for VBO's if you can. They will be much faster.

Note about your code, you dont have to disable and enable the arrays for each patch of terrain that you draw (enable once, draw everything that needs it [still setting pointers] and then disable).

Second thing, you are using unsigned ints for your indicies, this is slow especially if you aren't using the range. Use unsigned shorts instead (use bytes if you have less than 256 verts to index), half the size in memory and you can index up to 65536 verts (with GL_UNSIGNED_SHORT).

glDrawRangeElements might help you too.


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!