我想知道如何使用 pyglet.gl 设置雾颜色。
我在 documentation 中找不到有关雾颜色的信息,但我发现this有用。然而我写的代码
pyglet.gl.glFogfv(gl.GL_FOG_COLOR, (0.5, 0.7, 1.0, 1.0))
产生错误:ctypes.ArgumentError: argument 2: <class 'TypeError'>: expected LP_c_float instance instead of tuple
我不确定如何从我的颜色元组中给它一个 LP_c_float,因为它在 pyglet.gl 或上述文档中找不到。
最佳答案
第二个参数 pyglet.gl.glFogfv
是一个 4 个 float 的数组,sp 你必须通过 (GLfloat * 4)
创建一个 ctypes 数组,参见 pyglet.gl.glFogfv :
pyglet.gl.glFogfv(gl.GL_FOG_COLOR, (GLfloat * 4)(0.5, 0.7, 1.0, 1.0))
参见 ctypes — A foreign function library for Python - Arrays:
Arrays are sequences, containing a fixed number of instances of the same type.
The recommended way to create array types is by multiplying a data type with a positive integer:
TenPointsArrayType = POINT * 10
关于python - Pyglet OpenGL 设置雾颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53133993/