glDrawElements vs. glVertex3f
Hi all,
I have an opengl book that has an example of small game engine, and it is using glVertex3f() to draw all triangles. However, in one of the chapters, it says that glDrawElements() is more efficient and powerful. So which one is more efficient? Assume that glVertex3f() is drawing from vertex array.
Thanks,
Andy
Using glVertex*() functions is called immediate mode and is NOT a good idea for rendering lots of stuff.
glDrawElements (and other vertex array functions) really are faster and it's a good idea to get used to using vertex arrays.
For even better performance, you could try Vertex Buffer Objects (if your card supports them).
glDrawElements (and other vertex array functions) really are faster and it's a good idea to get used to using vertex arrays.
For even better performance, you could try Vertex Buffer Objects (if your card supports them).
Vertex arrays (glDrawElements) will always be faster to immediate mode (glVertex3f).
your book probably explains why, might want to take a look at VBO's too.
Thank you for all of your replies!!! You guys are good.
One more question, when I use glDrawElements(), do I need glBegin() and glEnd()?
Andy
One more question, when I use glDrawElements(), do I need glBegin() and glEnd()?
Andy
But then when I take away those two lines, my program crashes, once I put them back, it runs fine..???
Thanks,
Andy
Thanks,
Andy
your indicies are incorrect, or something similar, lemme guess, its an access violation right? you or openGL is trying to read outside the bounds of your arrays, which is bad, hence the violation, just make sure you pass the right sizes and stuff, and make sure your indicies (if ur using them) dont point to vertices outside of the bounds of the arrays ur using (ie: you have a vertex array, and a texture coordinate array, both have 256 elements, if you have one of ur indices asking for element 257, (or even 256 since its base 0) you should get an access violation, hope that helps
-Dan
-Dan
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement