The Android OpenGL API tends to use array and offset combinations in places where the C API would be using pointers. Is there anything in any Android documentation to say that it's illegal to pass the same array as multiple arguments of such a function?
I've been debugging the following (Kotlin) code for far too long:
val queryResults = IntArray(3)
GLES20.glGetActiveUniform(
handle, index, nameBuf.size,
queryResults, 0, // length
queryResults, 1, // size
queryResults, 2, // type
nameBuf, 0)
val length = queryResults[0]
val size = queryResults[1]
val type = queryResults[2]
I was hoping to avoid two array allocations (and the namespace clobbering they entail) by reusing a single three-element vector for all three int value output parameters. But it seems to me that only the first array element is actually being modified. The second and third argument stay at whatever value they had before the function was called. Why?
The Android Kotlin documentation is not saying anything apart from the function signature and argument names. The Java version is no more useful. The OpenGL documentation describes the function in terms of three distinct pointers, with no additional requirements.
The fix I have is to use one array per output argument, but I really would like to understand hy this is needed. There might be something about the whole API translation that I don't understand and that will become useful as I continue to work with it.
val lengthBuf = IntArray(1)
val sizeBuf = IntArray(1)
val typeBuf = IntArray(1)
GLES20.glGetActiveUniform(
handle, index, nameBuf.size,
lengthBuf, 0, // length
sizeBuf, 0, // size
typeBuf, 0, // type
nameBuf, 0)
val length = lengthBuf[0]
val size = sizeBuf[0]
val type = typeBuf[0]