https://github.com/robloach/raylib-libretro
libretro frontend using raylib :space_invader:
https://github.com/robloach/raylib-libretro
libretro raylib
Last synced: 11 days ago
JSON representation
libretro frontend using raylib :space_invader:
- Host: GitHub
- URL: https://github.com/robloach/raylib-libretro
- Owner: RobLoach
- License: other
- Created: 2020-04-12T20:33:15.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2026-06-05T23:09:05.000Z (16 days ago)
- Last Synced: 2026-06-05T23:12:05.458Z (16 days ago)
- Topics: libretro, raylib
- Language: C
- Homepage: https://robloach.github.io/raylib-libretro/?game=https://raw.githubusercontent.com/retrobrews/snes-games/refs/heads/master/saf.smc
- Size: 25.3 MB
- Stars: 37
- Watchers: 2
- Forks: 9
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# raylib-libretro :space_invader: [](https://github.com/RobLoach/raylib-libretro/actions)
[libretro](https://www.libretro.com/) frontend to play emulators for Windows, Mac, Linux, and the Web with [raylib](https://www.raylib.com). The [raylib-libretro.h](include/raylib-libretro.h) allows integrating any raylib application with the libretro API. *Still in early development.*

## Features
- Multi-System Emulator for NES, SNES, GB, GBA, SMS/GG, PlayStation
- Shipped Cores: fceumm, snes9x, mgba, genesis_plus_gx, prboom, pcsx_rearmed
- Gamepad, Keyboard, On-Screen Controls
- Audio
- Fast Forward, Slow Motion, Rewind
- Save Slots and SRAM
- Shaders
- Menu Themes
- Core Options
- Zip File Support
## Cores
| System | Core | Extensions |
| --- | --- | --- |
| Nintendo Entertainment System (NES)** | `fceumm` | `.fds`, `.nes`, `.unf`, `.unif` |
| Super Nintendo (SNES) | `snes9x` | `.smc`, `.sfc`, `.swc`, `.fig`, `.bs`, `.st` |
| Game Boy / Color / Advance | `mgba` | `.gba`, `.gb`, `.gbc`, `.sgb` |
| Sega Genesis / Mega Drive / Master System / Game Gear | `genesis_plus_gx` | `.bin`, `.gen`, `.smd`, `.md`, `.cue`, `.iso`, `.chd`, `.m3u`, `.sms`, `.gg`, `.sg` |
| PC Engine / TurboGrafx-16 | `mednafen_pce_fast` | `.pce`, `.cue`, `.ccd`, `.chd`, `.toc`, `.m3u` |
| WonderSwan / WonderSwan Color | `mednafen_wswan` | `.ws`, `.wsc`, `.pc2` |
| Doom (PrBoom Engine) | `prboom` | `.wad`, `.iwad`, `.pwad`, `.lmp`, `.m3u` |
| PlayStation | `pcsx_rearmed` | `.bin`, `.cue`, `.img`, `.mdf`, `.pbp`, `.toc`, `.cbn`, `.m3u`, `.ccd`, `.chd`, `.iso` |
## Usage
``` sh
raylib-libretro [-L ] [game]
```
- `[game]` can be a loose ROM file or a `.zip` archive
- `-L ` is optional — path to the libretro core (`.so`/`.dll`/`.dylib`)
### Example
```
raylib-libretro -L ~/.config/retroarch/cores/fceumm_libretro.so smb.nes
raylib-libretro -L ~/.config/retroarch/cores/fceumm_libretro.so smb.zip
raylib-libretro smb.nes
```
## Compile
[CMake](https://cmake.org) is used to build raylib-libretro...
``` sh
git clone http://github.com/robloach/raylib-libretro.git
cd raylib-libretro
git submodule update --init
mkdir build
cd build
cmake ..
make
```
### Mac OSX
- Make sure you have you have `cmake/xcode-cli-tools` installed
- Run the above compile instructions
- After installing RetroArch and some cores, you should be able to run the below:
```bash
bin/raylib-libretro -L ~/Library/Application\ Support/RetroArch/cores/fceumm_libretro.dylib ~/Desktop/smb.nes
```
## API Usage
```c
InitLibretro("fceumm.so");
LoadLibretroGame("mario.nes");
while (!WindowShouldClose()) {
UpdateLibretro();
BeginDrawing();
ClearBackground(BLACK);
DrawLibretro();
EndDrawing();
}
CloseLibretro();
```
## API Reference
See the full [API documentation](docs/API.md) for integration details, CMake setup, and function descriptions.
### Quick Reference
``` c
bool InitLibretro(const char* core);
bool LoadLibretroGame(const char* gameFile);
bool IsLibretroReady();
bool IsLibretroGameReady();
void UpdateLibretro();
bool LibretroShouldClose();
void DrawLibretro();
void DrawLibretroTint(Color tint);
void DrawLibretroEx(Vector2 position, float rotation, float scale, Color tint);
void DrawLibretroV(Vector2 position, Color tint);
void DrawLibretroTexture(int posX, int posY, Color tint);
void DrawLibretroPro(Rectangle destRec, Color tint);
const char* GetLibretroName();
const char* GetLibretroVersion();
unsigned GetLibretroWidth();
unsigned GetLibretroHeight();
unsigned GetLibretroRotation();
double GetLibretroFPS();
float GetLibretroAspectRatio();
Texture2D GetLibretroTexture();
bool IsLibretroGameRequired();
void ResetLibretro();
void UnloadLibretroGame();
void CloseLibretro();
void SetLibretroVolume(float volume);
float GetLibretroVolume();
bool SetLibretroCoreOption(const char* key, const char* value);
const char* GetLibretroCoreOption(const char* key);
void* GetLibretroSerializedData(unsigned int* size);
bool SetLibretroSerializedData(void* data, unsigned int size);
void SetLibretroMessage(const char* msg, float duration);
bool DrawLibretroMessage();
const char* GetLibretroDirectory(int directory);
```
## Development
Update the dependencies through git submodules...
```sh
git submodule update --recursive --remote --init --force
```
Use clang-format to apply coding standards...
```c
clang-format -i *.h
```
Build for web with emscripten...
```sh
mkdir build
cd build
emcmake cmake .. -DPLATFORM=Web -DCMAKE_BUILD_TYPE=Release
emmake make
```
To build the Doxygen documentation...
```sh
doxygen .Doxyfile
```
## Contributors
- [Konsumer](https://github.com/konsumer)
- [MikeDX](https://github.com/MikeDX) and [libretro-raylib](https://github.com/MikeDX/libretro-raylib)
## License
[zlib/libpng](LICENSE)