gluUnproject - the matrixes???

Hi,

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??

/grodslukaren

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;

glMatrixMode(GL_MODELVIEW);
glGetDoublev(GL_MODELVIEW_MATRIX, modelviewMatrix); // first error
glMatrixMode(GL_PROJECTION);
glGetDoublev(GL_PROJECTION_MATRIX,projectionMatrix);
glGetIntegerv(GL_VIEWPORT,viewport);
gluUnProject(winx,winy,winz,modelviewMatrix,projectionMatrix,viewport,&objx,&objy,&objz);
//////////////

/grodslukaren

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.

Thanks!!!

That really made it work!!