Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

TreborZehn

D3DCOLOR_RGBA macro wrong?

This topic is 5281 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
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...


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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!