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

What are the key considerations when creating a web crawler?

web-crawler

I just started thinking about creating/customizing a web crawler today, and know very little about web crawler/robot etiquette. A majority of the writings on etiquette I've found seem old and awkwa...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.