Jump to content
  • Advertisement
Sign in to follow this  
Dathu

How to make colour to a quad other than RGB.

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

Hi all, I have render one quad by using glBegin()and glEnd(),In that I have taken four vertexes.Before glBegin()I wrote the function glColor3d(),to make the quad colour.Here my question is,I want to make that quad colour other than Red,Green,Blue. can anyone help .....

Share this post


Link to post
Share on other sites
Advertisement
What do you mean by 'other than RGB'? OpenGL works using the RGB color space.
If you are talking about Hue-Sat and Luminance then you just need to write your own conversion matrix to convert that format into RGB before using the glColorX command.
In short - OGL only works in RGB (and newer extensions allow sRGB) anything else requires your own code to conversion code.

Share this post


Link to post
Share on other sites
I am using mfc appwizard dialog in that I have created the opengl window.In that opengl window I render one quad and to fill colour for that quad I used glcolor3d() function.Now question is I want to fill that quad with other than Red,Green,Blue.For this If I made any changes (i.e.values)in glcolor3d function the quad is not changing other than Red,Gree,Blue,Black,White.But I want to fill other than these colours. HOW?

Thanks.

Share this post


Link to post
Share on other sites
You must mix the color channels. E.g.

red = 100
green = 100
blue = 100

is a dark gray.

Best regards,
Porthos

Share this post


Link to post
Share on other sites
red = 1.0
green = 0.0
blue = 1.0

Makes purple. It's fairly easy, in Paint you can get the colour values (in range from 0 - 255). So what you have to do, is pick the number and divide it by 256. Then fill the red, green and blue values into glColor3f().

Share this post


Link to post
Share on other sites
For openGL the RGB values are float values between 0.0 and 1.0. These values are clamped. Typical paint programs display RGB values in the range of 0...255. So conversion is easy - just divide the each RGB component by 255 and use that result in the glColor3f () command.



Share this post


Link to post
Share on other sites
I *could* be wrong but divide by 255. Take the RED component for example. The max value this could have is 255. The Min value is 0. Yep - the range is 256 but
take pure RED - a value of 255. We want this to map to 1.0 - so divide by 255
Pure black in the RED channel is 0 - and when divided by 255 is still 0, so works for that too. If you divide by 256 then pure red is NOT mapping to 1.0

Share this post


Link to post
Share on other sites
Quote:
Original post by BionicBytes
I *could* be wrong but divide by 255. Take the RED component for example. The max value this could have is 255. The Min value is 0. Yep - the range is 256 but
take pure RED - a value of 255. We want this to map to 1.0 - so divide by 255
Pure black in the RED channel is 0 - and when divided by 255 is still 0, so works for that too. If you divide by 256 then pure red is NOT mapping to 1.0


Hmm yes, but it must be divided by 256 somehow, else it will never be right, will it?

Take 127, considered to be grey. 127 / 255 != 0.5

Share this post


Link to post
Share on other sites
Quote:
Original post by BionicBytes
I *could* be wrong but divide by 255. Take the RED component for example. The max value this could have is 255. The Min value is 0. Yep - the range is 256 but
take pure RED - a value of 255. We want this to map to 1.0 - so divide by 255
Pure black in the RED channel is 0 - and when divided by 255 is still 0, so works for that too. If you divide by 256 then pure red is NOT mapping to 1.0


try to thing on base 10.. you have 0 to 9... and divide by 10.
this is just a sort of "base 256", so divide by 256, and you'll be fine, trust me :)

and to answer your division question... you divide by 256 and the remaining is the number for each color.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!