私は pyglet を使用して Python で 3D ビジュアライゼーションを行っています。モデルビューと射影行列を取得してピッキングを行う必要があります。以下を使用してウィンドウを定義します。
from pyglet.gl import *
from pyglet.window import *
win = Window(fullscreen=True, visible=True, vsync=True)
次に、すべてのウィンドウ イベントを定義します。
@win.event
def on_draw():
# All of the drawing happens here
@win.event
def on_mouse_release(x, y, button, modifiers):
if button == mouse.LEFT:
# This is where I'm having problems
a = GLfloat()
mvm = glGetFloatv(GL_MODELVIEW_MATRIX, a)
print a.value
クリックすると印刷されます...
1.0
Segmentation fault
クラッシュします。GL_MODELVIEW_MATRIX で glGetFloatv を呼び出すと、16 個の値が返されるはずですが、それを処理する方法が正確にはわかりません。= GLfloat*16 を定義しようとしましたが、次のエラーが発生します。
ctypes.ArgumentError: argument 2: <type 'exceptions.TypeError'>: expected LP_c_float instance instead of _ctypes.PyCArrayType
これらの行列を取得するにはどうすればよいですか?