本文介绍了在OpenGL中有没有办法让所有的制服和放大器的列表; attribs使用的着色器程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获得所有的制服和放大器的列表;所使用的着色器程序对象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);
// ...
这篇关于在OpenGL中有没有办法让所有的制服和放大器的列表; attribs使用的着色器程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!