I had some initial success by adding an Effekseer runtime and building it in the love repo, though there's still a lot of things to fix and improve. Basically I took Examples/OpenGL/main.cpp and put the Manager class as an object inside graphics/opengl/Graphics.cpp in love. In lua, you can do:
Code: Select all
function love.load(args)
manager = love.graphics.getEffectManager()
effect = love.graphics.newEffect("efk/Laser01.efk")
end
function love.keypressed(key, unicode)
if key == 'space' then
effect:play(0, 0, 0)
end
end
function love.update(dt)
manager:update(dt)
end
function love.draw()
-- Effects are drawn automatically by love
end
My WIP is available in the effekseer branch here:
https://github.com/gittup/love/tree/effekseer
Here's an example image from the attached effekseer.love file:
- Example image
- effekseer.png (225.69 KiB) Viewed 14852 times
The two red things are regular pngs drawn with love.graphics.draw(), and the green things are drawn with Effekseer.
Note that I don't think this is the right approach overall, but it was the first way that I tried that actually successfully showed an effect on screen. I'd love to get some help properly integrating it into love. A few issues I ran into:
1) I haven't been able to fully integrate Effekseer's rendering with love's. I first tried making the manager object something that you create from love.load() or somewhere, rather than building it into Graphics.cpp. However, when I called draw() on the manager, it was making direct OpenGL calls that then got overwritten by Graphics::draw(). I was hoping to do something like this in order to draw the effects at a layer of my choosing:
Code: Select all
function love.draw()
love.graphics.draw(img1)
love.graphics.draw(manager)
love.graphics.draw(img2)
end
But unfortunately the image draws don't actually get drawn until later, while the effekseer manager gets rendered immediately. This meant the effects were always drawn behind everything. The hack of putting the manager code inside Graphics.cpp was intended to work around this, so the effects are basically drawn after everything else.
I think the right approach probably involves writing a custom renderer to replace EffekseerRendererGL.Renderer.cpp so that it can render things in a way love understands. I don't understand this well enough to know for sure, though.
2) Possibly related to 1), but when rendering shaders, effekseer calls glUseProgram(some number), and then when it closes out the shaders, it calls glUseProgram(0). This ended up causing everything rendered by love to not show up. I put a hack in to find out which program love was expecting it to be (it was number 3), and set it back to that after rendering the effekseer manager.
3) Also maybe related to rendering, I left in hard-coded values for setting the projection/camera matrices (these come from the effekseer example code). Obviously that needs to hook into love's matrices, or something.
Those are the main issues I'm aware of. Even after that there's a bunch of (easier) work adding extra wrappers to manipulate effects and such, but I wanted to share this initial success and see if anyone else can help with the hard parts
Some other notes:
- I think I was able to successfully get Effekseer's image loading working with love's filesystem code (this is what LoveTextureLoader / LoveEffectLoader are for). That enables the newEffect('file.efk') to find the efk file, and the .png files that the .efk file refers to internally.
- I left in main.lua calling manager:update(dt), since I assume the manager code would need to go back there and not be attached to Graphics.cpp. If the manager is truly internal in love, then presumably the update call could be done internally as well.