-
color problem
Hello!
I use vertex-colors in my 2D elements of my program.
I thought I understood the what the color is, but it seems I don't. I thought the color consists of RGB values: RRGGBB. So that 0000ff is blue, 00ff00 is green and ff0000 is red. These colors seem to work, but when I combine them something goes wrong. ffffff which should be white is something like this and ffff00 which should be bright yellow is actually like this.
What's wrong with it?
-
And what happens instead? We can probably figure out what is wrong if you give us a short table of
Code:
Value Expected Actual
where "Value" might be 00FF00, and Expected "Green", and Actual "Blue".
--
Mats
-
Code:
Value Expected Actual
ffffff white this
ffff00 this this
00ffff this this
ff00ff this this
It's no point to give more colors. It seems that all colors are darker and I can't give exact colors anyway.
-
Are you storing the colour numbers in a wide enough type? If you stuff "0xff" into a char, for example, you might not get the results you're expecting. An unsigned char would work; or, if you're putting all of the data into one variable, an unsigned long (or unsigned int if you wish I guess).
Beyond that, you might want to post some relevant code.
-
White is not FFFFFF. It is FFFFFFFF.
Most color is expressed as RGBA, ARGB, or XRGB. What you have expressed is XRGB. If you are in a graphics API and you have alpha blending enabled but set alpha to 0.0f you will not get any colors at the vertices.
-
OK, I forgot about alpha, because I don't use it. These colors are for rhw vertices. Nevertheless it seems to make no difference. It seems that ffffff and ffffffff give exactly the same result and the problem remains.
I use DWORDs to store colors.
-
It seems I know the problem now.
D3DPRESENT_PARAMETERS :: EnableAutoDepthStencil
When it is set to TRUE as in 3D it does weird things. I use 3D and 2D rhw simultaneously so I somehow need to change it, but it is not that simple, because it's used in CreateDevice. What should I do? Should I use two separate DirectX devices or is there some other way?
-
Never mind the previous post, that wasn't the problem.
The problem was, that I had to unset the texture, so the 2D elements used the colors of the previously set textures. Colors turned darker, because the texture's color was brown.
Problem solved!