PDA

View Full Version : Converting GLint to GLubyte



bumby
06-03-2003, 11:51 AM
Hello,

I am using readpixels to gather pixel data. I want to be able to go through the pixel map and test certain pixels against the background color so that that i can make some of the image show the background through it.

The problem I am having is that if I get the clear color using glGetIntegerv it returns a signed integer for the value.

But if I use GL_INT in readpixels, the performance is too slow, GL_UNSIGNED_BYTE works best. I need to be able to convert? the ints returned by glGetIntegerv to GL_UNSIGNED_BYTE.

Unfortunately the application I am working with is pretty big (meaning the color value is used for alot of other areas that require the integer type), so it is not possible to store the color as a unsigned byte first.

Anyone have any ideas?

[This message has been edited by bumby (edited 06-03-2003).]

bumby
06-03-2003, 12:36 PM
never mind....

tried to make it more complicated. I just converted it myself..

But it makes me wonder, why would glGetIntegerv(GL_COLOR_CLEAR_VALUE) return a signed number?

kehziah
06-04-2003, 06:31 AM
It does not return a single value. It returns an array (or vector, hence the 'v'), containing red, green, blue and alpha clearcolor values.

bumby
06-05-2003, 05:50 AM
ok,

then why would it return an ARRAY http://www.opengl.org/discussion_boards/ubb/smile.gif of signed values?

06-05-2003, 06:11 AM
glGetIntegerv is used for more than returning the clear color, and some of these other values can be negative. In C++, the return type cannot be changed at runtime (it is not a dynamically typed language). Therefore, it must return a signed integer. Much to learn, have you. http://www.opengl.org/discussion_boards/ubb/wink.gif

bumby
06-05-2003, 06:41 AM
I guess I should have been more clear.... http://www.opengl.org/discussion_boards/ubb/biggrin.gif

I was merely wondering why they dont have something that would return a value in the same format that a value is input.

I mean, if GL requires floats clamped to 0,1 for something like clearcolor, why dont they have something that would return an unsigned value back...

I know that glIntegerv returns a signed int.

What I was trying (and failing) to wonder was why there is no glGetUnsignedIntv or something like that.