Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

No conversion from cinterop types to Kotlin types done by code generator #13

Open
nlbuescher opened this issue Jan 20, 2020 · 7 comments

Comments

@nlbuescher
Copy link
Collaborator

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.

@Dominaezzz
Copy link
Owner

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.

@nlbuescher
Copy link
Collaborator Author

By not-so-firendly low-level function do you mean the version of glGetString that returns a CPointer<GLubyteVar>??

@Dominaezzz
Copy link
Owner

Yes, glGetString that returns CPointer<GLubyteVar>? (or glIsEnabled that returns Int instead of Boolean).

@Dominaezzz
Copy link
Owner

Dominaezzz commented Jan 22, 2020

I started in the nice_gl branch.
So far have done functions similar to:

  • fun glGetString(): String
  • fun glGetInteger(pname: GLenum): GLint instead of just fun glGetInteger(pname: GLenum, value: CPointer<GLintVar>): GLint.
  • fun glGenBuffer(): GLint in addition to fun glGenBuffers(count: GLsizei, idx: CPointer<GLuintVar>).
  • fun glGetUniformLocation(program: GLuint, name: String) in addition to fun glGetUniformLocation(program: GLuint, name: CValuesRef<GLcharVar>?): GLint
  • GLboolean to Boolean

Feel free to suggest any that could be added to the list.

EDIT: I won't be touching primitive arrays just yet.

@nlbuescher
Copy link
Collaborator Author

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()

@nlbuescher
Copy link
Collaborator Author

Are there any plans to use the Enums generated from the GL registry in the gl functions?

@Dominaezzz
Copy link
Owner

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants