OpenGL 3.1 - Color per polygon

Hello,
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?

No. That’s why I asked for some “indexing per attribute” mechanism in a future version of OpenGL:

http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=265744#Post265744

See the end of the post for a non-optimal workaround with the current OpenGL limitations, given by Ilian Dinev.

Thanks,

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.

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.

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?

Inside the shader you select which varyings are “flat”. Thus the combinatorial explosion that gives you flexibility.

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…

Read the GLSL1.5 spec.

Sure, but my card (ATI) only supports OpenGL 3.1 with 1.4 GLSL

Okay, the glsl1.4 spec then