2
我使用pyglet在python中執行三維可視化,並需要檢索模型視圖和投影矩陣來執行一些拾取。我定義使用我的窗口:使用glGetFloatv檢索pyglet中的模型視圖矩陣
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
如何檢索這些矩陣?
工作完美,非常感謝。 – user1223904 2012-03-24 14:45:07
你能分享這16個元素的解釋嗎?哪個元素代表什麼?根據我的理解,專欄專業爲 – vipin8169 2016-09-28 02:09:37
。即前4個是矩陣的第一列。 – 2017-02-09 08:50:40