Closed chaosct closed 9 years ago
Which ones? Is this similar to setTextureWrap needing GLfloat? In the Luabind wrapper, I added some gl stuff as enums: https://github.com/danomatika/ofxLua/blob/master/src/bindings/Gl.cpp#L452
We could do something similar with an %inline enum set.
I was in need of ofTexture::setTextureMinMagFilter(GLint minFilter, GLint maxFilter)
.
I was trying to avoid defining GLint in the swig wrapper code as GLint is already defined there. Moreover, GLint exact definition (int, unsigned int, ??) depends on the platform and OS. Even the location of the GL header depends on the OS and device.
If I am not mistaken, doing a typedef in the interface file only tells swig to accept ints in the warapper function, but don't leak the typedef in the .cpp file.
How would it look like this %inline alternative ?
The %inline or %extend would not be an alternative, but add some additional enums so you wouldn't have find the actual GL numeric values. With the Luabind wrapper you could use:
of.Texture.setTextureMinMagFilter(of.Texture.WRAP.CLAMP_TO_EDGE, of.Texture.WRAP.CLAMP_TO_BORDER)
I just forgot to add these.
Yeah you're right, it's not %inline but %extend that I want. The only reason it was added in Luabind was for convenience without pulling in the OpenGL API. Got it here https://github.com/danomatika/swig-openframeworks/commit/ca885758d4498d571927eebcc484eb7282ed77b6
For example, in Lua you can now use:
of.Texture.CLAMP_TO_EDGE
of.Texture.CLAMP_TO_BORDER
of.Texture.MIRRORED_REPEAT -- except for OpenGL ES
of.Texture.REPEAT
of.Texture.LUMINENCE
of.Texture.RGB
of.Texture.RGBA
Whoops, that didn't work :P I'll fix it a but later by using defines instead of enums.
Ok, fixed by using defines. Using %extend with enums does not work since the enums don't exist in the original class definition.
Again, in Lua it's now:
of.TEXTURE_CLAMP_TO_EDGE
of.TEXTURE_CLAMP_TO_BORDER
of.TEXTURE_MIRRORED_REPEAT -- except for OpenGL ES
of.TEXTURE_REPEAT
of.TEXTURE_LUMINENCE
of.TEXTURE_RGB
of.TEXTURE_RGBA
I'd prefer if these were part of the Texture class, but it's not unreasonable since we already have of.IMAGE_COLOR, etc.
Some functions require GLint parameters, and those can't be provided unless SWIG knows something about GLint type.