PDA

View Full Version : do i have any problem on glDrawPixels()?



wusheng
08-18-2004, 07:18 PM
I have setup an array of 400*400 in the memory.Each element of the array is a voxel(each voxel contains three unsigned int,representing the red, green, and blue color respectively)
Then, I want to display the array in an opengl window that has been constructed.However, after I called the function glDrawPixel(400,400,GL_RGB,GL_UNSIGNED INT,pImage),nothing was displayed.What would be the problem?Can anyone help me?Thanks
//the default position of raster is (0,0);
glDrawPixels(400,400,GL_RGB,GL_UNSIGNED INT,m_Image.pImage);
//Is there any problem? how i need to set the glOrhho()?and how about the glViewport()?
I want to display the picture in an opengl window that has been constructed.

Bob
08-18-2004, 11:15 PM
Do you use the whole range of an unsigned int in your image? OpenGL maps integer color values so that the maximum representable value maps to maximum intensity. For unsigned ints, that means the entire color range is from 0 (black) to ~4.2 billion (white, or maximum intensity).

wusheng
08-19-2004, 12:58 AM
If the problem lies in the wrong use of the unsigned int, I guess the values I set to the elements will approximately equal to zero when changed to the range of [0.0,1.0].Then, when I change the background of the window to white,a black image would display on the "white canvus".But in fact, nothing happened.
Am I right? I am not sure.Thanks.

Bob
08-19-2004, 01:53 AM
Yes, you are correct that you should get a black image if you only use a small fraction of the full range. For example, if you use unsigned integers, but only use colors in the range [0, 255] (an unsigned byte), when converted to the range [0, 1], you effectively get the range [0, ~0.0000006]. So a white clear color should give you a white background with a black square where the image goes.

Is the raster position correct then? If you set it explicitly, make sure it's valid. If you don't set it anywhere, the default is the lower left corner and it a valid position, so no need to worry about it then.

If the raster position is not a problem, you have to provide more details about what you're doing. There's nothing wrong with the calls to glDrawPixels as you posted them, assuming the parameters passed matches the actual image.