kgl
kgl copied to clipboard
No conversion from cinterop types to Kotlin types done by code generator
Functions like glGetString
are generated with a return type of CPointer<GLubyteVar>
rather than String
. This requires a conversion using a !!.reinterpret<ByteVar>().toKString()
, which could be included in the generated code to make the kotlin-facing functions more kotlinic.
Hi! Thanks for the interest in the project.
Generating more Kotlin friendly functions is on the TODO list.
The only issue is to decide what to do with the not so friendly low-level functions, or how to expose them rather.
I'll probably just do it the LWJGL way with the n
prefix.
By not-so-firendly low-level function do you mean the version of glGetString
that returns a CPointer<GLubyteVar>?
?
Yes, glGetString
that returns CPointer<GLubyteVar>?
(or glIsEnabled
that returns Int
instead of Boolean
).
I started in the nice_gl
branch.
So far have done functions similar to:
-
fun glGetString(): String
-
fun glGetInteger(pname: GLenum): GLint
instead of justfun glGetInteger(pname: GLenum, value: CPointer<GLintVar>): GLint
. -
fun glGenBuffer(): GLint
in addition tofun glGenBuffers(count: GLsizei, idx: CPointer<GLuintVar>)
. -
fun glGetUniformLocation(program: GLuint, name: String)
in addition tofun glGetUniformLocation(program: GLuint, name: CValuesRef<GLcharVar>?): GLint
-
GLboolean
toBoolean
Feel free to suggest any that could be added to the list.
EDIT: I won't be touching primitive arrays just yet.
I created some convenience functions for my own GL bindings and what I've done for primitive arrays for functions like glCreateBuffers is the following:
fun glCreateBuffers(n: Int): UIntArray = UIntArray(n).apply {
usePinned { copengl.glCreateBuffers(n, it.addressOf(0)) }
}
fun glCreateBuffer(): UInt = glCreateBuffers(1).first()
Are there any plans to use the Enums generated from the GL registry in the gl functions?
Ah.... those. The enums are generated from the official gl.xml registry. The problem is the registry isn't exhaustive about enums, so it doesn't work very well. I've been considering moving all the enums into a single enum but I'm not sure I like that idea very much.