Hello, I am trying to use OpenGL extensions on Lin...
# kotlin-native
g
Hello, I am trying to use OpenGL extensions on Linux with libepoxy. But cinterop don't seems to generate pointer to function declared with "#define" in the .h files. For example, in the .h file, there is :
Copy code
#define glCreateShader epoxy_glCreateShader
In generated .kt file, epoxy_glCreateShader is present, but not glCreateShader:
Copy code
var epoxy_glCreateShader: CPointer<CFunction<(GLenum) -> GLuint>>?
    get() = interpretPointed<CPointerVar<CFunction<(GLenum) -> GLuint>>>(kniBridge423()).value
    set(value) { interpretPointed<CPointerVar<CFunction<(GLenum) -> GLuint>>>(kniBridge423()).value = value }
Here the .def file I used with cinterop :
Copy code
depends = posix
package = epoxy
headers = epoxy/gl.h epoxy/glx.h
headerFilter = epoxy/**
linkerOpts = -lepoxy
compilerOpts.linux = -I/usr/include
Did you have any idea ?
o
it is intended mode of operations of cinterop, it creates mappings for functions and define’s to constant value. If you’ll use
Copy code
static inline int glCreateShader() {
      return epoxy_glCreateShader();
}
it shall work as intended (definitions like that could be in .def file after
---
separator.
g
Thanks for your fast answer. But I am unable to get it working, I add the lines in the .def file but I have this error :
Copy code
error: redefinition of 'epoxy_glCreateShader' as different kind of symbol
I also try with this :
Copy code
static inline GLuint glCreateShader(GLenum type) {
    return epoxy_glCreateShader(type);
}
o
You need to add
#undef glCreateShader
before
m
It is really pointer to function:
EPOXY_IMPORTEXPORT GLuint (EPOXY_CALLSPEC *epoxy_glCreateShader)(GLenum type);
g
Thanks, it's working with :
Copy code
#undef glCreateShader
static inline GLuint glCreateShader(GLenum type) {
    return epoxy_glCreateShader(type);
}
I think I will write a script to generate the .def file because there are thousands of functions like that.