@@ -43,6 +43,7 @@ int main()
4343
4444 const char *vertexShader =
4545 " #version 300 es\n "
46+ " uniform mat4 a;\n "
4647 " uniform Block1a {\n "
4748 " uniform mat4 var1;\n "
4849 " uniform vec4 variable2;\n "
@@ -52,7 +53,7 @@ int main()
5253 " uniform vec4 variable2;\n "
5354 " } block2dddd;\n "
5455 " void main() {\n "
55- " gl_Position = block1bb.var1*block1bb.variable2 + block2dddd.var1*block2dddd.variable2;\n "
56+ " gl_Position = a * block1bb.var1*block1bb.variable2 + block2dddd.var1*block2dddd.variable2;\n "
5657 " }\n " ;
5758
5859 const char *fragmentShader =
@@ -112,6 +113,30 @@ int main()
112113 glGetProgramiv (program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &maxLength);
113114 printf (" GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: %d\n " , maxLength);
114115 assert (maxLength == 12 );
116+
117+ GLint numActiveUniforms = -1 ;
118+ glGetProgramiv (program, GL_ACTIVE_UNIFORMS, &numActiveUniforms);
119+ printf (" GL_ACTIVE_UNIFORMS: %d\n " , numActiveUniforms);
120+ assert (numActiveUniforms == 7 );
121+
122+ for (int i = 0 ; i < numActiveUniforms; ++i)
123+ {
124+ char str[256 ] = {};
125+ GLsizei length = -1 ;
126+ GLint size = -1 ;
127+ GLenum type = -1 ;
128+ glGetActiveUniform (program, i, 255 , &length, &size, &type, str);
129+
130+ GLint loc = glGetUniformLocation (program, str);
131+
132+ GLint indx = -1 ;
133+ glGetActiveUniformsiv (program, 1 , (GLuint*)&i, GL_UNIFORM_BLOCK_INDEX, &indx);
134+
135+ printf (" Active uniform at index %d: %s\n " , i, str);
136+ printf (" glGetUniformLocation = %d \t GL_UNIFORM_BLOCK_INDEX = %d \t size = %d \t type = %d\n " , loc, indx, size, type);
137+
138+ assert ((loc == -1 ) != (indx == -1 )); // one of them must be true
139+ }
115140
116141 GLint numActiveUniformBlocks = -1 ;
117142 glGetProgramiv (program, GL_ACTIVE_UNIFORM_BLOCKS, &numActiveUniformBlocks);
0 commit comments