开发者

gluUnProject function in openGL

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

GLdouble objX,objY,objZ;
GLdouble modelvie开发者_如何学Cw1[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 C2664: 'gluUnProject' : cannot convert parameter 4 from 'GLdouble [4][4]' to 'const GLdouble []'


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 );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜