如何在Python / PyOpenGL中添加GLfloat类型的对象?
$ python
Python 3.3.3 (default, Nov 26 2013, 13:33:18)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from OpenGL.GL import *
>>> GLfloat
<class 'ctypes.c_float'>
>>> a = GLfloat(0.0)
>>> a += GLfloat(1.0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +=: 'c_float' and 'c_float'
>>>
答案 0 :(得分:1)
GLfloat
是ctypes.c_float。
>>> from OpenGL.GL import *
>>> a = GLfloat(0.0)
>>> a.value += 1
>>> a
c_float(1.0)