Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Odd behavior when resizing windows

  1. #1
    Intern Contributor
    Join Date
    Dec 2001

    Odd behavior when resizing windows

    Hi all,

    I have added the following to the draw function of the basic_template:


    glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0
    glBegin(GL_TRIANGLES); // Drawing Using Triangles
    glVertex3f( 0.0f, 1.0f, 0.0f); // Top
    glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
    glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
    glEnd(); // Finished Drawing The Triangle
    glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units
    glBegin(GL_QUADS); // Draw A Quad
    glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
    glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right
    glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
    glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left

    Some may notice, that this is directly from NEHE's lesson02

    The odd behavior that I am seeing is that when I resize the window, the objects appear to stretch for some number of pixels, then they snap back to their original size, only to start stretching again as I continue to enlarge the window.

    In GLUT, the objects would grow consistantly in the X and Y plane.

    I bet this is some difference that I am not seeing between the perspective, and viewpoint options between the GLUT and CPW programs but that code appears to be the same.

    Any ideas?


  2. #2
    Junior Member Regular Contributor
    Join Date
    Feb 2002

    Re: Odd behavior when resizing windows

    I tested this using the template. On resizing I believe I notices the problem you had. In the set3DMatrix function there is a call to gluPerspective:

    gluPerspective( 60, windowInfo.width / windowInfo.height, 1, 100 );

    Unfortunately width and height are integers. When I changed the line to:

    gluPerspective( 60, (float)windowInfo.width / (float)windowInfo.height, 1, 100 );

    The problem went away. I'll update this in the samples and template. Lemmie know if this fixes your problem..

    Jim Mathies

    \"The best way to predict the future is to invent it."

  3. #3
    Intern Contributor
    Join Date
    Dec 2001

    Re: Odd behavior when resizing windows

    Thats it!!!

    Thanks Jim. I added a printf to the set3DMatrix so that I could see what was happening. Now I think I understand. It was a rounding issue.

    By the way, this also fixed another odd problem that I forgot to mention. Without the (float) typecast, if the window was higher than it was wide, the objects would just vanish. Again due to rounding.

    Thanks a lot for the help,

Posting Permissions

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