PDA

View Full Version : glPixelZoom problem



04-17-2003, 11:48 AM
Hi, All -

I'm using the following piece of code to zoom into a background image that takes up the entire length and width of my screen:

//-------------------------------

... after grabbing hDC and hRC...

glMatrixMode( GL_PROJECTION );
glLoadIdentity();

glTranslatef( 0.0, 0.0, 1.0 );

glMatrixMode( GL_MODELVIEW );
glLoadIdentity();

setViewport();
clearBuffers();

... inside the drawBackground() function...

glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );

glPixelZoom( imageXScale, imageYScale );
glRasterPos3i ( x, y, 0 );

glDrawPixels( imageW, imageH, GL_RGBA, GL_UNSIGNED_BYTE, image.GetData() );

... returned from drawing background...

glFlush();
SwapBuffers( hDC );

... release hDC and hRC

//-------------------------------

imageXScale and imageYScale increment by small amounts each time through the function.

Everything works as expected for the first three times I scale the image. On the fourth scale, the screen goes black.

Recall that the background image initially fills the screen and that I want to zoom into that full-screen image... if I start with an image that's less than screen size it will zoom until it fits the window dimensions... then four more times, then black.

http://www.opengl.org/discussion_boards/ubb/confused.gif
Any ideas?

Thanks!

vincoof
04-17-2003, 12:39 PM
Are you sure that the current raster position is valid ?
If the coordinate sent by glRasterPos is outside the screen, the whole bitmap will be rejected.
You can check the correctness of the raster position by getting the GL_CURRENT_RASTER_POSITION_VALID bit with glGetBoolean.

04-17-2003, 12:49 PM
Yeah, I forgot to mention that the glRasterPos is always (0, 0, 0).

???


Originally posted by vincoof:
Are you sure that the current raster position is valid ?
If the coordinate sent by glRasterPos is outside the screen, the whole bitmap will be rejected.
You can check the correctness of the raster position by getting the GL_CURRENT_RASTER_POSITION_VALID bit with glGetBoolean.

vincoof
04-17-2003, 12:59 PM
Are you sure that the raster position is always valid ? Do you never translate / scale / rotate the modelview matrix ?
When your image disappear, is the CURRENT_RASTER_POSITION_VALID bit set or cleared ?

Apart from that, the fact that the zoom makes the image bigger than the viewport should not be a problem. Off-screen rendering is not a cause of error in OpenGL.

04-17-2003, 01:24 PM
Yes, glGetBooleanv( GL_CURRENT_RASTER_POSITION_VALID, &val );
always returns true, even when the screen is black.


Originally posted by vincoof:

When your image disappear, is the CURRENT_RASTER_POSITION_VALID bit set or cleared ?

vincoof
04-17-2003, 09:38 PM
Hmm that is weird.
Now to the configuration : what is your graphics card / OS / driver version / etc ?

[Edit: also have you tried your program on other card / OS ?]

[This message has been edited by vincoof (edited 04-18-2003).]

04-18-2003, 12:46 PM
Found the problem - has to do with how my clipping volume is set.

Thanks for the help.

Susan


Originally posted by vincoof:
Hmm that is weird.
Now to the configuration : what is your graphics card / OS / driver version / etc ?

[Edit: also have you tried your program on other card / OS ?]

[This message has been edited by vincoof (edited 04-18-2003).]