Hi, i've spotted this code around:
[pascal]
{------------------------------------------------------------------}
{ Get the vector for the current mouse position }
{------------------------------------------------------------------}
function GetOpenGLPos(X, Y: Integer): TVector;
var
viewport: TViewPortArray;
modelview: T16dArray;
projection: T16dArray;
winZ,winY: Single;
begin
glGetDoublev(GL_MODELVIEW_MATRIX, @modelview[0] ); // Get the Current Modelview matrix
glGetDoublev(GL_PROJECTION_MATRIX, @projection[0] ); // Get the Current Projection Matrix
glGetIntegerv(GL_VIEWPORT, @viewport[0] ); // Get the Current Viewport

winY := viewport[3] - y; //Change from Window to OpenGL coordinate system

glReadPixels(X, Round(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, @winZ );//Read the Depth value at the current X and Y position
gluUnProject(X, winY, winz, modelview, projection, viewport, // Get the vector for the current mouse position
@(Result.x), @(Result.y), @(Result.z)); // And Return it from the function
end;
[/pascal]

But it gives AV when i run it..
Any of you is using gluUnproject ? Thanks.
This picking stuff is driving me mad