在OpenGL中有没有办法让所有的制服和放大器的列表; attribs使用的着色器程序?有的、中有、放大器、没有办法

由网友(快手昵称)分享简介:我想获得所有的制服和放大器的列表;所使用的着色器程序对象attribs。 glGetAttribLocation()及glGetUniformLocation()可用于将一个字符串映射到某个位置,但我真的很想为字符串列表,而不必解析GLSL code。I'd like to get a list of all the...

我想获得所有的制服和放大器的列表;所使用的着色器程序对象attribs。 glGetAttribLocation()及glGetUniformLocation()可用于将一个字符串映射到某个位置,但我真的很想为字符串列表,而不必解析GLSL code。

I'd like to get a list of all the uniforms & attribs used by a shader program object. glGetAttribLocation() & glGetUniformLocation() can be used to map a string to a location, but what I would really like is the list of strings without having to parse the glsl code.

请注意:在OpenGL 2.0 glGetObjectParameteriv()被替换为glGetProgramiv()。而ENUM是GL_ACTIVE_UNIFORMS和放大器; GL_ACTIVE_ATTRIBUTES。

Note: In OpenGL 2.0 glGetObjectParameteriv() is replaced by glGetProgramiv(). And the enum is GL_ACTIVE_UNIFORMS & GL_ACTIVE_ATTRIBUTES.

推荐答案

属性:

// get count
glGetObjectParameterivA (shaderID, GL_OBJECT_ACTIVE_ATTRIBUTES, &count);
// for i in 0 to count:
glGetActiveAttrib (shaderID, i, bufSize, &length, &size, &type, name);
// ...

制服:

// get count
glGetObjectParameteriv (shaderID, GL_OBJECT_ACTIVE_UNIFORMS, &count);
// for i in 0 to count:
glGetActiveUniform (shaderID, i, bufSize, &length, &size, &type, name);
// ...
阅读全文

相关推荐

最新文章