• Advertisement

Archived

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

Strange RGB Values

This topic is 6521 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

Why why when i Clear the viewport in D3Dim and i set some clearing color i get some strange color, i mean when i set the clear color to RGB(255,0,0) i geting a blue screen and when i set it to RGB(0,0,255) im getting a red screen, hu ??? why??

Share this post


Link to post
Share on other sites
Advertisement
i ran into what appears to be a similar problem when i was learning about how to plot pixels. In 16 and 32 bpp color modes you can't use the RGB macro because the bits in the color value are arranged differently and have either less or more color values(something like that). Check out the programming section of gamedev there are some articles on this.

i don't know about D3D so i can't specifically help you.

Edited by - +AA_970+ on 4/16/00 8:48:09 PM

Share this post


Link to post
Share on other sites
Are you using Visual Basic? If you are then use DX.CreateColorRGB instead. I think that should work.

Share this post


Link to post
Share on other sites
Direct3D IM uses the D3DCOLOR data type to represent colors. You can use the D3DRGB and D3DRGBA macros to create a color for yourself.

Share this post


Link to post
Share on other sites
i tried the D3DRGB and D3DRGBA and with that i getting another problem , when i clear the viewport with Blue color
D3DRGB(0,0,255) i get a GREEN screen...

now this is very very strange...

somebody have good idea?

Share this post


Link to post
Share on other sites
quote:
Original post by Xeno

i tried the D3DRGB and D3DRGBA and with that i getting another problem , when i clear the viewport with Blue color
D3DRGB(0,0,255) i get a GREEN screen...

now this is very very strange...



Ever tried to look at the pixelformat of your surface?
You should write pixels in the format they are expected to be.
The macros only convert to a specific format and do not
change their behavior depending on your pixelformat.
(otherwise they would have been functions, or better,
methods of the surface object)

So if the format says something like ARGB (32 bits)
make sure you write $00ff0000 in there for red.
Also note that colors of a BMP-file are BGR data.

Share this post


Link to post
Share on other sites
So does D3DIM RGB macro Work like BMP file???
because when i use the RGB() macro its working like u saied - BGR.

Share this post


Link to post
Share on other sites
quote:
Original post by Xeno

So does D3DIM RGB macro Work like BMP file???
because when i use the RGB() macro its working like u saied - BGR.


The macro is used to generate D3DCOLORs. Apparently
it generates pixelvalues that are equivalent to the ones
used in a BMP file.

D3DCOLORs are used for the colors of vertices and
stuff. NOT for the contents of a surface.

You have to code a conversion macro yourself for use
inside a surface.

Share this post


Link to post
Share on other sites
Note that the RGB macro is part of the Platform SDK.
So it is used to generate Windows RGB colors, not
D3D colors... RGBA_MAKE creates D3D colors.
Confusing eh?

Share this post


Link to post
Share on other sites
Oh, i understand now.
so i need to make function that generate values like 0xfffffff (White)
to fill my viewport color, or any surface color, and not use the RGB Macros...

am i right?

Share this post


Link to post
Share on other sites
quote:
Original post by Xeno

i tried the D3DRGB and D3DRGBA and with that i getting another problem , when i clear the viewport with Blue color
D3DRGB(0,0,255) i get a GREEN screen...

now this is very very strange...

somebody have good idea?


Errr yeah. The D3DRGB and the D3DRGBA macros take input as
float values ! i.e 0 -> 1. Try that and you should get something correct happening instead of silly colors =)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
yeah!!!
u Right!!!
thanks a lllllllllloooooooooooottttt!!!

but i dont understand something , what 0.5f value mean????
or 0.2 or 0.4????
its not like u can set in integer 255 or 123 etc...

Share this post


Link to post
Share on other sites
opps forgot to enter my login and passwd...
so again:

yeah!!!
u Right!!!
thanks a lllllllllloooooooooooottttt!!!

but i dont understand something , what 0.5f value mean????
or 0.2 or 0.4????
its not like u can set in integer 255 or 123 etc...

Share this post


Link to post
Share on other sites
heh ..

Generally if you look at the macro for D3DRGB you find the
answer:
D3DRGB(r, g, b) \
(0xff000000L / ( ((long)((r) * 255)) << 16) / \
(((long)((g) * 255)) << 8) / (long)((b) * 255))

The value you pass in is multiplied by 255 and you get an
integer back out.
It seems strange, but all your saying really is that you
want a percentage saturation of the colour channel.
Not sure how else to explain it really.

Share this post


Link to post
Share on other sites
Good lord! I never went through that and my program runs fine......in 32 bit color.

Share this post


Link to post
Share on other sites

  • Advertisement