Jump to content
  • Advertisement
Sign in to follow this  
FutureCode

And, what is the origin of GetRValue series?

This topic is 2993 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 just used GetRValue to a D3DCOLOR, and I got the B value.
Is the data format of D3DCOLOR different from that of COLORREF?
And is there any macros used to get the R value of the D3DCOLOR?
((BYTE)((rgb)>>16) works, but it's not so beautiful. Must I create my own macro in every program?)

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Is the data format of D3DCOLOR different from that of COLORREF?

Yep. D3DCOLOR components are in byte order left-to-right: alpha, red, green, blue. COLORREF: alpha, blue, green, red.

So GetRValue for a D3DCOLOR does, indeed, return the blue vs red value.

I don't think there are built-in macros for accessing individual D3DCOLOR components. You could add yours to your d3d9types.h file if you're adventuresome.

Quote:
((BYTE)((rgb)>>16) works, but it's not so beautiful.

Actually, that's pretty close to (the opposite of) what's done to construct COLORREFs and D3DCOLORs. Take a look at d3d9types.h for the various D3DCOLOR "constructor" macros.

E.g.,
#define D3DCOLOR_ARGB(a,r,g,b)     ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))


EDIT: COLORREF is actually part of GDI and doesn't address the alpha value (which is rarely if ever used in GDI). So you're mixing GDI and DX. That's okay if you're careful, but using your own macros for DX is probably better as it's safer against revisions of GDI vs DX, etc.

[Edited by - Buckeye on July 12, 2010 9:11:42 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!