Results 1 to 4 of 4

Thread: size of screen depends on what?

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2011
    Posts
    24

    size of screen depends on what?

    hello sir

    i m trying to know how size of window i.e. height and width

    and gluOrtho effect the unit of translation in opengl

    i.e size is width=500,height=500 and glOrtho(-4.0,4.0,-4.0,4.0,-30,30);
    and if i write glTranslatef(-4.0,0.0,0.0);
    then object will go to right end of window
    but if we give width =800 and height =500
    then same object will not go to at end


    i m not getting the relation ..
    thanks

  2. #2
    Senior Member Regular Contributor
    Join Date
    Oct 2010
    Location
    France
    Posts
    458

    Re: size of screen depends on what?

    Forgot about glViewport ? Change the viewport too any times your window size changes.

  3. #3
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    Re: size of screen depends on what?

    void glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal);

    That is the definition of glOrtho. It defines a parallel projection matrix using what ever values you like.
    Typically you would use this to define a "2D" overlay to your main scene. If you want that then you'd typcially like to use a convienient x and y coordinate scheme. I find using the window width and height convienient as so endup with:

    Code :
    glviewport (0,0,width,height)
    glMatrixMode (GL_PROJECTION)
    glLoadidentity
    glOrtho (0,0, width, height, 1, 100) 
    glMatrixMode (GL_MODELVIEW)
    glLoadidentity

    which means that (0,0) is the bottom left corner of the window and (width,height) is the upper right corner.

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2011
    Posts
    24

    Re: size of screen depends on what?

    if i will do this then unit size of translation will change with it ?...

    i used it but i didn't get proper solution to my problem...

    eg...glTranslatef(1.0,0.0,0.0);

    will the length taken in one unit movement (in x direction here) will change with change in view port size??
    thanks

Similar Threads

  1. how to get screen size in openGL
    By helperyadav in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 03-03-2009, 02:56 AM
  2. API for finding screen size
    By freddie in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 06-15-2008, 12:48 PM
  3. Object size on the screen
    By dvm in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-26-2004, 03:56 PM
  4. screen & windows size
    By vemer in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-17-2003, 08:51 AM
  5. CS Screen Size Problem
    By in forum OpenGL: User Software
    Replies: 1
    Last Post: 06-25-2002, 11:34 AM

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