Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: Xalthorn on March 31, 2010

Title: OpenGL Triangle Strips
Post by: Xalthorn on March 31, 2010
Okay, so I have my little demo doing what I want it to do but now I want to do some heavy optimising.

It uses a significant number of triangles held in a big list and I figured the thing would run faster if I converted it to a few triangle strips.

However, having read through some websites, there seems to be a debate on whether or not this will make any difference whatsoever, and in fact it might run slower due to vertex cache issues.

As this is my first OpenGL project and I really don't have a clue, I'm hoping some of the experienced OpenGL'ers could let me know if it's worth wrestling with strips or just leave it as a triangle list.
Title: Re: OpenGL Triangle Strips
Post by: hellfire on March 31, 2010
If your application is limited by vertex-throughput use indexed triangle-lists with VBO (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=45)s.
With strips you always pass one vertex per triangle.
With indexing you can get significantly lower (~0.5 vtx/tri) because all three vertices of a new triangle are still in the cache.
Title: Re: OpenGL Triangle Strips
Post by: Xalthorn on March 31, 2010
Quote from: hellfire on March 31, 2010
If your application is limited by vertex-throughput use indexed triangle-lists with VBO (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=45)s.
With strips you always pass one vertex per triangle.
With indexing you can get significantly lower (~0.5 vtx/tri) because all three vertices of a new triangle are still in the cache.

Umm, okay looks like I need to do some more reading.  I'll follow that link and have a read :)
Title: Re: OpenGL Triangle Strips
Post by: Voltage on April 01, 2010
This looks like a good resource for finding bottlenecks in your opengl apps:

http://www.opengl.org/resources/code/samples/advanced/advanced97/notes/node205.html
Title: Re: OpenGL Triangle Strips
Post by: hellfire on April 01, 2010
Quotea significant number of triangles held in a big list
If "list" means a display-list (http://glprogramming.com/red/chapter07.html) you won't see much gain from VBOs.
The driver often performs quite some optimizations when assembling the list.
Title: Re: OpenGL Triangle Strips
Post by: Xalthorn on April 01, 2010
Quote from: hellfire on April 01, 2010
Quotea significant number of triangles held in a big list
If "list" means a display-list (http://glprogramming.com/red/chapter07.html) you won't see much gain from VBOs.
The driver often performs quite some optimizations when assembling the list.

Nope, my list is not as organised as that, it's just running through an array, spitting out OpenGL triangle commands as it goes.  I'm essentially writing a freebasic program throwing data at OpenGL and I'm sure OpenGL is annoyed at the way I'm doing it :)

But that gives me something else to think about, thanks :)
Title: Re: OpenGL Triangle Strips
Post by: hellfire on April 01, 2010
Are your vertices static or dynamic?
Title: Re: OpenGL Triangle Strips
Post by: Xalthorn on April 01, 2010
Quote from: hellfire on April 01, 2010
Are your vertices static or dynamic?

Assuming you are asking if the vertices have the same local coordinates and not whether the vertice list changes, I have two large models, one is static (although the thing scales, but I can probably mess with the camera for that) and the other is extremely dynamic.

From initial looks, I'm guessing I can pop the static one in a display list for sheer speed as the thing never changes shape.  That should get me a huge speed increase, and I'm wondering if I pop the dynamic one into a display list I should be sending less information to the OpenGL pipeline each frame.