Help for uniform buffers

Started by xenoliss, August 20, 2018, 11:05:21

Previous topic - Next topic

xenoliss

Hi,

After trying for several week to get my uniform block to work, I really need help. I read tutorials and tried to implement this in my code but it doesn't work  :(
I can easily query for uniforms offsets insides my uniform block in my shader but I can't fetch the size of each uniform the function :

GL31.glGetActiveUniformsiv(shaderProgramID, buffer_uniformIndices, GL31.GL_UNIFORM_SIZE, uniformSizes);


it always returns me 1...

I can give you all the code but it is already in my last topic : http://forum.lwjgl.org/index.php?topic=6792.0

Thanks for your help.

KaiHH

1 is actually correct. Read: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetActiveUniformsiv.xhtml

QuoteIf pname is GL_UNIFORM_SIZE, then an array identifying the size of the uniforms specified by the corresponding array of uniformIndices is returned. The sizes returned are in units of the type returned by a query of GL_UNIFORM_TYPE. For active uniforms that are arrays, the size is the number of active elements in the array; for all other uniforms, the size is one.

xenoliss

But why are my uniforms not considered as "active" uniforms ?
Why am I not in this case : "If pname is GL_UNIFORM_SIZE, then an array identifying the size of the uniforms specified by the corresponding array of uniformIndices is returned." ? (because I do have a intBuffer wth my uniforms indices).

Thanks for your help again !

KaiHH

You are in this case. Read again:
QuoteIf pname is GL_UNIFORM_SIZE, then an array identifying the size of the uniforms specified by the corresponding array of uniformIndices is returned. The sizes returned are in units of the type returned by a query of GL_UNIFORM_TYPE. For active uniforms that are arrays, the size is the number of active elements in the array; for all other uniforms, the size is one.

xenoliss

Oh my... I just understood  :o :o :o

So I have to query each time the type and then the size for all my uniforms right ? I thought I could just ask for the size and it would have gave me like 1 for a float, 3 for a vec3, 4 for a vec4 etc...

Thank you very much  ;D