gluUnproject - the matrixes???


When I use gluUnproject I have to use three matrixes, ModelMatrix, ProjMatrix and viewport. Theese matrixes are the matrixes I change with glTranslate() and glRotate()???

Am I right?? and in that case, how can I use them as variables in gluUnproject()?? Anybody have an example on gluUnproject??


I think I have it now. But it still makes me get errors. And I end up in the assembler when I´d like to see my errors…

What´s wrong with this code?? I get errors just by “asking” for modelviewmatrix with glGetDoublev(GL_MODELVIEW_MATRIX, modelviewMatrix);

GLdouble* modelviewMatrix = 0;
GLdouble* projectionMatrix = 0;
GLint* viewport = 0;
GLdouble winx,winy,winz;
GLdouble objx, objy, objz;

glGetDoublev(GL_MODELVIEW_MATRIX, modelviewMatrix); // first error


You have to provide the memory for the matrix to be copied to. For example, change GLdouble* modelviewMatrix = 0; to GLdouble modelviewMatrix[16]; and similarly for the other matrix, and viewport.


That really made it work!!