Libretro

From Official Kodi Wiki
Revision as of 21:24, 21 May 2020 by Karellen (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Home icon grey.png   ▶ Kodi Game ▶ Libretro

Kodi's Game API has Libretro Wrapper which is 1:1 compatibility with the libretro API, and all libretro cores can be ported game add-ons for Kodi. Libretro itself is a well defined cross-platform platform interface to handle the communication between a frontend (Kodi with RetroPlayer) and an Emulator Core (e.g. nestopia). Kodi uses libretro but libretro is its own seperate open source project developed by independent developers.

For more detailed information about libretro please visit their website at:


What is libretro?

Download the RetroArch/Libretro Technical Brochure (PDF) from libretro.org website

Libretro is a simple lightweight C/C++ API that allows for the creation of games and emulators. It is very simple in nature, yet very powerful. The simplicity of it all requires some explanation in order to truly grasp how useful it can be to your own projects. It works according to backend/frontend principle. Backend application talks with frontend by way of API. Facilitates input/audio/video/camera/location streams for use in games/media-players/graphics applications. With added value (shaders, rewinding, input support, etc).

When you choose to use the libretro API, your program gets turned into a single library file (called a ‘libretro core’). A frontend that supports the libretro API can then load that library file and run the app. The frontend’s responsibility is to provide all the implementation-specific details, such as video/audio/input drivers. The libretro core’s responsibility is solely to provide the main program. You therefore don’t have to worry about writing different video drivers for Direct3D, OpenGL or worrying about catering to all possible input APIs/sound APIs/supporting all known joypads/etc. This is none of your concern at the libretro core implementation level.

Any project that is ported to work with this API can be made to run on ANY libretro frontend – now and forever. You maintain a single codebase that only deals with the main program, and you then target one single API (libretro) in order to port your program over to multiple platforms at once.

Other projects benefit from our ever-expanding libretro core software library by implementing the libretro API inside their own projects. To this end, project such as Kodi (XBMC Foundation) have written a libretro wrapper/driver which follows the same concept as the reference libretro frontend, RetroArch.

Kodi's (with RetroPlayer) is frontend for Libretro. RetroArch is the official reference frontend, and it is only for gaming and is meant to be fast, simple, yet powerful, and is available on nearly all modern-day platforms. Other third-party platform-specific frontends for Libretro are currently in development, including Arcan and Minir. For more checkout: https://www.libretro.com/index.php/powered-by-libretro/

Who Uses Libretro?

While the most common use case for libretro has been console emulation, it is equally suited as a platform for almost any 2D game. For example, the NX Engine used in the popular freeware game Cave Story has been successfully ported to libretro, open sourced games like Quake and Doom have been ported to libretro, and the new freeware game Dinothawr supports libretro natively.

Libretro GL/GLES/Vulkan

Aside from retro-style games and emulators that depend on software rendering and where you’d typically need nothing more than the ability to render to a framebuffer, the Libretro API also allows you to target OpenGL, OpenGL ES (GLES), and Vulkan. This allows you to create libretro ports that use OpenGL, OpenGL ES (GLES), or Vulkan as part of their internal rendering.

From a portability perspective, we highly recommend that you try to target both so that your libretro GL port will work on both mobile (OpenGL ES) and desktop (OpenGL) computers.

Why Should Developers Target Libretro?

Software that targets the libretro API instantly gains access to all of the platforms that have libretro frontends available. That means your game is immediately available to those platforms’ users without worrying about input/audio/video drivers, compatibility issues or the myriad quirks of the underlying host system(s). Likewise, there’s no need to write specialized GUI code for each platform or to use esoteric–and often buggy–cross-platform toolkits, like Qt and GTK+.

Furthermore, once your game supports libretro, all of the libretro frontends’ other features come along for free, such as RetroArch’s real-time rewind, lag-concealing netplay, lossless video recording/streaming and cutting-edge post-processing shader support.

Perhaps best of all: libretro is an open specification that is 100% free to implement, with no licensing fees or hidden strings attached.

If you’d like to learn more about libretro, leave us a comment or chat with us on IRC at #retroarch on Freenode.

Libretro’s design goals

Libretro is the library programming interface. Programs get ported to this library and can then be run with any libretro-compatible frontend.

Our reference frontend is RetroArch. The two projects are not the same, and this is reflected in the licensing as well. RetroArch sticks to GPL version 3 whereas the libretro API is a MIT-licensed API.

Some of the design goals for libretro

* Allow a non-kitchensink approach to crossplatform portability.
* Allow a non-dependency heavy approach to crossplatform portability. Stick to just one header containing definitions for the necessary audio/video/input callbacks.
* Care about being backwards compatible. Libretro’s ABI( Application Binary Interface) has never been broken in years, and old libretro frontends from years ago in most cases can still use libretro cores being created today.
* By its very design enables programs to be ported to singular dynamic libraries which can then be loaded in and out of frontend applications thanks to the libretro API.
* Forces you by its design to rethink what code belongs to ‘core land’ and what should belong to ‘frontend land’. Libretro cores ideally should have minimal to no dependencies on any system/OS-specific APIs so that the same libretro cores can work on any libretro-compatible frontend.
* Designed with games, emulators and multimedia in mind. Libretro core ports resemble ports being done to standalone game consoles or mobile where the primary input device is not a keyboard and mouse (although libretro supports those as well).
* Does not concern itself with external WIMP GUIs (since they are not portable), or anything that would tie itself to mainly desktop PC-usage. Libretro cores ideally have to work seamlessly on mobile, desktop PC and game consoles.
* Requires you to link your libretro-ported program to a libretro frontend, leaves the libretro frontend creation part up to you or lets you select one of the mature libretro frontends already available.

See also

External Links