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 5 of 5

Thread: glRasterPos2f && glDrawPixels && Windows Points

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2012
    Posts
    15

    Question glRasterPos2f && glDrawPixels && Windows Points

    Does anyone have an idea on what im missing here?

    Im rastering to the window center point to make sure to stay within my clipping range so my image doesn't disappear when zooming/panning , etc.

    All that works. Image never disappears.

    The problem i am having has something to do with the WindowOrg point. When i pan or zoom, the image slowly is offset from my screen points. Note: Im plotting points manually ontop of the image. When I pan around the points are slowly offset more and more drastically the further i pan around. Im assuming its a conversion issue? Everything else in the program works fine.

    Also, if i Raster to my 0,0 point everything works just fine in terms of zooming and panning until that 0,0 point is outside the clip range then of course the image disappears.

    Code :
       glRasterPos2f(m_pWindowOrg.x,m_pWindowOrg.y);
     
        GLfloat x = (-m_image->width / 2) - (m_pWindowOrg.x);
        GLfloat y = (m_image->height / 2) - (m_pWindowOrg.y);
     
        glBitmap(NULL,NULL,m_image->width,m_image->height,m_fZoomScale * x,m_fZoomScale * y,NULL);
     
        //Inver the image (the data coming from OpenCV is inverted)
        glPixelZoom(m_fZoomScale * 1.0f,m_fZoomScale * -1.0f);
     
        glDrawPixels(m_image->width, m_image->height, GL_RGB, GL_UNSIGNED_BYTE,m_image->imageData);

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264
    The raster position is transformed by the modelview matrix. If you are applying some matrix to your modelview while panning and zooming, then it will effect glRasterPos2f. You might want to load an identity matrix, then call glRasterPos2f.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  3. #3
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    783
    Or call glWindowPos, to avoid exactly this problem.

  4. #4
    Junior Member Newbie
    Join Date
    Nov 2012
    Posts
    15
    Well when i do that the program crashes and i get an Access Expectation error but, i really don't see any debug info...

    glRasterPos2f(m_pWindowOrg.x,m_pWindowOrg.y); //WORKS!!!!

    glWindowPos2f(m_pWindowOrg.x,m_pWindowOrg.y); //CRASHES!!!

    Likewise

    glRasterPos2f(0,0); //WORKS!!!!

    glWindowPos2f(0,0); //CRASHES!!!

    NO i am NOT calling both.... I just used above as an example. I either comment out one or the other.

  5. #5
    Junior Member Newbie
    Join Date
    Nov 2012
    Posts
    15
    I have more info on this....

    The exact error/crash is 0xC0000005 Access Violation

    Doing some Google work its possible its a hardware problem. Not sure yet.

    So, i copied my Release EXE file to another PC and i am not receiving the error but, the glWindowPos does not create the same output as glRasterPos. It seems to move the image to a different part of the screen.....

    So any suggestions on what to do? glRaster works just find short of the image not lining up perfectly with everything else. See my original problem in first post. When i raster to the center of the view screen my image and my drawing are off just a little bit and the more i pan around, the greater the difference. I assumed it was a pixel / screen point problem and i played around there but still could not get it 100%.

Posting Permissions

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