我有一个像这样的统一块:
layout(shared) uniform ProjectionMatrices {
mat4 model_camera_xform;
mat4 camera_clip_xform;
};
我想查询一下这个街区制服的尺寸和偏移量。为此,我首先需要使用glGetUniformIndices
函数获取其成员的索引,但我不知道如何使用它。你知道吗
以下是我的尝试:
import ctypes as c
from OpenGL import GL
import numpy
name_array = c.c_char_p * len(uniform_names)
c_uniform_names = name_array(*[c.c_char_p(name.encode()) for name in uniform_names])
c_uniform_names = c.cast(c_uniform_names, c.POINTER(c.POINTER(c.c_char)))
uniform_indices = numpy.zeros(len(uniform_names), dtype='int32')
uniform_indices += 42
r = GL.glGetUniformIndices(program, len(uniform_names), c_uniform_names, uniform_indices)
err = GL.glGetError()
然而,其结果是:
>>> print(uniform_names) # looks good.
['ProjectionMatrices.model_camera_xform', 'ProjectionMatrices.camera_clip_xform']
>>> print(err == GL.GL_NO_ERROR) # No error occurred
True
>>> print(r) # GL.GL_INVALID_INDEX, not sure what this refers to
4294967295
>>> print(uniform_indices) # Nothing has been set
[42 42]
要解决
uniform_indices
未设置的问题,它们必须是uint32
,这可以通过以下几种方式完成:在此之后,
uniform_indices
被设置为GL_INVALID_INDEX
。通过将uniform_names
更改为使用非限定名称来解决此问题:OpenGL 4.4规范的相关部分是4.3.9接口块:
相关问题 更多 >
编程相关推荐