PDA

View Full Version : glGet



felix82
06-20-2006, 10:35 PM
I cannot for the life of me figure out why glGet is not working for me. To illustrate, I just wrote a quick and dirty tester program:



#include<stdio.h>
#include"GL/glu.h"
#include"GL/gl.h"
#include"stdlib.h"

int main()
{
float* mat = (float*)malloc((16*sizeof(float)));

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glGetFloatv(GL_MODELVIEW_MATRIX, mat);

int i,j;
i = j = 0;

for(;i < 16;)
{
printf("[ ");
for(j = 0; j < 4; j++)
{
printf("%f ", mat[i]);
i++;
}
printf(" ]\n");
}

int mode = 0;

glGetIntegerv(GL_MATRIX_MODE, &amp;mode);
printf("%d \n", mode);
return 0;
} mat remains unchanged, and I get all zeros in the print out.

06-21-2006, 12:19 AM
You need to have a OpenGL render context current before you can call into the API.

felix82
06-21-2006, 09:56 AM
Yeah...I'm so much of a beginner that I don't know what you're talking about. I (obviously) assumed including gl.h would be context enough. What, other initialization would I require?

06-21-2006, 05:13 PM
Check out GLUT:
http://www.xmission.com/~nate/glut.html

It's a nice little wrapper that handles window and context creation for you, among other things like input event notifications. Very easy to install and use. Be sure to read the ReadMe file for instructions on where to put everything. There are countless demos that utilize GLUT, so there is no shortage of examples.

Have a peek at the sticky Wiki, all this is in there, and more.