Page 1 of 1

Crash when using GluUnProject__()

Posted: Sun Jan 09, 2005 5:48 pm
by halo
I get a crash when using GluUnProject__(). This function is a little different than most Glu functions because it pokes a double float to the objx,y, and z pointers, which the user then returns. My guess is this is an oversight in the wrapper, since it is a rather advanced command.

gluUnProject
The gluUnProject function maps window coordinates to object coordinates.

int gluUnProject(
GLdouble winx,
GLdouble winy,
GLdouble winz,
const GLdouble modelMatrix[16],
const GLdouble projMatrix[16],
const GLint viewport[4],
GLdouble *objx,
GLdouble *objy,
GLdouble *objz
);
Parameters
winx, winy, winz
The window coordinates to be mapped.
modelMatrix
The modelview matrix (as from a glGetDoublev call).
projMatrix
The projection matrix (as from a glGetDoublev call).
viewport
The viewport (as from a glGetIntegerv call).
objx, objy, objz
The computed object coordinates.
Return Values
If the function succeeds, the return value is GL_TRUE.

If the function fails, the return value is GL_FALSE.

Remarks
The gluUnProject function maps the specified window coordinates into object coordinates using modelMatrix, projMatrix, and viewport. The result is stored in objx, objy, and objz.

Requirements
Windows NT/2000: Requires Windows NT 3.5 or later.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Header: Declared in Glu.h.
Library: Use Glu32.lib.

See Also
glGet, glGetDoublev, glGetIntegerv, gluProject

Posted: Sun Jan 09, 2005 6:08 pm
by halo
Now I am trying to use F64 and the regular glu command. Please tell me if you can see anything wrong here:

Code: Select all

ProcedureDLL.l gluUnProject(winx.f,winy.f,winz.f,modelmatrix,projmatrix,viewport,objx,objy,objz)
dwinx.double
dwiny.double
dwinz.double
F64_Float(dwinx.double,winx)
F64_Float(dwiny.double,winy)
F64_Float(dwinz.double,winz)
dobjx=AllocateMemory(8)
dobjy=AllocateMemory(8)
dobjz=AllocateMemory(8)
result=gluUnProject_(dwinx\a,dwinx\b,dwiny\a,dwiny\b,dwinz\a,dwinz\b,modelmatrix,projmatrix,viewport,dobjx,dobjy,dobjz)
x.double
y.double
z.double
x\a=PeekL(dobjx+0)
x\b=PeekL(dobjx+4)
y\a=PeekL(dobjy+0)
y\b=PeekL(dobjy+4)
z\a=PeekL(dobjz+0)
z\b=PeekL(dobjz+4)
rx.f=F64_toFloat(x)
ry.f=F64_toFloat(y)
rz.f=F64_toFloat(z)
PokeF(objx,rx)
PokeF(objy,ry)
PokeF(objz,rz)
FreeMemory(dobjx)
FreeMemory(dobjy)
FreeMemory(dobjz)
ProcedureReturn result
EndProcedure