slages / love-imgui

imgui module for the LÖVE game engine
MIT License
318 stars 61 forks source link

Use love classes instead of using SDL directly #1

Closed ficoos closed 8 years ago

ficoos commented 8 years ago

This should make this library a bit more portable with other implementations of love that doesn't use SDL (though not 100% due to love's internal design)

This method should also allow using love::graphics directly instead of going through Lua to build the mesh and set the render state.

to build:

LOVE_DIR=<PATH_TO_LOVE_SOURCES> cmake ..
slages commented 8 years ago

Thanks a lot for the request, I would love to take this route and directly link with LOVE to use its classes, but unfortunately this version doesn't build under Windows, as LOVE does not export its functions/classes with dllexport to be able to make them available on Windows. So without quite some modifications to LOVE I can't merge this version.

Anyway I'll definitely need to get rid of the SDL2 dependency, but in the same way as the graphics calls, I'll need to get the data I need trought lua scripts, it's the only portable way to do it for now.

ficoos commented 8 years ago

That's too bad, I think Love has a really good base API and adding C++ extensions will benefit it very much. It's too bad it isn't built for it.

slages commented 8 years ago

Yep I totally agree, I even tried on my side to use this CMake feature before going for the lua path: https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature But unfortunately it doesn't work out of of box, it also requires some modifications to the sources, and it creates a much larger Windows dll (like 10x larger), which will be redhibitory to most users.

ficoos commented 8 years ago

MOAI does this thing where you can add plugins when configuring the build [1]. This will build it as part of the main binary.

The main problem with Love is that a lot of things regarding the Lua bindings are defined in a central location. This means that extensions can't easily be added without changing some global data structures. There needs to be some work so you can add a module only with code in that module.

I think this might be the way to do and will also work for mobile platforms when static linking as the preferable way to do things.

Maybe we need to open an issue on the main Love bitbucket. Might be something to do for 0.11.0 .

[1] https://github.com/moai/moai-dev/wiki/Using-External-Plugins

slages commented 8 years ago

Yes feel free to open an issue, a system comparable to MOAI allowing to easily build static plugins would be great. Even if it won't help us here, as anyway exporting engine features with dllexport is clearly not in the philosophy of LOVE, as it's meant to be used in Lua, so even if static linking is possible, if we want this plugin to work when dynamically linked, we still need to go through the Lua path.