Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: glPixelZoom problem

  1. #1
    Guest

    glPixelZoom problem

    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.


    Any ideas?

    Thanks!

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    France
    Posts
    765

    Re: glPixelZoom problem

    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.

  3. #3
    Guest

    Re: glPixelZoom problem

    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.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    France
    Posts
    765

    Re: glPixelZoom problem

    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.

  5. #5
    Guest

    Re: glPixelZoom problem

    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 ?


  6. #6
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    France
    Posts
    765

    Re: glPixelZoom problem

    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).]

  7. #7
    Guest

    Re: glPixelZoom problem

    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).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •