🔒 Locked
glColor3f()
Advertisement
Original Post
glcolor3f
the syntax for this is like any other opengl command
the 3 stands means you need to send 3 values to this function, they are Red Green & Blue, respecively. If it was four it would be RGB and Alpha. the ''f'' means it needs floats, ex. 0.3433242
1.0 is full intensity, 0.0 is no intensity...
so glColor3f(1.0,0.0,0.0); would produce full red
oh ya! u know what this call does? it sets the color for the next vertex you draw. so if you set it to red and draw a triangle it will come out red, or whatever set...
check some examples, thats really the only way to learn, but if you get stuck, post... check out nehe.gamedev.net, some of the intro tutorials will prolly do the trick.
the syntax for this is like any other opengl command
the 3 stands means you need to send 3 values to this function, they are Red Green & Blue, respecively. If it was four it would be RGB and Alpha. the ''f'' means it needs floats, ex. 0.3433242
1.0 is full intensity, 0.0 is no intensity...
so glColor3f(1.0,0.0,0.0); would produce full red
oh ya! u know what this call does? it sets the color for the next vertex you draw. so if you set it to red and draw a triangle it will come out red, or whatever set...
check some examples, thats really the only way to learn, but if you get stuck, post... check out nehe.gamedev.net, some of the intro tutorials will prolly do the trick.
Honestly, if the concept of RGB doesn''t make sense to you, you might want to hold off on OGL stuff for a bit. RGB is a simple thing compared to the maths that you will need to learn to actually do anything with the API. Almost any computer work you EVER do will need to have an understanding of RGB.
Even colors in HTML are set up that way.
Landsknecht
Even colors in HTML are set up that way.
Landsknecht
Maybe I was not clear, it is not the function nor
RGB that I have an issue with. I understand
what the function is, does and its usage.
I just do not understand the usage of 0.0 -> 1.0 (float)
for the RGB colors. I have experience with the normal
RGB color syntaxt (IE: 123,255,98)
-Ron
RGB that I have an issue with. I understand
what the function is, does and its usage.
I just do not understand the usage of 0.0 -> 1.0 (float)
for the RGB colors. I have experience with the normal
RGB color syntaxt (IE: 123,255,98)
-Ron
again, if you would read the MSDN documentation above, i think it would have become quite clear to you.... ahhh, but alas....
you can look at it like this....
1.0f == 255 == brightest.
.50f == 128 == medium.
0.0f == 0 == darkest.
i.e.
glColor3f(1.0f, 0.0f, 0.0f); == a bright red.
glColor3f(0.0f, 0.5f, 0.5f); == medium turquoise.
try playing around with values to see what you get or alternatively, you can use glColor3ub if that's the notation your familiar with....
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
[edited by - jenova on May 24, 2002 11:22:32 AM]
you can look at it like this....
1.0f == 255 == brightest.
.50f == 128 == medium.
0.0f == 0 == darkest.
i.e.
glColor3f(1.0f, 0.0f, 0.0f); == a bright red.
glColor3f(0.0f, 0.5f, 0.5f); == medium turquoise.
try playing around with values to see what you get or alternatively, you can use glColor3ub if that's the notation your familiar with....
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
[edited by - jenova on May 24, 2002 11:22:32 AM]
Great information!
So, their has to be some form of mathmatical formula to convert a standard RGB format to glColor3f() format.
I am one that likes to know how things work, not just understand them so I can use them. I have read the MSDN and scoured the web, but still I am left hungering for something provides information regarding the conversion of standard RGB to the OGL float style
IE:
use this mathematical formula to convert a standard RGB of 128,255,128 to 0.5f,1.0f,0.5f
So, their has to be some form of mathmatical formula to convert a standard RGB format to glColor3f() format.
I am one that likes to know how things work, not just understand them so I can use them. I have read the MSDN and scoured the web, but still I am left hungering for something provides information regarding the conversion of standard RGB to the OGL float style
IE:
use this mathematical formula to convert a standard RGB of 128,255,128 to 0.5f,1.0f,0.5f
ummm.....
255/255.0f = 1.0f
128/255.0f = 0.5f
0/255.0f = 0.0f
so x/255.0f
furthermore, from the MSDN....
Unsigned integer color components, when specified, are linearly mapped to floating-point values such that the largest representable value maps to 1.0 (full intensity), and zero maps to 0.0 (zero intensity). Signed integer color components, when specified, are linearly mapped to floating-point values such that the most positive representable value maps to 1.0, and the most negative representable value maps to –1.0. Floating-point values are mapped directly.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
[edited by - jenova on May 24, 2002 12:03:19 PM]
255/255.0f = 1.0f
128/255.0f = 0.5f
0/255.0f = 0.0f
so x/255.0f
furthermore, from the MSDN....
Unsigned integer color components, when specified, are linearly mapped to floating-point values such that the largest representable value maps to 1.0 (full intensity), and zero maps to 0.0 (zero intensity). Signed integer color components, when specified, are linearly mapped to floating-point values such that the most positive representable value maps to 1.0, and the most negative representable value maps to –1.0. Floating-point values are mapped directly.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
[edited by - jenova on May 24, 2002 12:03:19 PM]
some mathematical formula?!?!!?
0=>0
255=>1
how difficult can this formula be?!
how about this?
float realred = float(stupid0to255red)/255.f;
float realgreen = float(stupid0to255green)/255.f;
float realblue = float(stupid0to255blue)/255.f;
how that was difficult.. i dont even call this formula..
why 255 is stupid? first: its only for 24 or 32bit colors directly the same (soon 40bit colors are there, and 64bit colors next year)
why 255 is stupid? because it has no mathematical meaning.. say white is 1,1,1, if you have something, and multiply it by white, it will be white again..
if i have for example red: (1,0,0) and multiply by white (1,1,1) this results in this:
(1,0,0) * (1,1,1) = (1,0,0) wich is?! red again..
learn some stuff about lighting and you know why 0..1 range is the best for simple stuff like currently done..
"take a look around" - limp bizkit
www.google.com
0=>0
255=>1
how difficult can this formula be?!
how about this?
float realred = float(stupid0to255red)/255.f;
float realgreen = float(stupid0to255green)/255.f;
float realblue = float(stupid0to255blue)/255.f;
how that was difficult.. i dont even call this formula..
why 255 is stupid? first: its only for 24 or 32bit colors directly the same (soon 40bit colors are there, and 64bit colors next year)
why 255 is stupid? because it has no mathematical meaning.. say white is 1,1,1, if you have something, and multiply it by white, it will be white again..
if i have for example red: (1,0,0) and multiply by white (1,1,1) this results in this:
(1,0,0) * (1,1,1) = (1,0,0) wich is?! red again..
learn some stuff about lighting and you know why 0..1 range is the best for simple stuff like currently done..
"take a look around" - limp bizkit
www.google.com
O.K
After looking to the left for the answer and coming to realise it was to the right all is well now.
I was trying to create a over complicated formula to convert RGB to glColor3f(). No clue why I tried to make this so complicated when the answer was so so simple.
r = c/255
r = 152/255
r is now 0.59
After looking to the left for the answer and coming to realise it was to the right all is well now.
I was trying to create a over complicated formula to convert RGB to glColor3f(). No clue why I tried to make this so complicated when the answer was so so simple.
r = c/255
r = 152/255
r is now 0.59
Er...
For a floating-point component ''f'' and an unsigned byte (i.e. 0 to 255) component ''ub'', then ''f = (float) ub / 255.0f''.
Just Plain Wrong
For a floating-point component ''f'' and an unsigned byte (i.e. 0 to 255) component ''ub'', then ''f = (float) ub / 255.0f''.
Just Plain Wrong
Something else to think about:
The 0 to 255 thing only has a basis when you have 8 bits of color for each of R, G, B. If you later expand on it to, for example, 10 bit, you now have a range of 0 to 1023. This throws everything off.
If you simply use a range of 0.0 to 1.0, then it will support ANY bit depth.
Does this help explain the logic?
Landsknecht
The 0 to 255 thing only has a basis when you have 8 bits of color for each of R, G, B. If you later expand on it to, for example, 10 bit, you now have a range of 0 to 1023. This throws everything off.
If you simply use a range of 0.0 to 1.0, then it will support ANY bit depth.
Does this help explain the logic?
Landsknecht
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement