confusing problem !!!

You have to force conversion to float before you do the divide, else it will be integer divide (eg. 3/7=2).

ex :
Mousex = -80 + (160*(((float)x)/Winx));
Mousey = 80 - (160*(((float)y)/Winy));

or :
Mousex = -80 + (160.0x)/Winx;
Mousey = 80 - (160.0
y)/Winy;

Originally posted by ido77:
[b]Here is a code example for using gluUnproject
Given the gMouseAreaIni var and the gMouseAreaFin var (respectively first and second mouse points)

GLdouble lFirstPoint[3];
GLdouble lSecondPoint[3];
GLdouble lModelViewMatrix[16];
GLdouble lProjectionMatrix[16];
GLdouble lDepthRange[2];
GLint lViewport[4];
GLboolean lValidFirstPoint;
GLboolean lValidSecondPoint;

glGetDouble(GL_MODELVIEW_MATRIX,lModelViewMatrix);
glGetDoublev
(GL_PROJECTION_MATRIX, lProjectionMatrix);
glGetDoublev
(GL_DEPTH_RANGE, lDepthRange);
glGetIntegerv(GL_VIEWPORT, lViewport);

lValidFirstPoint = gluUnProject( (GLdouble)gMouseAreaIni[0], (GLdouble)(lViewport[3] - gMouseAreaIni[1]), lDepthRange[0], lModelViewMatrix, lProjectionMatrix, lViewport,&(lFirstPoint[0]), &(lFirstPoint[1]), &(lFirstPoint[2]));

lValidSecondPoint = gluUnProject((GLdouble)gMouseAreaFin[0], (GLdouble)(lViewport[3] - gMouseAreaFin[1]), lDepthRange[0], lModelViewMatrix, lProjectionMatrix, lViewport,&lSecondPoint[0], &lSecondPoint[1], &lSecondPoint[2]);[/b]

Hi ido77

Seems also difficult to me
I found other easier solution to solve my problem .
Thanks alot ido77 , I apprciate your help.

Originally posted by ZbuffeR:
[b]You have to force conversion to float before you do the divide, else it will be integer divide (eg. 3/7=2).

or :
Mousex = -80 + (160.0x)/Winx;
Mousey = 80 - (160.0
y)/Winy;[/b]

IT WORKS

Thanks millions

Glad to see I helped you solve your problem. Try to find some doc/tutorial on the nasty C traps, especially with format conversion, pointers and arrays, etc. You may need it.

I’am happy to see you have succeeded in solving your problem this way.

A firm grasp on C/C++ would help a ton here, I think. Everyone wants to make cool 3D programs, but no one wants to learn HOW cool 3D programs are made. Just throw me some code, that’s all beginner programmers are asking these days.