Closed mbrla0 closed 3 years ago
Could we use
GL_UNIFORM_BLOCK_NAME_LENGTH
inglGetActiveUniformBlockiv
?256
seems like a reasonable default if we can't use that for some reason.
Oh, totally. I missed that parameter as I was mostly only reading the WebGL documentation, which doesn't have it. My bad.
Build succeeded:
Fixes #183.
What is it?
This pull request adds support for the
glGetActiveUniformBlock
family of functions through the addition of three new functions toHasContext
:get_active_uniform_block_parameter_i32
, which retrieves a single signed integer parameter and is intended for use with the followingpname
s:GL_UNIFORM_BLOCK_BINDING
,GL_UNIFORM_BLOCK_DATA_SIZE
,GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS
,GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER
, andGL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER
.get_active_uniform_block_parameter_i32_slice
, which retrieves a slice of signed integer parameters and is intended for use with the followingpname
:GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES
.get_active_uniform_block_name
, which retrieves the name of a uniform block, as a string.Potential Implementation Pitfalls
In the WebGL backend, the integer data types returned by the
getActiveUniformBlockParameter
function are unsigned, rather than signed, as they are in OpenGL. In my implementation I have decided to follow OpenGL, rather than WebGL, and have thus opted to implement functions with ani32
return type, rather than with au32
.When retrieving the name of an active uniform block in the native backend, this implementation will buffer
256
bytes on the stack and pass those as the receiving name buffer to OpenGL, as there doesn't seem to be a way to query for the length of the uniform block's name ahead of time.