Table of Contents

Fix, Fork, Contribute

How can I get all the uniforms and uniformBlocks


when I write uniformBuffer in shader like this.

uniform Material {
 uniform vec4 u_DiffuseColor;
 uniform vec4 u_TilingOffset;
 uniform vec3 u_MaterialSpecular;
 uniform float u_AlphaTestValue;
 uniform float u_Shininess;

gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS) and gl.getActiveUniform(program, i) still contaion uniformBuffer item( for example u_DiffuseColor,it's redundant!), the only one thing I found is gl.getUniformLocation(program, uniName) will return null.

is there another better way i can get uniforms not include uniformBuffer item,because the i should dispose them with two different way. Maybe this is not best way when have uniformBuffer block in shader with opengles3.0


You can get all uniforms and which blocks they are in by calling gl.getActiveUniform and gl.getActiveUniforms. gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS) returns the number of uniforms. You then create an array of indices to pass to gl.getActiveUniforms and pass it gl.UNIFORM_BLOCK_INDEX. -1 = not in a block.

Other questions related to using uniform blocks

The question and quoted portions thereof are CC BY-SA 4.0 by gl3336563163com from here
Questions? Ask on stackoverflow.
Issue/Bug? Create an issue on github.
Use <pre><code>code goes here</code></pre> for code blocks
comments powered by Disqus