Does anyone tried to use GLFW with kotlin native? ...
# kotlin-native
m
Does anyone tried to use GLFW with kotlin native? Declarations like
typedef struct GLFWwindow GLFWwindow;
in GLFW are being mapped to
kotlinx.cinterop.CPointer<cnames.structs.GLFWwindow>?
and have "ERROR" texts in IDE next to them.
d
Yeah, the IDE isn't the most useful right now but it should still compile and run.
Most Native types have ERROR texts next to them in the IDE.
o
In which IDE?
d
CLion
Actually I just checked. It also happens in IntelliJ when you "Ctrl+Q" on a function that take a pointer to a struct. Such as
GLFWwindow
.
m
@olonho IntelliJ IDEA 2018.3 EAP (Ultimate Edition) Build #IU-183.3647.12, built on October 10, 2018 IntelliJ IDEA EAP User Expiration date: November 9, 2018 JRE: 1.8.0_152-release-1343-b5 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0
I also do not have this kind of "struct class" declaration for GLFWwindow in GLFW generated klib. However I have declarations for some structs like
class GLFWvidmode(rawPtr: NativePtr) : CStructVar(rawPtr) {
.
o
Shall work in IDEA
a
kotlinx.cinterop.CPointer<cnames.structs.GLFWwindow>
youll have to unwrap using
.useContents { }
- that wasn't clear to me without some looking up
m
Maybe the problem is related to the fact that glfw3.h (from include folder) has only this typedef line
typedef struct GLFWwindow GLFWwindow;
concerning the GLFWwindow.
d
Do you have the
glfwCreateWindow
function defined? What does it return?
m
Yes, in .knm file it is defined as
Copy code
public fun glfwCreateWindow(width: <http://kotlin.Int|kotlin.Int>, height: <http://kotlin.Int|kotlin.Int>, title: kotlin.String?, monitor: kotlinx.cinterop.CValuesRef<cnames.structs.GLFWmonitor>?, share: kotlinx.cinterop.CValuesRef<cnames.structs.GLFWwindow>?): kotlinx.cinterop.CPointer<cnames.structs.GLFWwindow>? { /* compiled code */ }
d
Yeah, you should be able to use that.
m
When i ctrl+click on GLFWwindow name, I get Cannot find declaration to go - is that ok?
d
Yeah that's okay. Everything else should work.
m
Yes, it seems it otherwise work. Thanks