Beyond My Mind

April 22, 2006

A C++ Color class for using with opengl

Filed under: Uncategorized — mahbub @ 9:05 pm

I know this is nothing new. But when I was looking for something similar to C# color class with tons of predefined color values I found one wihich somehow matches with my requirement but that was for MFC. So I took the predefined color codes from that class and added some function for my own purpose. Code project have two of them hosted there. Here are the links:

I will not paste the entire file here, just a portion. The files can be downloaded from here. Let me discuss some of the characterstic of the class

The entire class is inside Mahbub namespace. The Color class has four color components for red, green, blue and alpha. It has a option to store a name for it as well. But the memory is never allocated if no name is specified. You can use random number generator and generate random color from it. I used Mersenne Twister random number generator with it. Also I used a Mathematics wrapper class with it. I will post the Mathematics wrapper class description later. You can download it from here or just replace with appropriate function from math.h.

Here is an example usage of it:

Color a = Color::RED;


If you find it useful or have any suggestion please don’t forget to let me know, udvranto (a) yahoo.

Powered by Qumana

1 Comment »

  1. I want to learn programming perfectly. Which will be the best one for learning in BD? Your site is really a great source for me also.

    Comment by — April 15, 2015 @ 10:00 pm | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: