1
"""glu[Un]Project[4] convenience wrappers"""
2
from OpenGL.platform import GL
3
from OpenGL.raw import GLU as simple
4
from OpenGL import GL, arrays
5
from OpenGL.lazywrapper import lazy
7
POINTER = ctypes.POINTER
9
@lazy( simple.gluProject )
10
def gluProject( baseFunction, objX, objY, objZ, model=None, proj=None, view=None ):
11
"""Convenience wrapper for gluProject
13
Automatically fills in the model, projection and viewing matrices
16
returns (winX,winY,winZ) doubles
19
model = GL.glGetDoublev( GL.GL_MODELVIEW_MATRIX )
21
proj = GL.glGetDoublev( GL.GL_PROJECTION_MATRIX )
23
view = GL.glGetIntegerv( GL.GL_VIEWPORT )
24
winX = simple.GLdouble( 0.0 )
25
winY = simple.GLdouble( 0.0 )
26
winZ = simple.GLdouble( 0.0 )
27
result = baseFunction(
32
# On Ubuntu 9.10 we see a None come out of baseFunction,
33
# despite it having a return-type specified of GLint!
34
if result is not None and result != simple.GLU_TRUE:
35
raise ValueError( """Projection failed!""" )
36
return winX.value, winY.value, winZ.value
38
@lazy( simple.gluUnProject )
39
def gluUnProject( baseFunction, winX, winY, winZ, model=None, proj=None, view=None ):
40
"""Convenience wrapper for gluUnProject
42
Automatically fills in the model, projection and viewing matrices
45
returns (objX,objY,objZ) doubles
48
model = GL.glGetDoublev( GL.GL_MODELVIEW_MATRIX )
50
proj = GL.glGetDoublev( GL.GL_PROJECTION_MATRIX )
52
view = GL.glGetIntegerv( GL.GL_VIEWPORT )
53
objX = simple.GLdouble( 0.0 )
54
objY = simple.GLdouble( 0.0 )
55
objZ = simple.GLdouble( 0.0 )
56
result = baseFunction(
59
ctypes.byref(objX),ctypes.byref(objY),ctypes.byref(objZ),
62
raise ValueError( """Projection failed!""" )
63
return objX.value, objY.value, objZ.value
64
@lazy( simple.gluUnProject4 )
67
winX, winY, winZ, clipW,
68
model=None, proj=None, view=None,
71
"""Convenience wrapper for gluUnProject
73
Automatically fills in the model, projection and viewing matrices
76
returns (objX,objY,objZ) doubles
79
model = GL.glGetDoublev( GL.GL_MODELVIEW_MATRIX )
81
proj = GL.glGetDoublev( GL.GL_PROJECTION_MATRIX )
83
view = GL.glGetIntegerv( GL.GL_VIEWPORT )
84
objX = simple.GLdouble( 0.0 )
85
objY = simple.GLdouble( 0.0 )
86
objZ = simple.GLdouble( 0.0 )
87
objW = simple.GLdouble( 0.0 )
88
result = baseFunction(
91
ctypes.byref(objX),ctypes.byref(objY),ctypes.byref(objZ),ctypes.byref(objW)
94
raise ValueError( """Projection failed!""" )
95
return objX.value, objY.value, objZ.value, objW.value