- //************************************************************************************************
- //Get the tile wich is selected
- //************************************************************************************************
- function GetOGLPos(X, Y: Integer): T3D_Point;
- var
- viewport: TViewPortArray;
- modelview: T16dArray;
- projection: T16dArray;
- winZ: Single;
- resPoint: T3D_Point;
- begin
- glGetDoublev(GL_MODELVIEW_MATRIX, @modelview );
- glGetDoublev(GL_PROJECTION_MATRIX, @projection );
- glGetIntegerv(GL_VIEWPORT, @viewport );
- // In Delphi A Y Value Of 0 Returns An Unknown Value
- // I Discovered This While I Was Testing A Crosshair
- if(Y = 0) then Y := 1;
- glReadPixels(X,-Y,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,@winZ);
- gluUnProject(X,viewport[4]-Y,winZ,modelview,projection,viewport,@resPoint[0],@resPoint[1],@resPoint[2]);
- writeLn(floatToStr(resPoint[0]) + ' , ' + floatToStr(resPoint[1]) + ' , ' + floatToStr(resPoint[2]));
- Result := resPoint;
- end;