Dominaezzz / kgl

Thin multiplatform wrappers for graphics.
Apache License 2.0
106 stars 14 forks source link

Replace IoBuffer with something more ergonomic #4

Open Dominaezzz opened 5 years ago

Dominaezzz commented 5 years ago

kotlinx.io.core.IoBuffer is going to be deprecated soon. kotlinx.io.bits.Memory will be a a better substitute for representing void* in kotlin.

https://github.com/Kotlin/kotlinx-io/issues/39

Dominaezzz commented 4 years ago

May have to take this into my own hands and implement an ergonomic Buffer class. One for each primitive type.

aouerf commented 4 years ago

While possibly overkill, it might be worth looking into using okio's Buffer for this.

Dominaezzz commented 4 years ago

Hello! Thank you for your interest in this project.

okio.Buffer is convenient but a bit too high level. Every time a okio.Buffer is passed to kgl, it would have to make an allocation, copy the contents of the buffer over and then give it to OpenGL/Vulkan. Also, some APIs return a pointer which cannot be represented by okio.Buffer since it uses "on-heap" memory. I looked around and I don't think okio has appropriate data structures for this. okio also doesn't support many native targets.

aouerf commented 4 years ago

Yeah that makes sense, thanks for the explanation. I guess the best option for now is to roll your own implementation like you said since kotlinx-io doesn't have exactly what you need (yet) and breaking changes are bound to happen.