View Full Version : glGet

06-20-2006, 09: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:


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

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]);
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-20-2006, 11:19 PM
You need to have a OpenGL render context current before you can call into the API.

06-21-2006, 08: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, 04:13 PM
Check out GLUT:

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.