Hey Jean-Claude,

I thought this way is the correct initialization in GL/GLUT.
I'm having the exact same problem on Linux.

If I scale the window up (resizing) the whole viewport and all textures are scaled, not by the same ratio. Then the mouse coordinates are differently scaled up. X coordinate is not as much "far away" from the real target as y is.

Assuming you click at 50% / 50% each time.

100x100 window > resizing to 200x200

- textures are double the size in each dimension, they are correctly scaled up.
- mouse coordinates are at ~90 x 50 pixels, not 100 x 100 as expected.

So it seems as the y coordinate is not multiplied by the additional scaling (skewing) factor. The x coordinate is not correctly scaled up, so it's kind of "close" to the real point, but with a percentage in distance (from top/left corner) to it.


Is there a fix already in the current trunk or does it need to be fixed? Could you give me a hint on where the relevant code in freeglut is, I'll try my best to make a patch :)


~Cheers,
Christoph


On 10/14/2012 03:22 AM, Jean-Claude Gervais wrote:
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 ... */
    glLoadIdentity();

    /* 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?

Thanks!


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


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 : )


-Alamar

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

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




------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev


_______________________________________________
Freeglut-developer mailing list
Freeglut-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freeglut-developer

-- 
-- sent from my Notebook

Christoph Martens
informatics student, former JavaScript engineer at Zynga

creator of Zynga Jukebox, Zynga Speedrun and sslsploit
linux core dev, hardcore v8 hacker, w3c member (webapp, css & svg)


Eleonorenstraße 126 | 55252 Mainz-Kastel | DE-Germany
E-Mail: christoph@martens.ms, cmartensms@gmail.com
Mobile: (+49) 151 / 201 34443
Skype: martens.ms
Web: www.martens.ms