Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (636)
Games in Android Showcase (178)
games submitted by our members
Games in WIP (687)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Triangles or quads  (Read 1640 times)
0 Members and 1 Guest are viewing this topic.
Offline steg90

Senior Devvie

Medals: 2

« Posted 2013-04-26 10:11:11 »


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,
Offline princec

« JGO Spiffy Duke »

Medals: 625
Projects: 3
Exp: 16 years

Eh? Who? What? ... Me?

« Reply #1 - Posted 2013-04-26 10:36:55 »

Always use triangles.

Cas Smiley

Offline steg90

Senior Devvie

Medals: 2

« Reply #2 - Posted 2013-04-26 10:51:58 »

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


Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline davedes
« Reply #3 - Posted 2013-04-26 14:26:04 »

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.

Offline steg90

Senior Devvie

Medals: 2

« Reply #4 - Posted 2013-04-26 15:10:56 »


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

Offline davedes
« Reply #5 - Posted 2013-04-26 15:44:31 »

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.

Offline steg90

Senior Devvie

Medals: 2

« Reply #6 - Posted 2013-04-26 17:40:01 »


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.

Offline theagentd

« JGO Bitwise Duke »

Medals: 594
Projects: 4
Exp: 8 years

« Reply #7 - Posted 2013-04-26 18:37:42 »

Almost all drivers will convert to triangles anyways.
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.

Offline Vermeer

JGO Coder

Medals: 16

« Reply #8 - Posted 2013-04-26 18:53:14 »

This is great for vbo's

And I used this:
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Dwinin (71 views)
2015-11-07 13:29:08

Rems19 (80 views)
2015-10-31 01:36:56

Rems19 (74 views)
2015-10-31 01:32:37

williamwoles (106 views)
2015-10-23 10:42:59

williamwoles (92 views)
2015-10-23 10:42:45

Jervac_ (106 views)
2015-10-18 23:29:12

DarkCart (134 views)
2015-10-16 00:58:11

KaiHH (116 views)
2015-10-11 14:10:14

KaiHH (156 views)
2015-10-11 13:26:18

BurntPizza (171 views)
2015-10-08 03:11:46
Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48

Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!