0

So I was looking around for optimizations for my program and I was wandering if using QUADS is the most efficient way of doing it.. I am using Mapped interleaved VBOs for QUADS vertices and TEXTURE coords .

So I want to know if there is a clear performance boost when using one of the following instead of QUADS for rendering:

Note: This needs to include the fact that I am using textures!

  • TRIANGLE_STRIPS
  • TRIANGLES
  • QUAD_STRIPS

Which is the fastest?

Note 2: I looked around and could not find a definitive answer.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Amit Assaraf
  • 512
  • 11
  • 34
  • 1
    Theres a difference between TRIANGLE_STRIPS and TRIANGLES. Not so sure about QUAD_STRIPS why not just make a small program that takes a large number of random primitives and draws them and look at performance. – Xonar Jun 02 '13 at 12:01
  • Yeah but I want to know if there is a difference compared to QUADS.. and its a great idea to make the program but I simply don't have the time so I want to see if I can get a short and good answer :D – Amit Assaraf Jun 02 '13 at 12:53
  • http://stackoverflow.com/questions/6644099/what-is-so-bad-about-gl-quads – Grimmy Jun 02 '13 at 13:01

1 Answers1

3
  • GL_QUAD_STRIP is deprecated and not supported in the current version of OpenGL, so that's out. Plus, it's not too fast anyway - see this post for a good explanation of why it's no longer supported (save for compatibility purposes).

  • GL_TRIANGLES is generally a good way to go. It'll be faster than using outdated functionality. And it's faster in principle, too - quads are broken down into triangles anyway, so you save a bunch of needless work by doing it once CPU side and then saving the GPU work it would have to do. Triangles are a standard and perfectly fine way of specifying shapes.

  • GL_TRIANGLE_STRIP is faster than GL_TRIANGLES because it takes one point, not three, to specify each triangle after the first triangle is specified. The previous two vertices of the triangle before are used. You get connected triangles, but you also use less memory. Because you have to read less, you can process faster. And because your last two vertices were just specified in the last triangle, they're going to be easier to fetch in memory than two other vertices that may come from who knows where. There are also tricks for using degenerate triangle strips for allowing for seamless jumps between triangles.

If you want the best performance of the three, GL_TRIANGLE_STRIP is the way to go. Unfortunately, unless your data comes already specified for use in a triangle strip, you'll have to order your vertices yourself and remember where to put your degenerate triangles. A good starting point is with height maps (ie terrain). However, optimizing other parts of your code first (eg determining whether to even draw an object) may be a better use of your time. And I may be wrong, I don't think texture use should have an impact on your choice of vertex specification.

Edit: Here is an example of how rendering a square is done with GL_TRIANGLE_STRIP

Vertices: (0,0) (0,1) (1,0) (1,1)

Triangle 1: (0,0) (0,1) (1,0) (1,1)

Triangle 2: (0,0) (0,1) (1,0) (1,1)

Community
  • 1
  • 1
GraphicsMuncher
  • 4,583
  • 4
  • 35
  • 50
  • I have a lot of the optimizations down, Face culling frustum culling etc.. So I'm looking for other stuff that can help.. – Amit Assaraf Jun 02 '13 at 19:28
  • Can you give me an example on the how to render a TRIANGLE_STRIP in 3D as a QUAD? I cant seem to get it right – Amit Assaraf Jun 02 '13 at 19:29
  • What do you mean as a quad? – GraphicsMuncher Jun 03 '13 at 01:08
  • Render a 3D Square with Triangle stips – Amit Assaraf Jun 03 '13 at 09:16
  • While this: *"GL_QUAD_STRIP is deprecated and not supported in the current version of OpenGL"* is true (at least for a core context), this: *"You'd have to use glBegin and glEnd to use that feature"* certainly isn't. Given a compatibility context (which you need for deprecated things anyway), nobody stops you from mixing deprecated (like `GL_QUAD_STRIP`) and non-deprecated things (like VBOs). While the general advice of staying away from deprecated things is of course good, that statement as it stands is plain wrong. By that logic he would have to use `glBegin/glEnd` for his `GL_QUADS`, too. – Christian Rau Jun 03 '13 at 15:07