Sign in to follow this  

OpenGL Rendering large meshes in OpenGl

Recommended Posts



I am rendering large meshes in a very simple and straightforward way (i.e. using VBOs), but as soon as meshes start having more than 0.5 mio triangles, rendering gets slower and scene manipulation is not fluid anymore.


When I look at some other applications (i.e. visualization applications), they can handle the same imported meshes in a much faster and more fluid manner. So my question is: how do they do it?


I am not using any shaders, but the speed difference between my application and the others is too large that it could only be a matter of shaders. My code basically resumes to:






Am I missing an important part of the puzzle?



Share this post

Link to post
Share on other sites

Some possibilities:


1.) Are the update rates of the vertex positions array and the normals array different? If not then put both into the same VBO and store them interleaved.


2.) Use an index buffer.


3.) Try invoking glVertexPointer as the last of all attribute set-ups. Even better, try to use a VAO if possible.


4.) Are the buffers allocated with GL_STATIC_DRAW (if applicable)?

Share this post

Link to post
Share on other sites

Also note that you are not meant to do draw calls of just about any size (though in my opinion, half a million vertices should work perfectly fine on every card, that's certainly big but then again not that big), in particular when using an index buffer as suggested by haegarr, mind what the spec has to say about that:


Implementations denote recommended maximum amounts of vertex and index data, which may be queried by calling GetIntegerv with the symbolic constants MAX_ELEMENTS_VERTICES and MAX_ELEMENTS_INDICES. If end-start+1 is greater than the value of MAX_ELEMENTS_VERTICES, or if count is greater thanthe value of MAX_ELEMENTS_INDICES, then the call may operate at reduced performance.


Maybe the driver is reluctant to pushing such a big chunk of memory onto the card in one go (even if the card can most probably handle that, half a million vertices isn't that much!) and has to do a DMA transfer in the middle, or such a thing. Who knows...

Share this post

Link to post
Share on other sites

Also depends on how big the object is on screen. If you render a million triangles that are drawing to 1/50th of the screen, tons of pixels will be drawn too and will incur very bad performance.

Share this post

Link to post
Share on other sites

In addition to everything mentioned above, there is no reason to glEnableClientState(GL_VERTEX_ARRAY); and glDisableClientState(GL_VERTEX_ARRAY);.

Vertices are always required in a draw call.

Enable it once and leave it enabled.


It also wastes time enabling and disabling GL_NORMAL_ARRAY needlessly between draw calls.  That is, if you draw 2 objects in a row that both have GL_NORMAL_ARRAY enabled, don’t disable and re-enable it, just leave it enabled.

You should always reduce/eliminate redundant API calls.



L. Spiro

Edited by L. Spiro

Share this post

Link to post
Share on other sites

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