Hi Alamar!

    I am running freeglut-2.8.0-r1 on Gentoo linux.

    If I understand what you wrote, then I'd need to take into account the window-manager's non-client area in my calculations, but then the skew should always be off by the same amount. What I am experiencing appears to be progressive/cumulative/always-increasing.

    Here's the reshaping procedure:

void ReshapeFunc( int cx, int cy ) {

    glViewport( 0, 0, cx, cy );
    glMatrixMode( GL_PROJECTION );
    /* Reset world coordinates first ... */

    /* Then set them to what we want based on the new aspect ratio */
    glOrtho( 0, cx, cy, 0, 0, 1 );
    glMatrixMode( GL_MODELVIEW );

    /* Displacement trick for exact pixelization */
    glTranslatef( 0.375, 0.375, 0 );

    glDisable( GL_DEPTH_TEST );

    glClear( GL_COLOR_BUFFER_BIT );

Maybe there is something in there that is incorrect, or only needs to be done once at the start?


On Sat, 2012-10-13 at 19:50 -0400, Alamar's Domain wrote:

I am assuming Windows, because I had the same (or similar) issue, and my situation is also windowed.

The width/height made available in the reshape callback include extra window size information, but I didn't see a portable way to determine those sizes (outside of a define or the like to call windows functions to get various sizes).

For a non-portable solution, I'm just calling GetClientHeight and using those values (on the viewport call, and during calculations for mouse position) instead.

I would love to see a better solution though : )


On Sat, Oct 13, 2012 at 7:32 PM, Jean-Claude Gervais <jc.gervais@videotron.ca> wrote:

When I first start my application, drawing coordinates correspond to mouse-reporting positions, meaning if I hover the mouse at (10,10) and issue a drawing command to draw a pixel at (10,10), the pixel appears right under the mouse pointer.

However, I have recently implemented a reshape function, if I grab the window by its lower-right-hand corner and generate lots of callbacks to the reshape function, the physical drawing coordinates gradually drift away from their original positions toward the bottom and right.

Whatever window size I specify originally, drawing and mouse coordinates line up, but after enough resizing of the window, they progressively drift apart, whether I am making the window bigger or smaller. The mouse-reporting positions seem to stay absolute and correct, but all drawing in the window seems to drift even if I hard-code coordinates.

The application is a simple 2D display.

What should I do to fix this?

Thank you