View Full Version : slow vertex array
09-07-2002, 07:45 AM
i'm using a vertex array in a display list, that is i use...
the problem is, that it is unbelievably slow (first i thought my programm crashed, but it was just the time needed to render the first frame!)! i wonder if the reason for that is, that i transfer the whole geometry data to the graphics card every frame with glDrawElements. can anyone give me an advice?
09-07-2002, 08:50 AM
How large is the vertex array you are sending? Have you checked the maximum recommended index and vertex counts?
Also, what data type are you using for your indices?
09-07-2002, 09:12 AM
the vertex array is 852 vertices. what are the recommended index and vertex counts? the data type of the indices is unsigned int/GL_UNSIGNED_INT.
09-07-2002, 09:27 AM
i was just thinking, if glDrawElements is the function that sends the geometry data to the graphics card, i shouldnt call it every frame (that would probably explain why it is so slow). or does it load the data only the first time it is called and then takes it from the cards memory? or is there a point about this that i got completely wrong?
09-07-2002, 10:35 AM
You should read the faq, but here is a cut n paste from the msdn OpenGL documentation about what commands you can't use in a display list:
"Certain commands are not compiled into the display list, but are executed immediately, regardless of the display list mode. These commands are glColorPointer, glDeleteLists, glDisableClientState, glEdgeFlagPointer, glEnableClientState, glFeedbackBuffer, glFinish, glFlush, glGenLists, glIndexPointer, glInterleavedArrays, glIsEnabled, glIsList, glNormalPointer, glPopClientAttrib, glPixelStore, glPushClientAttrib, glReadPixels, glRenderMode, glSelectBuffer, glTexCoordPointer, glVertexPointer, and all of the glGet routines."
"Similarly, glTexImage2D and glTexImage1D are executed immediately and not compiled into the display list when their first argument is GL_PROXY_TEXTURE_2D or GL_PROXY_TEXTURE_1D, respectively."
Instead of using the glVertexPointer and other commands related to glDrawElements inside of a display list generation, you should use the glBegin(GL_TRIANGLE) ... glEnd(); functions. Do this once for the static polygon data during your initialization with GL_COMPILE for glNewList argument instead of GL_COMPILE_AND_EXECUTE. Then simply call glCallList(displayListIndex) in your rendering function.
If you wan't to use the glDrawElements function call, forget about display lists and simply call every frame the needed glVertexPointer, glNormalPointer etc to setup the per vertex information and call glDrawElements after that. The performance should be good enough for starters and if you wan't to get more performance start looking up the vertex array range extensions for Nvidia boards and Atis corresponding.
09-07-2002, 10:45 AM
Thanks a lot! So does it mean i can't gain further speed when using a display list and a vertex array? is the geometry data used by functions in a display list automatically stored on the card?
Once you passed the data to the display list, you will never know where and how it's stored. It can be in video memory, yes, but it can also be in system memory, or some other strange place.
If you try to add a vertex array in a display list, the display list will dereference the vertex array in the same way as when you draw the vertex array, and move the vertex data from the vertex array to the display list. That means the vertex array is no longer in use once compiled into the display list.
09-07-2002, 02:17 PM
Thanks! That was, what i was wondering about.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.