View Full Version : Color Questions

11-10-2010, 05:50 PM

I am working on converting a simple VC++ game with colored blocks on the screen (not tetris). The Windows program was coded using MFC. My goal is to port the program over the Xcode and OS X. Most of the program code is pretty simple to convert; however, I'm stumped on something that I thought would be very simple.

In several functions in the original program the return type is a color reference (COLORREF). There is also a variable declared as type COLORREF. Essentially, the COLORREF object is a unsigned integer value representing the color.

Is there something in OpenGL that corresponds to COLORREF?


11-11-2010, 12:11 AM
A pointer to 4 component GLubyte ?
Look at the glColor4*v here :

11-11-2010, 04:43 AM
I had originally considered using glColor3f. However, when I declare a variable or a function using it ...

glColor3f m_arrColors[4];

I receive the following error: "glColor3f does not name a type."

#include "Cstdlib"
#include "CSSameGameBoard.h"
#include "GLUT/glut.h"
#include "OpenGL/gl.h"
#include "OpenGL/glu.h"
#include "math.h"

11-11-2010, 05:38 AM
Ventre Saint-Gris.

What to say ... maybe try to learn the basics of C programming ? And then actually read the documentation I linked ?

glColor3f is a *function* not a *type*, as you compiler said. GLFloat is the type.

Try this instead :

GLfloat myColor[4];
// do not forget to fill color component with values between 0.0 and 1.0, example :
myColor[0]= 0.5; // red value
myColor[1]= 0.1; // green value
myColor[1]= 0.9; // blue value
myColor[3]= 1.0; // alpha value (1 is opaque, 0 transparent, not sure if you need it)
// say to opengl "from now, draw with myColor !"