# OpenGL Drawing a few polygons that move- VBO's, VA's, Dl's?

## Recommended Posts

If i just draw a few polygons on the screen that move around and rotate, should I do VBO's or VA's? And I'm assuming DL's won't work with moving poly's (polys are static, but I use opengl state calls to move them, transforms and rotates) What would be fastest

##### Share on other sites
That all depends on the hardware, drivers, and how many poly's you will be drawing. DL's or VBO's would be your best bet though.

##### Share on other sites
Well im probably going to be doing around 50 to 2000 polys on the screen. Most will be particles.

Hardware wise, it's a game, so im putting minimum requires ments at a geforce 1 or ati card.

I also might be using the stencil buffer to draw only parts of some polygons.

And just to clarify, if im storing my my polygon locations in a STL class/struct, I can use DL's?

Also what data structure is the most compatible?

Right now im drawing everything in immediate mode, and with such few polys it's pretty fast. But Basicly im looking for something to give older/slower systems a speed boost, as immediate mode is just to slow anyways.

##### Share on other sites
For that number of particles I'd say you'll probably be fine with regular vertex arrays. Do that first and see what the performance is like.

However you can still build a display list and use glTranslate/Rotate etc. before you call it. The snag being that you can't get any kind of animation as the polys are fixed in relation to each other.

##### Share on other sites
Don't discount immediate mode. If you submit, say, less than 40 vertices at a time before changing state, immediate mode may work just fine.

You can use display lists even when you move them. If you only record the vertex data, not the transforms, then you can set up the transforms separately, and call the display list to issue the data.

If you're doing lots of particles, though, you really want to be writing them all into one big streaming VBO per material; that's going to be the fastest way to get the geometry to the GPU, assuming you have hardware transform.

##### Share on other sites
I understand supposedly that on average, Lists and VBOs are about the same speedwise, or somewhat close. Lists have the advantage that they can also include state changes, which tend to be costly, and vertices. A trick is that any state that isn't actually changed inside the list then uses the state as is when you call the list, so if you have a quad, just the verts in the list, you can change it's color while using the same list. The disadvantage is that the verts can't change relative to each other. If you have a static model, it is great, but if the model does any animation, you out of luck. VBOs/VAs have the main advantage to me in that they use dynamic data. For just straight VAs, the real advantage is just batch sending of vertices to th GPU in one function call. VBOs I think put the verts into GPU memory before usage(something like that) so they are faster. This isn't too much of an issue, but VBOs are used in an extension to OpenGL, so older cards(read really old) don't have it, but most anything nowere or recent does. The best way is just to use the best tool for the job. A List won't help too much for a particle system due to that the particles are animated position wise, so you'd have the List of only one quad or point, so obviously VAs are a better choice for that.

##### Share on other sites
Hrm, ive got a question, you reccomend streaming VBOs. I was thinking that when i designed my particle system. But, is it possible/likely that internally, vertex arrays ARE streaming VBOs? (on newer cards that is). Or do you think that theres still an advantage to using a streaming vbo over a va? (Im currently using VAs, although premature optimization is the root of all evil, the transition would be so painless i wouldnt mind, what do you think?)

thanks
-Dan

## 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

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627676
• Total Posts
2978582
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
Thank you in advance!
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 11
• 12
• 10
• 12
• 22