Hello Guest

Help for uniform buffers

  • 4 Replies
  • 762 Views
Help for uniform buffers
« on: August 20, 2018, 11:05:21 »
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 :

Code: [Select]
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.

*

Offline KaiHH

  • ***
  • 161
Re: Help for uniform buffers
« Reply #1 on: August 20, 2018, 11:47:59 »
1 is actually correct. Read: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetActiveUniformsiv.xhtml

Quote
If 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.

Re: Help for uniform buffers
« Reply #2 on: August 20, 2018, 12:30:23 »
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 !

*

Offline KaiHH

  • ***
  • 161
Re: Help for uniform buffers
« Reply #3 on: August 20, 2018, 12:32:07 »
You are in this case. Read again:
Quote
If 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.

Re: Help for uniform buffers
« Reply #4 on: August 20, 2018, 13:10:21 »
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