Sign in to follow this  

Worthwile using compiled vertex arrays??

This topic is 4750 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:
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glTexCoordPointer(2, GL_FLOAT, 0, m_Object.m_pTextureCoords);
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, m_Object.m_pVertices);
	glDrawElements(GL_TRIANGLE_STRIP, m_Object.m_numOfTriangles, GL_UNSIGNED_INT, m_Object.m_pIndices);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);

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.

HTH

Share this post


Link to post
Share on other sites

This topic is 4750 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this