grovesNL / glow

GL on Whatever: a set of bindings to run GL anywhere and avoid target-specific code
Apache License 2.0
1.2k stars 130 forks source link

Add support for the `glGetActiveUniformBlock` family of functions #184

Closed mbrla0 closed 3 years ago

mbrla0 commented 3 years ago

Fixes #183.

What is it?

This pull request adds support for the glGetActiveUniformBlock family of functions through the addition of three new functions to HasContext:

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 an i32 return type, rather than with a u32.

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.

mbrla0 commented 3 years ago

Could we use GL_UNIFORM_BLOCK_NAME_LENGTH in glGetActiveUniformBlockiv? 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.

bors[bot] commented 3 years ago

Build succeeded: