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: how to change the length of a unit?thank you !

  1. #1
    Guest

    how to change the length of a unit?thank you !

    First ,I defined the Orthographic Projection
    gluOrtho2D (0.0 ,(GLdouble)w, 0.0,(GLdouble)h);
    glViewport (0, 0, (GLsizei) w, (GLsizei) h);
    and a window of size 500*500. At last, a unit equals the size of a pixel.But when the window
    become bigger,the unit become bigger too .

    What i want to get is whenever the size of the window is changed ,a unit always corresponds to
    a pixel.any suggestion is appreciative!

  2. #2
    Junior Member Regular Contributor
    Join Date
    Sep 2003
    Location
    Ireland
    Posts
    136

    Re: how to change the length of a unit?thank you !

    you need to do that every time your window dimensions change, with the new dimensions as parameters...

  3. #3
    Guest

    Re: how to change the length of a unit?thank you !

    hello,charliejay ,thank you very much!
    But i still don't know how and where i should modify my program when the window dimensions change,would you please explain that in detail?
    Furthermore,this is transformation part:
    void reshape (int w, int h)
    {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    gluOrtho2D (0.0 ,(GLdouble)w, 0.0,(GLdouble)h);
    glMatrixMode (GL_MODELVIEW);
    }
    Thank you so much!

  4. #4
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,142

    Re: how to change the length of a unit?thank you !

    The code you posted should work as it is.

    Of course, you have to register the reshape function after creating the window:
    glutReshapeFunc(reshape);

  5. #5
    Guest

    Re: how to change the length of a unit?thank you !

    ok,i understand .
    thank you all very much!

Posting Permissions

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