PDA

View Full Version : Printing out the color value



The Ordinary
11-03-2008, 04:43 AM
Hi

I have a program which im testing and id like to know what is the best way to print out the value of a color to the screen. I am using the GLUT API.

the function that im trying to use is called:
glutGetColor(y, GLUT_RED)
where int y is the value that is sent through from the y mouse coordinate.
id like to print out the color where ever the mouse is situated in the window. but it just prints out -1. i know that the value of 'y' in the glutGetColor() has to do with a cell call? so can i just send through the mouse coordinate into that place? it seems like it doesnt work.

the function im using to get the mouse coordinate is:
glutPassiveMotionFunc(int x, int y)

any help would be wonderful!
thanks

_NK47
11-03-2008, 08:22 AM
i quickly checked that glutGetColor() functions and seems like operating on color indices! do you have a color index window?

dletozeun
11-03-2008, 09:43 AM
I don't know glutGetColor function, you may use glReadPixels (http://www.opengl.org/sdk/docs/man/xhtml/glReadPixels.xml) that seems to do what you want to do.

_NK47
11-04-2008, 06:34 AM
dletozeun: ... you may use glReadPixels that seems to do what you want to do.
actually yeah thats better. never heard of glutGetColor either.


make sure you treat your pixels like the format you read them in, thats maybe the problem.

The Ordinary
11-05-2008, 01:41 AM
I don't know what a color index window is, any help?
i will try to use the glReadPixels now. Thank you for the help

The Ordinary
11-11-2008, 07:19 AM
I came right, thank you