View Full Version : Trying to get rid from immediate mode
03-05-2011, 10:55 PM
I'm trying very hard to get rid from the immediate mode of drawing, since this is the slowest method. The problem is I have a Mac Book Pro with a GeForce 320M that supports OpenGL 2.1 (GLSL 1.2).
The problem I'm facing force me to have an ID for each triangle that I draw. This is easy solved using the immediate mode and glUniform variables. But, trying to write my code using VBO's and vertex arrays came the problems.
The uniform variables can only be set once per shader execution (using vertex arrays)
In GLSL 3.3 there's the flat qualifier that tells the fragment shader to not interpolate values, so I could set the same value for each vertex of the triangle and I'd have a single value for the fragments of the triangle.
This can be done with GLSL 1.2?
One could suggest that I use some system with OpenGL 3.2 or heigher, but I need to develop in my laptop, it's the only system I have for now.
Thanks in advance
03-06-2011, 09:29 AM
The problem is I have a Mac Book Pro with a GeForce 320M that supports OpenGL 2.1 (GLSL 1.2). The problem I'm facing force me to have an ID for each triangle that I draw.
Yes, as you're alluding with the mention of the "flat" qualifier, one way to provide this "triangle ID" to your shader is with a vertex attribute. Then there isn't a state change required between each triangle because you can just batch a bunch of them together. Couple choices there. If you are drawing GL_TRIANGLES, you could specify the same value for all verts in a tri for that attribute. In which case you don't even need the "flat" qualifier (if you use a float attribute type in your shader). OTOH, if you're doing GL_TRIANGLE_STRIPs, you might actually want to use flat so that the value for the entire tri is set by the value of the attribute at one specific vertex.
Also worth checking whether your GL 2.1 box supports any of these extensions: ARB_draw_instanced, EXT_draw_instanced, or ARB_instanced_arrays. If so, you have even more options.
03-06-2011, 09:54 AM
Thanks Dark Photon,
I'm going to "use vertex attribute" way, guess this will be more easily implemented, I'll take care of redundant data later.
03-06-2011, 11:59 AM
The problem is I have a Mac Book Pro with a GeForce 320M that supports OpenGL 2.1 (GLSL 1.2).
GT 320M is an OpenGL 3.3+ compatible card ("+" means almost all 4.1 extensions are supported, but none of 4.0). So the compatibility problem is not in the graphics card, but in OS/drivers!
ARB_draw_instanced is an OpenGL 3.1 extension, so it is very unlikely that draw_instanced is supported by your OS.
03-06-2011, 12:33 PM
Aleksandar, I think that GeForce 320M is different from GT 320M.
But, do you have a link with info about opengl support for the 320M card?
03-06-2011, 12:53 PM
GeForce 320M and GT 320M are the same cards, or I have a really serious problem in identifying NV hardware . :)
I don't have the link, but you can consult mighty Google.
I've got 8600M GT on my laptop and I have 100% GL 3.3 compatibility and 63% of GL 4.1 compatibility with 266.58 drivers. My video card is several generations older than yours. Do you need more proofs? :)
03-06-2011, 01:11 PM
So, if I have the newest driver installed, when I query for the OpenGL version using glGetString( GL_VERSION), I'll get something like
I my current system this is 2.1 NVIDIA-1.6.26
03-06-2011, 02:29 PM
If you are using MacOS then you are doomed to GL 2.1.
Take a look at some posts on this forum (e.g. OpenGL 4.0 and Mac (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=277664#Post2776 64) )
That's what I meant with OS/driver problem.
On MS Windows it is quite easy to get the latest functionality.
It is as easy as you said.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.