Results 1 to 4 of 4

Thread: Getting Projection Matrix

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    7

    Getting Projection Matrix

    Hi All,

    This is my first post here so please forgive any noobiness. I just started learning openGL couple days ago. I tried to creat a simple program but it seems to not be working. It compiles properly but other then that when I run it, I don't get any output. I am basically trying to compute a projection matrix (i tried both gluPerspective and glFrustum) and then using glGetDoublev to retreive the data.

    It all seems to compile but when I run it, glGetDoublev does nothing. The data buffer is completely empty. I did the calulcations by hand so I know the numbers that should be in the matrix.

    Any help will be appreciated. Here's the code I am using (visual studio 2005).

    int _tmain(int argc, _TCHAR* argv[])
    {
    GLdouble temp[16];

    glBegin(GL_TRIANGLES);
    glVertex3d(100.0,0.0,0.0);
    glVertex3d(0.0,200.0,0.0);
    glVertex3d(-300.0,-400.0,0.0);
    glEnd();

    glMatrixMode(GL_PROJECTION);
    //GLdouble *temp = (GLdouble *) calloc(16,sizeof(GLdouble));

    glLoadIdentity();

    gluPerspective(12.959025,2.3658537,361.0,2696.0);
    //glFrustum(-97.0,97.0,-41.0,41.0,361.0,2696.0);
    glGetDoublev(GL_PROJECTION_MATRIX ,temp);

    temp[0] = 10;

    return 0;
    }

  2. #2
    Senior Member Regular Contributor
    Join Date
    Nov 2004
    Location
    San Diego, CA, USA
    Posts
    122

    Re: Getting Projection Matrix

    You need to set up a window and OpenGL context before you can start calling OpenGL functions. On Windows, this would involve using either the GLUT library or Microsoft's wgl functions.

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    7

    Re: Getting Projection Matrix

    How would I go about doing that?

    I thought that since I don;t need to draw any of this on the screen there is no need to crerat a window.

  4. #4
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    7

    Re: Getting Projection Matrix

    Solved it. Thanks. Just did a window draw call and magically all the numbers poped up. Thanks.

Similar Threads

  1. Replies: 0
    Last Post: 09-16-2015, 03:27 PM
  2. Using modelview/projection matrix to do a projection myself
    By AllForum in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-30-2012, 07:42 AM
  3. OpenGL Projection matrix to intrinsic matrix
    By Elimentz in forum OpenGL: General
    Replies: 18
    Last Post: 10-20-2011, 06:26 AM
  4. Projection matrix, arbitrary projection plane
    By omdown in forum OpenGL: General
    Replies: 0
    Last Post: 04-01-2010, 07:26 AM
  5. Can concatenate projection matrix with viewport transformation matrix?
    By MelvinEng in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 07-07-2002, 10:31 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