Why have you changed it from using the matrix you get from
GLGETFLOATV( GL_MODELVIEW_MATRIX , @Matrix(0,0) )
to using the camera matrix? Or have you changed GenioGL to store it away?
Here's my entire While loop after I'd finished (total mess, I left your stuff in there and added my own, but you can pick out the bits you need)
do
Dim As Single Matrix( 0 To 3 , 0 To 3 )
Dim As Single TmpX , TmpY , TmpZ , Xvec , Yvec , Zvec
GenioRender( Camera )
GenioClear()
GenioCheckKeys( Key )
' GLGETFLOATV( GL_MODELVIEW_MATRIX , @Matrix(0,0) )
glGetFloatv(GL_MODELVIEW_MATRIX, @Matrix(0,0))
TmpX = ( Matrix(0,0) * Cube->Position->X + Matrix(0,1) * Cube->Position->Y + Matrix(0,2) * Cube->Position->Z )
TmpY = ( Matrix(1,0) * Cube->Position->X + Matrix(1,1) * Cube->Position->Y + Matrix(1,2) * Cube->Position->Z )
TmpZ = ( Matrix(2,0) * Cube->Position->X + Matrix(2,1) * Cube->Position->Y + Matrix(2,2) * Cube->Position->Z )
Xvec = TmpX - Camera->Position->X
Yvec = TmpY - Camera->Position->Y
Zvec = TmpZ - Camera->Position->Z
Dim as single Tmp1X,Tmp1Y,Tmp1Z,Tmp2X,Tmp2Y,Tmp2Z
Tmp1X = Cube->Position->X + Matrix(3,0)
Tmp1Y = Cube->Position->Y + Matrix(3,1)
Tmp1Z = Cube->Position->Z + Matrix(3,2)
Tmp2X = ( Matrix(0,0) * Tmp1X + Matrix(0,1) * Tmp1Y + Matrix(0,2) * Tmp1Z )
Tmp2Y = ( Matrix(1,0) * Tmp1X + Matrix(1,1) * Tmp1Y + Matrix(1,2) * Tmp1Z )
Tmp2Z = ( Matrix(2,0) * Tmp1X + Matrix(2,1) * Tmp1Y + Matrix(2,2) * Tmp1Z )
Xvec = Tmp2X
Yvec = Tmp2Y
Zvec = -Tmp2Z
If ( Xvec < -Zvec Or Xvec > Zvec ) Then
'Do Nothing
Xin = 0
Else
Xin = 1
EndIf
If ( Yvec < -Zvec Or Yvec > Zvec ) Then
'Do Nothing
Yin = 0
Else
Yin = 1
EndIf
If ( Xin And Yin ) Then
DrawEntity( Cube )
OutputDebugString("In"+Chr$(13)+Chr$(10))
Else
OutputDebugString("Out"+Chr$(13)+Chr$(10))
EndIf
glDisable(GL_DEPTH_TEST)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
glBegin(GL_POINTS)
glColor3f(1,0,0)
glVertex3f(Tmp2X, Tmp2Y, Tmp2Z)
glEnd()
glEnable(GL_DEPTH_TEST)
MoveCamera( Camera )
LOOP WHILE Key.esckey <> 1
Jim