Sign in to follow this  
Beco

Different types of primitives with VA and VBO

Recommended Posts

I draw a model containing many primitives of different types, also lines, triangles and quads. I would like to implement it with VAs and VBOs to increase speed but I don't know exactly how. Can I create more than one array for every type of primitives? If I store everything in one array how can I call drawing functions with different modes (GL_LINES, GL_TRIANGLES, GL_QUADS)?

Share this post


Link to post
Share on other sites
Make your vertex array (including position, colours, textures, etc.). Then make two arrays of indices (for triangles and quads). For lines, use glPolygonMode(GL_FRONT,GL_LINE) (and glPolygonMode(GL_BACK,GL_LINE) if you don't have back face culling enabled). You should be able to work it out from there.

Share this post


Link to post
Share on other sites
I've found out a solution of the problem but now I have another. I've managed to build my model from vertex arrays in my PC's memory and it became much faster. I've reached about 80-100 fps with nearly 8000 faces with normals and colors. But when I want to use VBOs it slows down to 4-5 fps. What could be the problem? I do exactly the same as in NeHe Lesson 45. I've Radeon 9250 (128 MB) and Lesson 45 runs at least 110-120 fps with VBOs depending on the size of the window.

Share this post


Link to post
Share on other sites
VA and VBO aswell as Display lists may perform differently. If your geometry is static, try using display lists.

Just test what gieves best performance an use it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Beco
What could be the problem? I do exactly the same as in NeHe Lesson 45.


Well, you obviously aren't doing exactly the same, or it'd work ;¬) I'd guess you are uploading the vertices every frame or something, while telling the driver to treat it as STATIC_DRAW. Either use another usage hint or only upload the verts once.

Share this post


Link to post
Share on other sites
I've managed to resolve the problem and now it runs at a very high speed with VBOs. But now I have a new problem with SwapBuffers. When I draw a big model (above 250000 faces with vertex, normal , color and texture coord array) rendering remains very fast from Vertex Buffer Object but SwapBuffers takes 0.2 sec. What could be the reason?

I think SwapBuffers should depend only of the size of the window. Is it possible that my card is out of memory and it slows down buffer handling? I can't think of anything else.

thx

Share this post


Link to post
Share on other sites
SwapBuffers is probably waiting for the gpu to finish processing the geometry you send.

edit: found the man page.. and atleast in GLX it doesen't wait for the buffers to actually swap but instead returns emidiatly. If hoever you start drawing befor the buffers are swapped then you have to wait. don't know how this is in the win equivalent, but I imagine its simmilar.

Memory shouldn't be a problem. If I made the math correctly your geometry would take ~11MB

[Edited by - nefthy on May 31, 2005 5:29:01 AM]

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