PDA

View Full Version : Getting Projection Matrix



asimov01
10-08-2009, 02:58 PM
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;
}

James W. Walker
10-08-2009, 04:03 PM
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.

asimov01
10-08-2009, 04:19 PM
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.

asimov01
10-08-2009, 05:24 PM
Solved it. Thanks. Just did a window draw call and magically all the numbers poped up. Thanks.