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
    Senior Member Regular Contributor
    Join Date
    Sep 2003
    Location
    Ireland
    Posts
    135

    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,102

    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!

Similar Threads

  1. Replies: 1
    Last Post: 09-04-2014, 10:54 AM
  2. Unit of length in OpenGL
    By HaVyThoai in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 11-16-2007, 01:51 PM
  3. Texture unit 0 blending with Texture unit 1 problem
    By kackurot in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 10-31-2006, 10:16 PM
  4. the ratio of screen pixels and unit length
    By jyoung77 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-26-2005, 04:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean