By Squarepusher

RetroArch 0.9.9 (to be released later this week) will introduce an important new feature to the libretro API that I’m sure a lot of developers will be interested in.

To date, all libretro cores have used software rendered video. Sure, the frontend (RetroArch in this case) has hardware accelerated drivers (such as an OpenGL driver or a Direct3D driver), but all that really guarantees is that blitting is going through a few API functions that might (or might not ) be hardware accelerated depending on the driver supplied by the vendor. But generally speaking, libretro cores for emulators/games that depend on hardware-accelerated 3D (such as Dolphin, PCSX2, and even N64 emus) were previously impossible on RetroArch.

This is no longer the case with libretro GL. Libretro GL is not a new API – it is merely an extension to the libretro API (that doesn’t break ABI) which allows you to write OpenGL 2.0/ES 2.0 compliant code inside your libretro core.

The way this works is that at the final end of the chain inside the libretro core, everything gets rendered to an FBO (Frame Buffer Object), and this in turn will be passed back to the frontend for final processing.

Which platforms does libretro GL support right now?
The OpenGL subset we are targeting for libretro GL is either OpenGL 2.0 (on desktop) and/or OpenGL ES 2.0 (mobile and/or desktop PC in case you’re using bleeding-edge MESA drivers). This means that any platform that has at least support for either OpenGL 2.0 or OpenGL ES 2.0 should be capable of running libretro cores that depend on GL features.

The following platforms right now are supported:

  • Android
  • iOS
  • Blackberry QNX (BB10/Playbook)
  • Pandora (not tested yet)
  • PC (Windows/UNIX/OSX)

Fixed function or programmable pipeline?

With RetroArch 0.9.9, we will finally support all of the major mobile phone/tablet operating systems (except for Windows RT). This means that your libretro port can now reach a much bigger audience than just PC and/or game consoles.

All of the mobile phones/tablets out on the market today support at least OpenGL ES 2.0 (and in most cases with added extensions support). OpenGL ES 2.0 requires that you move away from deprecated fixed function GL programming. This might be an initial learning curve but the added platform support should eventually be worth it.

Note that nothing is stopping you from writing fixed function GL code – it should theoretically run on RetroArch for PC. However, this would be a bad design decision from a portability perspective since it will automatically cut off all the mobile platforms from being able to run your libretro core.

What about Direct3D / other unsupported platforms right now?

Looking at all the devices out there, it seems pretty clear that the industry as a whole has decided to throw its collective weight behind OpenGL. We therefore (for now) have made the conscious decision not to provide a similar context for Direct3D.

The downsides of this is that it automatically cuts off Xbox 360 support since Direct3D 9 is used for the XDK. I am not sure if it would make sense to eventually provide something similar for D3D or if it would be possible to somehow make a wrapper (from GL ES 2.0/GL 2.0 to D3D9) – but for now Direct3D support is out.

For the time being – PS3 support is out as well. Sony’s implementation of OpenGL (PSGL) was never made OpenGL ES 2.0-compliant – what it is currently is a mishmash of OpenGL ES 1.x and a lot of proprietary performance-related extensions. I found some undocumented functions inside that hinted at some kind of preliminary GL ES 2.0 support, but for now I’m not really confident we can make PSGL work as a GL ES 2.0 backend.

Obviously it is unfortunate that PS3 and Xbox 360 are cut off right now – the two being the only programmable pipeline consoles out there. But OpenGL ES 1.x would just be too limiting (which is what we have on PS3), and Direct3D really is only available on Xbox consoles and Windows/RT at this point – for now it doesn’t really make much sense to us to make a totally different backend just for D3D since on a Windows PC you still have the option of using OpenGL.

How do I make a libretro GL core?

Maister wrote a simple tutorial that should walk you through the steps to get started with making your own libretro GL core.

Link: Implementing a Hardware Accelerated Libretro Core

Maister also made two test cores (ModelViewer and SceneWalker) that shows off what you can do in libretro GL. These two will be the subject of a subsequent article, so stay tuned…

4 thoughts on “Libretro GL starting from RetroArch 0.9.9

  1. I have a problem here:
    I have a JXD S7300 with sxelrom rom 3.0 and patch 3.5 installed, and when I map the physical buttons the dpad does not work. Only the left analog stick works and even then only up and left. The other buttons work perfectly. Otherwise the emulator is great, congratulations to the developers.

    1. The controls don’t work fine with autodetection turned on?

  2. when i turn on nothing works.

  3. Will GL support be added to the current cores (i.e. Genesis and others) to be hardware accelerated too?

Comments are closed.