danomatika / swig-openframeworks

a SWIG interface for openFrameworks with included Makefile, submodule this in your language wrapper addons
Other
39 stars 11 forks source link

Wrap GL_LUMINANCE, GL_RGB, GL_RGBA #9

Closed fredreichbier closed 7 years ago

fredreichbier commented 8 years ago

Stumbled upon ofxLua, great project! For some reason, the three constants were not available on the Lua side for me. I don't know much about SWIG, but I can access them in Lua if I use the %constant instead of #define to wrap them. Maybe you know a better way though.

Cheers!

danomatika commented 8 years ago

They are wrapped, just using a diff name: https://github.com/danomatika/swig-openframeworks/blob/master/openFrameworks.i#L232

Do you think it's better call them with the same name? Though they will still be module level enums:

of.GL_LUMINANCE
of.GL_RGB
of.GL_RGBA
fredreichbier commented 8 years ago

Sorry, didn't word that very well. If I understand correctly, of.TEXTURE_RGB should evaluate to 0x1907 if all goes well. But if I add a print d right here, I just get nil. There is also no mention of TEXTURE_RGB in the SWIG-generated code. Could it be that swig just ignores the lines you linked?

danomatika commented 8 years ago

Yeah, good catch. I'm including the defines but I think SWIG doesn't actually know about the defines in the GL headers, so it doesn't actually set the values.

danomatika commented 8 years ago

Confirming the existing values aren't set:

[notice ] got a script error: Error running setup(): ...ddons/ofxLua/luaExample/bin/data/scripts/boringTests.lua:109: attempt to concatenate a nil value (field 'TEXTURE_LUMINANCE')
fredreichbier commented 8 years ago

Ah, alright. I guess it would also be cool if more GL constants were exported, as I've already patched my local ofxLua to export GL_FRAGMENT_SHADER to Lua as well. But I'm not sure what's the best approach to do that.

danomatika commented 8 years ago

My approach is to wrap just the things that are needed, otherwise we end up going down the road of wrapping the whole gl API. There are lua modules that already do that. That being said, does ofShader need the GL shader defines as well?

fredreichbier commented 7 years ago

Sorry for the silence on my part. I see that you wrapped LUMINANCE, RGB and RGBA in baa07cfd -- thank you for that! So I guess this pull request is obsolete now. I just opened a new pull request (#10) for GL_FRAGMENT_SHADER.