SDL2 hardware renderer doesn't work as a libretro core

I am trying to build an SDL2 project as a libretro core and I have managed to get it to work successfully with an SDL2 software renderer, but it runs very slowly. If I build the application as an executale and run it, then the hardware renderer works fine, but if I build it as a library for libretro, then it can’t render textures.

I have created a minimal example to demonstrate this, the source code is here.

Build and run both the libretro core and the executable, and you will see the exe runs fine, but the libretro core only clears the screen, but doesn’t draw the texture.

Then change the USE_HARDWARE flag here to false and then run the libretro core and the executable, and you will see that both now work perfectly.

Is there anyonw who has experience with Libretro and SDL2 that can advise me?

I don’t have any personal experience doing it, but I know for hardware rendered cores, you need to interact with them a little differently than you would software-rendered cores. That is, hardware-rendered cores need to create a framebuffer and hand that final framebuffer off to the frontend.

I’ll see if I can get anyone better to explain it :stuck_out_tongue:

That is what I have done in my example, see here.

@hunterk Are there any simple examples that you can link me to?

I asked bparker about it in discord and this was his response:

bparker: it looks like he's using gl and trying to do it that way, not via sdl itself like I thought
bparker: but I don't see in his code where he hands an FBO id off
bparker: he's trying to use the old get_hw_framebuffer or whatever it's called

Anyway, here are some helpful resources:

https://docs.libretro.com/tech/developing-cores/#resources-for-core-development

https://docs.libretro.com/tech/opengl-cores/

https://docs.libretro.com/tech/opengl-cores/#test-implementations

If you like, you can stop by our IRC or discord channels and try speaking with some folks directly.