Hello, I used the following procedure to get the screen coordinates of a point in the 3D matrix (with OpenGL)

Code:
// objx,objy,objz - 3D location of a point 
// screenX, screenY - will hold screen coordinates of (objx,objy,objz) 
procedure Matrix_To_Win(objx,objy,objz : integer;  var screenX : integer,  var screenY : integer); 
var 
 model, proj : T16dArray;  //type defined in glu.pas 
 view : TViewportArray;    //also defined in glu.pas 
 winx,winy,winz : glDouble; 
begin 
 glGetDoublev(GL_PROJECTION, @proj); 
 glGetDoublev(GL_MODELVIEW, @model); 
 glGetIntegerv(GL_VIEWPORT,@view); 

 gluProject(objx,objy,objz, proj, model, view, @winx, @winy, @winz); 
 screenX := Round(winx); 
 //since OpenGL treats lower left corner as a (0,0) winy must be 
 //transformed to normal window coordinates with (0,0) at upper left 
 //corner 
 screenY := ScreenHeight - Round(winy); 
end;
But for some reason, it bugs on the last two lines. I don't understand why, since all we're doing is changing the values of the variables! I thought it might have to do with the rounding or something in there, so I changed those two lines to
Code:
screenX:=0;
screenY:=0;
and it still bugged...
Then I just commented them out and it worked fine (except that I don't get the correct output values, of course).
I don't understand what's going on...

Oh, and also, when objx,objy and objz are anything other than integers, i get the error
Code:
floating point overflow
Isn't that weird, since coordinates should be reals or even GLdoubles ?

Cheers