View Full Version : OpenGL 3.1 - Color per polygon
10-28-2009, 04:33 AM
I'm using a VBO for holding vertex information, IVBO to avoid putting the same vertex more then once in my VBO, and a VAO to remember all my attribute pointers.
The question I have is definitely a very basic one. Is it possible using the stuff I mentioned above, to create a rubicube, holding only 8 vertexes in VBO, or do I have to hold 24(each vertex in 3 copies - one for each color)?. Is it possible to somehow assign colors to polygons instead of vertices?
10-28-2009, 07:31 AM
No. That's why I asked for some "indexing per attribute" mechanism in a future version of OpenGL:
See the end of the post for a non-optimal workaround with the current OpenGL limitations, given by Ilian Dinev.
10-28-2009, 08:26 AM
That feature would definitely be welcome. The workaround is sound, but it requires to choose either Color per polygon, or Color per vertex for the whole project, and I'd like to be able to choose the coloring method as needed, so I'll have to stick to having more vertices. It sucks that it's not implemented though.
10-28-2009, 08:38 AM
The workaround is sound, but it requires to choose either Color per polygon, or Color per vertex for the whole project
Uh, no. You can have any number of flat and interpolated varyings this way, so maximum freedom is easily possible out of the box. The code given there rearranges indices and merges data for you, for immediate use. Out of the box. Plug and play.
Also, there are always geom-shaders, for immense flexibility.
10-28-2009, 09:07 AM
This forces me to admit, that I must have not understood it.
Weren't you suggesting to use the first vertexes attribute(color, normal, whatever) of the primitive as the primitives attribute?
10-28-2009, 09:33 AM
Inside the shader you select which varyings are "flat". Thus the combinatorial explosion that gives you flexibility.
10-28-2009, 09:47 AM
And I inform the shader by passing a vec1 variable to it?
It seems I'll have to get a better understanding of shaders to do this, because as of now, I only used them to process vertices...
10-28-2009, 10:07 AM
Read the GLSL1.5 spec.
10-28-2009, 11:47 AM
Sure, but my card (ATI) only supports OpenGL 3.1 with 1.4 GLSL
10-28-2009, 11:57 AM
Okay, the glsl1.4 spec then
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.