D3DCOLOR_RGBA macro wrong?
I''m using directx 8 (I know I should use 9 so don''t bother writing just to tell me that).
I''m making a simple program that draws a triangle on the screen (one of those basic learning programs).
I set the all 3 vertex diffuse colors as follows, expecting to see a red triangle...
D3DCOLOR_RGBA(255, 0, 0, 255)
Instead I got a green triangle.
Next I tried the following expecting to get a blue triangle...
D3DCOLOR_ARGB(255, 0, 0, 255)
Instead I got a red triangle.
There are two possibilites that I see...
1) The macros are wrong or backwards or misnamed or something (seems unlikely)
2) My understanding of vertex colors and how they''re rendered is wrong. (seems LIKELY)
Can anyone explain this to me? or does everone use the hex representation instead of the macros?
The macros are correct and you''ve got a mistake in your code. You can verify this by taking the macro out of the equation and just use a DWORD formatted as A8R8G8B8 and see if you get the same result (red = 0xffff0000).
If I had to guess, without seeing any of your code, I''d say that the problem is that your FVF flags don''t match your vertex data.
If I had to guess, without seeing any of your code, I''d say that the problem is that your FVF flags don''t match your vertex data.
Thanks, I will try that out. (Don''t have the code in front of me right now.) I''ll let you know if it turns out to be the macros (by some strange chance).
Do this...
if (0xff00ff00 == D3DCOLOR_RGBA(255, 0, 255, 0)) {
// blah
}
and see if they''re the same
BTW, the macro works fine for me. Maybe your machine is hosed.
if (0xff00ff00 == D3DCOLOR_RGBA(255, 0, 255, 0)) {
// blah
}
and see if they''re the same
BTW, the macro works fine for me. Maybe your machine is hosed.
quote:Original post by aldisd
Do this...
if (0xff00ff00 == D3DCOLOR_RGBA(255, 0, 255, 0)) {
// blah
}
and see if they''re the same
Now I''m confused again. Shouldn''t
D3DCOLOR_RGBA(255, 0, 255, 0) == 0x00ff00ff (i.e. transparent magenta)
or did you mean to type D3DCOLOR_ARGB ?
this probably isnt what you meant, but isnt it
255,0,0,0 for red, 0,255,0,0 for greeen, 0,0,255,0 for blue?
255,0,0,0 for red, 0,255,0,0 for greeen, 0,0,255,0 for blue?
Found my code error...
My vertex format was wrong. (don was right, my vertex data didn''t match my FVF flag) I had the following code...
What''s weird is that my compiler (free command line tools from Borland) didn''t complain about the fact that I was only assigning 3 floats and a 32-bit word to a structure that has 6 floats and a 32-bit word...
In any case removing the "float nx, ny, nz;" line from my vertex structure declaration did the trick.
Thanks for all your help.
My vertex format was wrong. (don was right, my vertex data didn''t match my FVF flag) I had the following code...
typedef struct { float x, y, z; float nx, ny, nz; D3DCOLOR diffuse;} sVertex;sVertex Vertices[4] = { { 0.0f, 0.0f, 1.0f, D3DCOLOR_RGBA(0,255,0,255) }, { 0.0f, 100.0f, 1.0f, D3DCOLOR_RGBA(0,255,0,255) }, { 100.0f, 0.0f, 1.0f, D3DCOLOR_RGBA(255,255,255,255) }, { 100.0f, 100.0f, 1.0f, D3DCOLOR_RGBA(0,255,0,255) },};#define VertexFVF (D3DFVF_XYZ | D3DFVF_DIFFUSE)
What''s weird is that my compiler (free command line tools from Borland) didn''t complain about the fact that I was only assigning 3 floats and a 32-bit word to a structure that has 6 floats and a 32-bit word...
In any case removing the "float nx, ny, nz;" line from my vertex structure declaration did the trick.
Thanks for all your help.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement