PDA

View Full Version : OpenGL 3.1 question regarding GL_QUADS



nullsmind
05-20-2009, 10:41 PM
I was just about to write a 2D RPG on Windows using OpenGL 1.1-1.4 to suffice for the common denominator of computers. I was going to use GL_QUADS for sprite rendering but I heard some word that it is deprecated in OpenGL 3.1? If I use OpenGL 2.1 and below, is this a worry? Will it still work if a user has OpenGL 3.1? Will all previous applications using OpenGL's deprecated functions suddenly not work?

What I am hoping for is if an application does not declare it will render with OpenGL 3.1, then all the deprecated functions will work properly. As the opposite: If the application declares it is using OpenGL 3.1, then they cannot use the deprecated functions.

So am I right? I liked using GL_QUADS previously for writing sprites. I am aware of GL_TRIANGLE_STRIP but I would have to rewrite what was once reusable code. Any ideas would be good, thanks.

scratt
05-20-2009, 11:51 PM
QUADS are deprecated in 3.x
AFAIK, basically the hardware always made QUADS into triangles anyway as that's how it works internally.

A very simple way to replace them is with Tris, as you mention.
Since I have prepped for GL3.x and onwards I have replaced QUADS everywhere with Triangles, or Triangle Strips. It's really very trivial to do. :)

Most mainstream drivers in 3.x HW allow you to keep the deprecated model running alongside the main API, so you could choose to simply use deprecated systems for now.. and the foreseeable future.

btw, If you have geometry shaders it's worth making your own Point Sprites which create geometry as triangles from a single vertex. Also bear in mind that traditional Point Sprites are still around too, but come with the usual size restrictions.

overlay
05-21-2009, 07:02 AM
If you have isolated quads, I found easier to go with triangle fans of 4 points than with triangle strips of 4 points because the point ordering matchs between quads and 4-points triangle fans:

quad: 0,1,2,3 (v0=0,v1=1,v2=2,v3=3)
3-2
| |
0-1

triangle fan: 0,1,2,3 (v0=0,v1=1,v2=2,v3=3)
3-2
|/|
0-1

triangle strip: 0,1,3,2 (v0=0,v1=1,v2=3,v3=2)
3-2
|\|
0-1

By the way, you can apply this remark too for going from GL_POLYGON to GL_TRIANGLE_FAN. The ordering is the same, and the triangulation will look like this (image from here (http://www.themathlab.com/dictionary/twords/triangulation.gif), vertex 0 is the one with all the red lines on it):
http://www.themathlab.com/dictionary/twords/triangulation.gif