Triangles or quads

Hi,

I’ve been coding a voxel engine for a couple of months and got it using some standard optimization techniques ( frustum culling, only draw blocks that have no neighboring blocks, only draw faces that can be seen). Now, was wondering, should I change my rendering of blocks to use triangles as opposed to quads? I’ve read that triangles are quicker as the GPU doesn’t have to do any vertex conversion as opposed to splitting quad up into triangles?

Any advice is appreciated,
Thanks,
Steve

Always use triangles.

Cas :slight_smile:

Thanks for that, and is the reason down to speed - I also know quads are supported in OpenGL 3.x

Thanks

Quads are deprecated in GL3+. Almost all drivers will convert to triangles anyways. Just get used to working with triangles, and use index buffers for shared vertices.

They probably won’t provide a huge performance boost compared to things like VBOs/VAOs/instanced draw calls/etc.

Thanks,

I’m using display lists, guess should convert these this to VBO and then use triangle primitives?

My suggestion would be to learn the programmable pipeline. (Display lists are also deprecated.)

But if you don’t want to learn GL3+, then you can stick with fixed-function and quads.

Hi,

I’m ok with shaders etc, come from Direct3D 10. OpenGL I’ve been messing with for around 6 weeks, but started with fixed pipeline, immediate mode then display lists.

Think will convert to VBO’s and triangles as a first go. Any good lwjgl tutorials on VBO’s or any place, I’ve looked at nehe’s.

Thanks

They have to be split into two triangles. It’s possible to construct a non-planar quad that isn’t even flat, and together with the limited precision of floating point positions it’s pretty safe to assume that the 4 vertices won’t lie exactly on the same plane after perspective transformation (I’m talking 3D here). Plus, hardware interpolators only interpolate vertex attributes between the 3 corners of a triangle.

To draw quads use indexed rendering. Use 4 vertices and 6 indices to form 2 triangles using the 4 vertices. That’s what OpenGL does when you render a quad with GL_QUADS under the hood anyway so performance is identical to using GL_QUADS. Quads are also not supported at all on OpenGL ES so it’s a good idea to avoid quads if you have any plan at all to develop for OpenGL 3+ or OpenGL ES.

This is great for vbo’s

http://www.java-gaming.org/index.php?topic=24272.0

And I used this:

http://www.lwjgl.org/wiki/index.php?title=Using_Vertex_Buffer_Objects_(VBO)