简体   繁体   中英

Pyglet OpenGL Setting Fog Color

I'd like to know how to set fog color using pyglet.gl.

I couldn't find information about fog color in the documentation , but I found this useful. However, the code I wrote

pyglet.gl.glFogfv(gl.GL_FOG_COLOR, (0.5, 0.7, 1.0, 1.0))

produces the error: ctypes.ArgumentError: argument 2: <class 'TypeError'>: expected LP_c_float instance instead of tuple

I'm not sure how to give it a LP_c_float from my color tuple, as it is not found in pyglet.gl or in the above documentation.

The 2nd paramter of pyglet.gl.glFogfv is an array of 4 floats, sp you have to create an ctypes array by (GLfloat * 4) , see pyglet.gl.glFogfv :

pyglet.gl.glFogfv(gl.GL_FOG_COLOR, (GLfloat * 4)(0.5, 0.7, 1.0, 1.0))

See 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM