#OpenGL - nglGetActiveUniform - kotlin, buffer pointer

1 messages · Page 1 of 1 (latest)

slim torrent
#

given the following code:
(note that this code wrong and wont work)

private fun getUniformLocations(){
        //if linking succeeded get all the active uniforms and store them in our map of uniform variable location
        val numUniforms = glGetProgrami(shaderProgramID, GL_ACTIVE_UNIFORMS)
        val maxCharLength = glGetProgrami(shaderProgramID, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH)
        if(numUniforms > 0 && maxCharLength > 0){
            var charBuffer = BufferUtils.createByteBuffer(maxCharLength)
    
            for(i in 0 until numUniforms){
                var length: Int = 0
                var size: Int = 0
                var dataType: Int = 0
                nglGetActiveUniform(shaderProgramID, i, maxCharLength, length.toLong(), size.toLong(),dataType.toLong(), charBuffer )
                val location = glGetUniformLocation(shaderProgramID,charBuffer)
                println("uniform at $location is ${charBuffer}")
            }
        }
    }```
you can asume that the shaderProgramID is right, its where the whole shader is build on and the shader works just fine 
this function doesnt return anything yet, i was planning to save all the Uniforms in a list with there type and stuff, 
But for now i am just printing the result untill i get it working

So the problem.
I am trying to do the method `nglGetActiveUniform()` or `glGetActiveUniform()` both will  do the same i think, but with other imputs (`ngl` being the some kind of java wrapper thingy of `gl`, or at least thats what i heard)
anyway, for both i need to enter some `long`s which would be the pointers to in this case of the `charBuffer`
I tried maby things but i cant seem to get a pointer/long of the charbuffer. Or maby i did but then i cant seem to get the right end result

for this method i for example need to enter the following
opal dustBOT
#

<@&987246683568103514> please have a look, thanks.

opal dustBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

slim torrent
#

i dont understand, i am getting half the answer and half garbage

#

this is the shader

slim torrent
#

yea know what, i think i am just going to stick with knowing the uniform names

#

instead of making htis whole list, its unnessesary anyway