I have tested the gluUnProject function from both FPC's and JEDI-SDL's glu unit in both Linux and Windows using the latest FPC compiler, and I have not run into any problems. I use the gluUnProject function in the following way:

[pascal]{**********************************************}
{ Generates a ray based on a window coordinate }
{**********************************************}
function GenerateRay(x, y: Integer): TbmRay;
var
modelmatrix, projmatrix: T16dArray;
viewport: TViewPortArray;
objxn, objyn, objzn, objxf, objyf, objzf: GLDouble;
begin
{ Get the modelview and projection matrices and the viewport data }
glGetDoublev(GL_MODELVIEW_MATRIX, @modelMatrix[0]);
glGetDoublev(GL_PROJECTION_MATRIX, @projMatrix[0]);
glGetIntegerv(GL_VIEWPORT, @viewport[0]);
{ gluUnProject z=0 for the nearplane; z=1 for the far plane }
gluUnProject(x, y, 0, modelMatrix, projMatrix, viewport, @objxn, @objyn, @objzn);
gluUnProject(x, y, 1, modelMatrix, projMatrix, viewport, @objxf, @objyf, @objzf);
{ ray = near + t * (far - near) }
Result.vStart[0] := objxn; Result.vStart[1] := objyn; Result.vStart[2] := objzn;
Result.vDel[0] := objxf - objxn; Result.vDel[1] := objyf - objyn; Result.vDel[2] := objzf - objzn;
end; [/pascal]

where TbmRay is defined thusly:

[pascal]TbmVector = array[0..2] of Double;
TbmRay = record
vStart: TbmVector;
vDel: TbmVector;
end;[/pascal]

Similarly, I have tested Paul's code with the latest FPC compiler (I used just the glunprojecttest.dpr and sdlapplicationunit.pas files) in both Linux and Windows, and again I have run into no problems.

So if there is a bug it is either with Lazarus or some aspect of your system.

Perhaps Michalis can tell us exactly which functions in JEDI-SDL's opengl units are incorrectly declared, so that we can test that and fix them if necessary. This would be a good thing to get right for the 1.0 release.