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(" ]

    int mode = 0;

    glGetIntegerv(GL_MATRIX_MODE, &mode);
", mode);
    return 0;

mat remains unchanged, and I get all zeros in the print out.

You need to have a OpenGL render context current before you can call into the API.

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?

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.