Results 1 to 6 of 6

Thread: glOrtho question

  1. #1
    Member Contributor
    Join Date
    May 2002
    Location
    Irvine, CA, USA
    Posts
    51

    glOrtho question

    Okay, here's a simple question. What really goes on in glOrtho ()? I'm looking at this url: http://www.opengl.org/developers/documen...ortho#first_hit

    However, when it attempts to describe how the matrix is setup, the numerators are all missing... which doesn't help.

  2. #2
    Member Contributor
    Join Date
    May 2002
    Location
    Irvine, CA, USA
    Posts
    51

    Re: glOrtho question

    Well, I found my answer here: http://msdn.microsoft.com/library/de...unc03_8qnj.asp

    However, I'm still a bit confused. Since I can't find out how to read matrix from the opengl stack (is it possible?) I managed to initialize a vertex shader and setup its trackview to store the projection into register c[0]-c[3] and inspected; I found that the matrix produced by glOrtho () was diffrent than the one that I setup. I'm not sure what I'm doing wrong... here's some sample code:

    void mSetOrthographic (int left, int top, int right, int bottom, float n, float f)
    {
    float fTerm1 = 2.0f / (right - left);
    float fTerm2 = 2.0f / (bottom - top);
    float fTerm3 = 2.0f / (f - n);
    float fTerm4 = (float) -(right + left) / (float) (right - left);
    float fTerm5 = (float) -(bottom + top) / (float) (bottom - top);
    float fTerm6 = (float) -(f + n) / (float) (f - n);

    tMtx4x4 &m = fProjectionMtx.mGetMtx4x4();
    m[0][0] = fTerm1; m[1][0] = 0.0f; m[2][0] = 0.0f; m[3][0] = fTerm4;
    m[0][1] = 0.0f; m[1][1] = fTerm2; m[2][1] = 0.0f; m[3][1] = fTerm5;
    m[0][2] = 0.0f; m[1][2] = 0.0f; m[2][2] = fTerm3; m[3][2] = fTerm6;
    m[0][3] = 0.0f; m[1][3] = 0.0f; m[2][3] = 0.0f; m[3][3] = 1.0f;

    fProjectionMtx.mSet3x4Flag( kFalse );

    Any idea what I'm doing wrong?

  3. #3
    Member Contributor
    Join Date
    Jan 2002
    Location
    Stockholm, Sweden
    Posts
    74

    Re: glOrtho question

    Microsoft's opengl documentation is not that inspiring - you should really get the redbook, pref. paper editon so you can study even without a computer (ie in bed, when walking, etc). You can get an older version online: http://www.opengl.org/developers/doc...ion/specs.html

  4. #4
    Member Contributor
    Join Date
    May 2002
    Location
    Irvine, CA, USA
    Posts
    51

    Re: glOrtho question

    I have the redbook, but it doesn't explicitly say what the output of glOrtho () is.

  5. #5
    Member Contributor
    Join Date
    Nov 2002
    Location
    Torun/Poland
    Posts
    58

    Re: glOrtho question

    I think that to get matrix from OpenGL stack simply use
    glGetFloatv(GL_MODELVIEW (or GL_PROJECTION) , matrix]); where matrix is a float[16]

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: glOrtho question

    The redbook gives all the formulas used for glOrtho, glFrustum, glRotate, glTranslate, glScale, etc. in an appendix at the back of the book.

    Also, I believe all the formulas used for anything OpenGL related can be found in the OpenGL specification. You can find a link to that somewhere from the main site here, under Documentation.

    [This message has been edited by Deiussum (edited 12-12-2002).]
    Deiussum
    Software Engineer and OpenGL enthusiast

Similar Threads

  1. glOrtho
    By minidrive in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 02-27-2013, 09:44 PM
  2. Replies: 0
    Last Post: 01-21-2005, 06:06 AM
  3. glortho
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-15-2002, 12:15 AM
  4. glOrtho aspect ratio question?
    By ironduke in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-11-2000, 08:31 AM
  5. glOrtho aspect ratio question?
    By ironduke in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 09-10-2000, 11:46 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