Multiplatform opengl api

I try to write multiplatform OpenGL wrapper.
OpenGL has function glBufferData(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage)
What is the best candidate in kotlin for the third argument?
I find several solutions:

  1. kotlin-io.IoBuffer
  2. Array
  3. Multiplatform OpenGl is bad idea. Its better to write native wrapper for working with untyped arrays.

The best candidate for Buffers is probably kotlin-io.IoBuffer.
Also if you really want to write this wrapper you might want take a look at
I, @elect and a few others are working on a more kotlin friendly wrapper around lwjgl (opengl java bindings). I don’t know how hard it would be to move this project to mpp but it would probably be worth it in the long run. That way we have only one kotlin project for opengl and not multiple ones.
I personally don’t have much time to help you change it as I don’t have any experience with mpp and don’t have much time atm to learn it.

Native will most likely be better performing (especially if you know what you are doing). It just allows you to use the capabilities of the platform better. That being said, mpp is great since it would make it easier to develop 3d games for android and ios at once. I can’t really say whether it is worth it though. I don’t have much experience with android, none with ios and I don’t know anything about opengl on either platform, so maybe I am way off.
Not sure if you would ever want to share a game between pc and mobile (or at least I would have said that a few years ago), but nowadays there are a few prominent examples out there so maybe this would be useful for that as well.

1 Like

@eshim2009 hi, did you manage to make something workable?

I have a multiplatform (JVM and Native) wrapper for Vulkan here . It should give you an idea of how to handle void*. Spoiler, I use
I also have native bindings for OpenGL, since glew, glad, etc don’t work well with cinterop.
Multiplatform OpenGL wrapper is WIP.