While that page is incomplete, Atilim is silently working on the plugin support which will enable 3rd party C++ code or library to be seamlessly used within Gideros. This will be a huge impact in terms of availability and extensibility of the platform.
In our SVN this plugin support is currently nothing but a "hello world" example, and definitely we need some more time to implement fully. According to our roadmap, it'll be ready for the next release.
i run into the problem that i would be willing to use a c++ library, not only on the desktop player. is there an example how to do that (for android mainly but i'm also interested if that can be done cross-platform so that it will work later for ios too).
so after further search i'm assured that c++ can be used as a plugin for all platforms, but is there an example on how to do that, because that i did not find. the example i've found is only for the desktop player. like the tnt particle engine is written in c and then converted to plugins for all platforms. i want to do the same but with another c library. please help.
@keszegh: I think you need to look at this thread for plugins for the desktop player.
I should also point out that this thread is 18 months old (and as such, much of the content could be out of date). Maybe you should have started a new thread to avoid confusing people who like me started reading this thread from the start.
@scouser, you may be right. i just don't like to start new topics when not necessary, the title of this one fits perfectly my question. if someone else wants as well i can move my questions to a new topic.
in any case i'm looking for a documentation where it is explained how to use a cpp library across all platforms (as a plugin), not just for desktop player. assuming that i have almost no knowledge of cpp (except that i can read a cpp code probably).
@keszegh so what you need is actually bind c++ library to lua.
Once that is done, for ios, you simply add cpp files to the xcode project and thats it.
For Android, it's the same as creating android plugin, you need to create Android.mk file pointing to your cpp files and then run Android NDK to compile it to .so file that can be included in Android project.
@ar2rsawseen, that android tutorial is quite detailed, so i could copy paste basically when i needed it for an earlier project with java plugin, yet it is for using java and so it contains some stuff that is probably not needed or needed somehow differently. so it will still be a hard time for me to make it work, that's my impression. btw i may want to use this polygon clipping library, which also has a lua-binding: http://www.cs.man.ac.uk/~toby/gpc/#Ports (actually i would prefer to use http://www.angusj.com/delphi/clipper.php as it has a free licence, but there is no lua binding for it)
i think generally there are many cpp libs, so it would be maybe useful to make a tutorial how to make a plugin from them (mainly so plugin for android). would it be possible to make such a tutorial? i understand that one part is lua-binding which is explained around the net and is a different cup of tea, but given the lua-binding how to do the rest, that's what i would be happy to see (assuming minimal java and cpp knowledge).
@keszegh I see. well if lua binding is already provided, it won't work out of the box and should also be a little modified as gideros plugin.
It could differ from binding to binding but in most cases it should have included gideros.h
and couple of additional methods:
//register c functions
LUALIB_API int luaopen_plugin(lua_State *L){//where funcs is function list
luaL_register(L, "somePluginName", funcs);return1;}//here we load a packagestaticvoid g_initializePlugin(lua_State *L){//get global package object
lua_getglobal(L, "package");
lua_getfield(L, -1, "preload");//put our plugin name inside with a callback to//registering C functions
lua_pushcfunction(L, luaopen_plugin);
lua_setfield(L, -2, "somePluginName");
lua_pop(L, 2);}//and here we free everything we need to freestaticvoid g_deinitializePlugin(lua_State *L){}
And probably need to remove the initialization of that binding
Now about Android, it's actually should be quite easy. Export project as Android project, copy and paste everything from Gideros installation folder/sdk/include to project's jni folder. Create Android.mk file with minimum this contents:
LOCAL_PATH := $(call my-dir)## Gideros Shared Library#
include $(CLEAR_VARS)
LOCAL_MODULE := gideros
LOCAL_SRC_FILES := ../../libs/$(TARGET_ARCH_ABI)/libgideros.so #may need to provide correct path
include $(PREBUILT_SHARED_LIBRARY)## Plugin#
include $(CLEAR_VARS)
LOCAL_MODULE := exampleplugin #plugin name
LOCAL_ARM_MODE := arm
LOCAL_CFLAGS := -O2
LOCAL_SRC_FILES := file1.cpp file2.cpp #list cpp files here
LOCAL_LDLIBS := -ldl-llog
LOCAL_SHARED_LIBRARIES := gideros
include $(BUILD_SHARED_LIBRARY)
Or navigate through command line to your project's jni folder and run ndk-build
And that should be it. Your project's libs folder should contain so files in each proper armeabi folder.
But what you try to accomplish (clipping) I think may not be possible, due to probably that it uses openGL to draw and in Gideros case, the Gideros openGL surface is drawing api is not exposed, so it won't work. There is a plan to expose it in the future, but then probable even more modification must be needed for current available library.
thanks @ar2rsawseen, this may be quite enough for a start. you say that lua binding to use with gideros differs from lua binding in general (or that it is not a universal thing to bind, it depends on usage). so is there some general rule how to do the binding for gideros? or what you wrote above is basically all of that (remove initialization, add gideros.h and the above mentioned additional methods)?
sidenote about the clipping libraries: about clipping, the nice thing is that this is a clipping library for polygons as data structures, so it is opengl etc independent. once clipping is computed using this library theoretically we get back a polygon data (union of polygons actually), e.g. the list of the triangles of one of its triangulations and then we can use gideros meshes to render this fast even on current gideros version. this should be good for colored meshes, if one wants texturing, then it should be again relatively easy to compute the texture coordinates of the vertices and thus for each vertex of each triangle in the mesh.
overall this shall be a useful library for other people too, i want to use it to make a 2d dynamic lighting/shadow engine, but my plans are rather theoretical at this point, i even did not make up my mind about which framework to use. i prefer gideros, but lack of info about the time of appearance of desktop export takes me back a little, so i contemplate haxenme as well. anyway most probably i won't start to realize the project soon, but i had a basic tech-demo years ago with as3 and i thought that maybe i can rewrite it more efficiently, now using gideros and one such clipping library (previously i used blending modes to emulate clipping in as3, but that was incredibly slow) just to see whether it could perform well on mobiles.
@keszegh oh ok I get it now. And yes, that probably should be the basic to replace for Gideros, but based on other bindings there might be different specifics, as there are more than one way to bind something.
If you run into trouble, you can post here and I'll try to help as much as I could
Comments
While that page is incomplete, Atilim is silently working on the plugin support which will enable 3rd party C++ code or library to be seamlessly used within Gideros. This will be a huge impact in terms of availability and extensibility of the platform.
In our SVN this plugin support is currently nothing but a "hello world" example, and definitely we need some more time to implement fully. According to our roadmap, it'll be ready for the next release. I must say that this is a global problem
Thanks for heads up.
Likes: brigosx
Fragmenter - animated loop machine and IKONOMIKON - the memory game
like the tnt particle engine is written in c and then converted to plugins for all platforms. i want to do the same but with another c library. please help.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
I should also point out that this thread is 18 months old (and as such, much of the content could be out of date). Maybe you should have started a new thread to avoid confusing people who like me started reading this thread from the start.
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
in any case i'm looking for a documentation where it is explained how to use a cpp library across all platforms (as a plugin), not just for desktop player. assuming that i have almost no knowledge of cpp (except that i can read a cpp code probably).
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Once that is done, for ios, you simply add cpp files to the xcode project and thats it.
For Android, it's the same as creating android plugin, you need to create Android.mk file pointing to your cpp files and then run Android NDK to compile it to .so file that can be included in Android project.
More on Android plugins and compiling them:
http://appcodingeasy.com/Gideros-Mobile/Creating-plugins-for-Android-in-Gideros
And that's about it in most cases.
that android tutorial is quite detailed, so i could copy paste basically when i needed it for an earlier project with java plugin, yet it is for using java and so it contains some stuff that is probably not needed or needed somehow differently. so it will still be a hard time for me to make it work, that's my impression.
btw i may want to use this polygon clipping library, which also has a lua-binding:
http://www.cs.man.ac.uk/~toby/gpc/#Ports
(actually i would prefer to use http://www.angusj.com/delphi/clipper.php as it has a free licence, but there is no lua binding for it)
i think generally there are many cpp libs, so it would be maybe useful to make a tutorial how to make a plugin from them (mainly so plugin for android).
would it be possible to make such a tutorial? i understand that one part is lua-binding which is explained around the net and is a different cup of tea, but given the lua-binding how to do the rest, that's what i would be happy to see (assuming minimal java and cpp knowledge).
Fragmenter - animated loop machine and IKONOMIKON - the memory game
well if lua binding is already provided, it won't work out of the box and should also be a little modified as gideros plugin.
It could differ from binding to binding but in most cases it should have included gideros.h
and couple of additional methods:
Now about Android, it's actually should be quite easy. Export project as Android project, copy and paste everything from Gideros installation folder/sdk/include to project's jni folder.
Create Android.mk file with minimum this contents:
And either set it up like this: http://mobilepearls.com/labs/ndk-builder-in-eclipse/
Or navigate through command line to your project's jni folder and run ndk-build
And that should be it. Your project's libs folder should contain so files in each proper armeabi folder.
But what you try to accomplish (clipping) I think may not be possible, due to probably that it uses openGL to draw and in Gideros case, the Gideros openGL surface is drawing api is not exposed, so it won't work. There is a plan to expose it in the future, but then probable even more modification must be needed for current available library.
this may be quite enough for a start. you say that lua binding to use with gideros differs from lua binding in general (or that it is not a universal thing to bind, it depends on usage). so is there some general rule how to do the binding for gideros? or what you wrote above is basically all of that (remove initialization, add gideros.h and the above mentioned additional methods)?
sidenote about the clipping libraries:
about clipping, the nice thing is that this is a clipping library for polygons as data structures, so it is opengl etc independent. once clipping is computed using this library theoretically we get back a polygon data (union of polygons actually), e.g. the list of the triangles of one of its triangulations and then we can use gideros meshes to render this fast even on current gideros version. this should be good for colored meshes, if one wants texturing, then it should be again relatively easy to compute the texture coordinates of the vertices and thus for each vertex of each triangle in the mesh.
overall this shall be a useful library for other people too, i want to use it to make a 2d dynamic lighting/shadow engine, but my plans are rather theoretical at this point, i even did not make up my mind about which framework to use. i prefer gideros, but lack of info about the time of appearance of desktop export takes me back a little, so i contemplate haxenme as well. anyway most probably i won't start to realize the project soon, but i had a basic tech-demo years ago with as3 and i thought that maybe i can rewrite it more efficiently, now using gideros and one such clipping library (previously i used blending modes to emulate clipping in as3, but that was incredibly slow) just to see whether it could perform well on mobiles.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
And yes, that probably should be the basic to replace for Gideros, but based on other bindings there might be different specifics, as there are more than one way to bind something.
If you run into trouble, you can post here and I'll try to help as much as I could
Fragmenter - animated loop machine and IKONOMIKON - the memory game