Is there a compact way to specify solid per-triangle colors when using Vertex Buffer Objects?

I'm drawing a VBO in GL_TRIANGLES mode, and I just draw solid triangles.

Right now I have to create a 4-component color for every single vertex. For each triangle that means 3 colors, which results in a massive amount of 12 values. But all I need is a solid color for the triangle.

Is there a way of "compressing" this amount of data so that -at least in memory- there are just 4 values stored to define the color of a triangle?

Answers


You can call glColor* before you render your triangle. It sets the "current" vertex color, and then you don't need to bother with colors per-vertex.


If its an rgb color you should be able to store it as a single int

Each byte in the int represents a color argb.

You could choose to use the alpha channel or ignore it


Need Your Help

Why can't I cause a seg fault?

c++ segmentation-fault

OK for whatever reason I'm having trouble causing a seg fault. I want to produce one so that I can use gdb to see how to debug one. I have tried both examples from the Wikipedia article yet neither...

Calling function from c++ dll whose argument is a struct and the struct's attribute is a string

java visual-c++ jna

I know how to use the basic type such as int, char*, struct, but I don't know what represents the C++ type string which is a class using jna. I used the String of Java to represent the string of C+...