Color different?

We are having some problem regarding color index. We have an user defined palette of 67 colors.

Case 1: Set the mode to RGBA in the pixel formatDescriptor. Draw a line setting color with glColor3ub

Case 2: Set the mode to Color Index in the pixel formatDescriptor. Draw a line setting color with glIndex.

The output in the above two cases differ slightly in color when the index corresponding to the same colorref variable is refered in the glIndex.

It depends on what you mean with “slightly”. It can be a slight difference with color index mode since the VGA standard only uses 6 bits of each R,G and B in the palette.

Hi their,
Let me explain you the problem in detail.
I am trying to draw both GDI and OpenGL figures in a single window. GDI is in RGB mode. OpenGL is in Color Index mode. For both, i am using an user defined palette.

Hope so far is understood.

Step1:- Fill the window background using FillRect by passing a brush created with an equivalent colorref of a color taken from the palette.
Eg: sb = CreateSolidBrush(0xc0c0f0);
where 0xc0c0f0 is a eqivalent to color index 17 in the palette.

Step2:- For opengl set the index to 17 and draw a filled rectangle.

Now if you check the output you can see a slight difference in the background color and the rectangle fill color, even though i am using the same color for both.

I tried this in an NT with 65536 colours.

Hope you got the problem.

Is this because of what you mentioned earlier or some thing else.?

Well … now i understand the situation a little better, and what i mentioned above shouldn’t have anything do to with your problem … but i don’t have any answer to why the problem occurs, sorry …

Maybe this has something to do with OpenGL bleding something? Or a lighting effect?
if these are disabled, I haven’t got a clue either.


Hi john,
I tried enabling light and blending, still its not working. The problem comes only if you run the program in NT machine with 65536 colors.