Libretro used in "New Retro Arcade" - how did they do that?

Well actually i wanted to use DOSBOX in UE4 to load some old DOS applications on a computer in my level for a few cheap laughs. I was looking for an emulator plugin within UE4, but nothing is released so far. I stumbled upon the “New Retro Arcade” project - these guys made a libretro plugin for UE4, but needless to say that they didn’t release any sources or so.

there is a DOSBOX dll for libretro, so if i could make a plugin like the guys from that project then that would work.

Any clues on how to start? Is there some plugin i could use as a base? I thought i could just direct the plugin output onto a procedural texture, but i never made a plugin for UE4 yet, so I am looking for similar material to look at. Any ideas, comments or advise?

I wish I knew, a tutorial would be amazing!

To make a virtual emulator you would need to:
-Forward input from UE4 to the library/dll
-Get a texture from lib/dll and set and update a UE4 Texture
-Optionally: encapsulate it as a plugin for drag and drop

Check your library for the API for both getting a texture and function calls for passing in input.

To incorporate a dll into a plugin there are a few approaches, there are some good wiki resources for this:
-A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums and use the plugin wizard to start the plugin code.
-A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums - for linking a dll in UE4

In terms of textures, if you can get RGB values in an array or a raw buffer, you can set a UTexture2D from that. Somewhere in your plugin call a function every frame to fetch the latest texture data and update the UE4 texture values/pointers. Usually I then turn that into an event so that you can just subscribe to the event and always get the latest data pushed to you. Then if you have any material set to use that texture as a sample, it will be updated correctly whenever the contents change. Anything with that material will then become your virtual screen.
See an old example here: leap-ue4/LeapImage.cpp at master · getnamo/leap-ue4 · GitHub where I copy RGB values as a buffer into a RGBA format UTexture2D.

If you need better performance (and less impact on say your game thread), consider using ENQUEUE_UNIQUE_RENDER_COMMAND e.g. BLUI/BluEye.cpp at master · ashea-code/BLUI · GitHub which will update the texture in the render thread, in this particular instance it will only update the regions that changed.

That should be most of it. Feel free to look into any of my plugins for reference implementations, they all come with source.

That said keep in mind that libretro and dosbox are both GPL projects. These are incompatible with UE4 license if you include them as a dll or if you statically link them in a plugin and you may need to look for a more liberally licensed project.

Thank you! This gives me a great starting point to work from! How does New Retro Arcade get around the licensing issue? Is that why they require libretro to be downloaded separately?

Have you made any progress with this? I’m trying to make a game with a flight simulator with some of Unreal’s VR functionality but I want to be able to use some older flight sims.