Results 1 to 10 of 27

Thread: Ortho Setup

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    877

    Ortho Setup

    Hey,

    I need to get (OpenGL) ortho working... This is what I do to set it up..., well, this is practically the only thing I do but to draw:
    Code:
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glOrtho(0, width, 0, height, -1, 1);
    -It seems to work at first, but something... just doesn't look right...
    -Everyrthing's stretched that's what!! Eeek!!

    It apears as if OpenGL thinks the window is a square (same width as height), but since the width is larger than the height everything apears stretched...
    And when I draw a square in just front of the "camera" it takes up the whole window's though it should end before the window's x-borders...

    Everything apears to work as it should exept that it is stretched.
    Does anyone know why this might happen?

    Thanks!
    Last edited by EvilCookie; 08-08-2006 at 10:22 AM.

  2. #2
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    877
    Hmmm... nooo... everything got black...

  3. #3
    Join Date
    Oct 2005
    Location
    Australia
    Posts
    753
    Sorry, try this:

    Code:
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    
    float ratio = width / height;
    
    glOrtho(-100.0 * ratio,   100.0 * ratio,
               -100,          100.0,
                1.0,  -1.0);
    
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  4. #4
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    877
    nope... black...

    Edit: maybe someone has an extremly simple example of orthographics that works that I could take a look at...?
    Last edited by EvilCookie; 08-08-2006 at 02:26 PM.

  5. #5
    Join Date
    Oct 2005
    Location
    Australia
    Posts
    753
    Grab a copy of OpenGL Super Bible 3rd Edition by Richard Wright - has EVERYTHING you need to know plus code. Goes into great detail. Buy this one book if nothing else.

    From memory, I think you can also download the Red and Blue books from http://www.opengl.org

    Could you post your complete code here so I can have a look and compile to see what's up?
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  6. #6
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    877
    There's a "blue book" too?? I've only got "the red book".

    Quote Originally Posted by wozdac
    Could you post your complete code here so I can have a look and compile to see what's up?
    -Well it's accually an empty OpenGL-window... every attempt to make Ortho work has been a modify to the code, since it hasn't worked I've changed it back...

    Though I could send you the code, even if it's not any ortho-stuff yet, for you to look at and tell me what to do? Dunno...

    Well if so here it is...

    In SetupGLWindow.h this is what I've been trying to modify:
    Code:
    // === Set Viewport... and stuff... ===
    glViewport(0, 0, res_x, res_y);
    glDepthFunc(GL_LESS);
    glEnable(GL_DEPTH_TEST);
    glShadeModel(GL_SMOOTH);
    glMatrixMode(GL_PROJECTION);
    gluPerspective(45.0f, (GLfloat)res_x/(GLfloat)res_y, 0.1f, 100.0f);
    glMatrixMode(GL_MODELVIEW);
    (Note that I... for some reason call the variables res_x and res_y, and not width/height, otherwize the resolution is set to 640x480)
    -The other stuff, like the drawing, is in MainLoop.h.
    Attached Files Attached Files

Posting Permissions

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