tags:

views:

146

answers:

1

Hi,

The following piece of code gives me an error and I'm not able nor to round it ,neither to understand it .

enter code here

GLdouble objX,objY,objZ;
GLdouble modelview1[4][4], projection1[4][4];
GLint viewport1[4]; 
glGetDoublev( GL_MODELVIEW_MATRIX, *modelview1 );
glGetDoublev( GL_PROJECTION_MATRIX, *projection1 );
glGetIntegerv( GL_VIEWPORT, viewport1 );

gluUnProject(x, y, z, modelview1, projection1, viewport1,  objX , objY ,  objZ);`

the error :

`Error 1 error C2664: 'gluUnProject' : cannot convert parameter 4 from 'GLdouble [4][4]' to 'const GLdouble []'

+1  A: 

It seems that variables modelview1 and projection1 have wrong type.

I found following snippet (here http://www.3dkingdoms.com/selection.html ):

// This function will find 2 points in world space that are on the line into the screen defined by screen-space( ie. window-space ) point (x,y)
   double mvmatrix[16];
   double projmatrix[16];
   int viewport[4];
   double dX, dY, dZ, dClickY; // glUnProject uses doubles, but I'm using floats for these 3D vectors

   glGetIntegerv(GL_VIEWPORT, viewport);    
   glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix);
   glGetDoublev (GL_PROJECTION_MATRIX, projmatrix);
   dClickY = double (g_WindowHeight - y); // OpenGL renders with (0,0) on bottom, mouse reports with (0,0) on top

   gluUnProject ((double) x, dClickY, 0.0, mvmatrix, projmatrix, viewport, &dX, &dY, &dZ);
   ClickRayP1 = Vector3 ( (float) dX, (float) dY, (float) dZ );
   gluUnProject ((double) x, dClickY, 1.0, mvmatrix, projmatrix, viewport, &dX, &dY, &dZ);
   ClickRayP2 = Vector3 ( (float) dX, (float) dY, (float) dZ );
Kamil Szot
yes , you are right. thanks
rantravee
can you accept the solution then?
Kamil Szot