This project is licensed under the MIT License. See LICENSE for details.
A sample Libretro core demonstrating OpenGL rendering of a rotating RGB triangle with a red background. This project is designed as a minimal example for developers learning to create contentless Libretro cores using OpenGL Core 3.3. It is tested with RetroArch 1.21.0 on Windows.
- Renders a rotating RGB triangle (red, green, blue vertices) on a red background.
- Uses OpenGL Core 3.3 with GLEW for function loading.
- Contentless core (no ROM or content required).
- Configured for 800x600 resolution with a 4:3 aspect ratio.
- Operating System: Windows 10/11 (64-bit).
- Compiler: Visual Studio 2022 with C++ Desktop Development workload.
- CMake: Version 3.20 or higher.
- RetroArch: Version 1.21.0 or later, installed at
D:\dev\RetroArch-Win64
. - Git: For cloning dependencies.
- GLEW: OpenGL Extension Wrangler Library (fetched via CMake).
- linmath.h: Lightweight math library for matrix operations (fetched via CMake).
git clone https://github.com/Lightnet/libretro_core_triangle_glew.git
bat
build.bat
Current set to Debug to log console.
Download RetroArch binary for testing in case of fail open application.
Run RetroArch to set up files and folders.
- Copy build\Debug\triangle_libretro.dll to ''\RetroArch-Win64\cores.
- Launch RetroArch with verbose logging:
powershell
cd D:\dev\RetroArch-Win64
.\retroarch.exe -v > log.txt 2>&1
-
In RetroArch:
- Go to Main Menu > Load Core > Triangle Core.
- Select Start Core.
-
Verify:
- A rotating RGB triangle with a red background appears.
- src/main.c: Core implementation, handling Libretro lifecycle and OpenGL rendering.
- build/_deps/linmath-src/linmath.h: Matrix math library.
- build/_deps/glew-src/: GLEW library for OpenGL extensions.
- CMakeLists.txt: CMake configuration for building the core.
-
SET_HW_RENDER Placement:
- This core places SET_HW_RENDER in retro_init instead of the standard retro_set_environment. This works with RetroArch 1.21.0 for contentless cores but may not be compatible with other frontends or versions.
- Testing showed that SET_HW_RENDER in retro_set_environment caused [libretro] Failed to set HW render, likely due to lifecycle differences for contentless cores.
-
Contentless Core:
- The core uses RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME to run without content, simplifying retro_load_game.
- Setting auto_run_contentless_cores = false prevents RetroArch from running a dummy core prematurely.
If [INFO] [slang]: Building pass #0 (N/A) appears in log.txt:
- Verify video_shader_enable = false and video_shader = "" in retroarch.cfg.
- Check D:\dev\RetroArch-Win64\shaders for .slangp files and remove them.
- In RetroArch, ensure Settings > Video > Shaders > Load Shader Preset is None.
If [libretro] Failed to set HW render occurs:
- Keep SET_HW_RENDER in retro_init (current setup).
- Avoid moving it to retro_set_environment unless testing with other frontends.
To debug the core:
- Open build\my_libretro_core.sln in Visual Studio 2022.
- Set triangle_core as the startup project.
- Configure debugging:
- Command: D:\dev\RetroArch-Win64\retroarch.exe
- Arguments: -v
- Working Directory: D:\dev\RetroArch-Win64
- Set breakpoints in retro_init, retro_load_game, or retro_run.
- Run in Debug mode (F5) to inspect the lifecycle or OpenGL errors.
- Add input handling (e.g., keyboard controls to adjust triangle rotation).
- Support additional OpenGL features (e.g., textures, lighting).
- Test with other Libretro frontends to validate retro_init vs. retro_set_environment.
- Optimize shaders or add more complex geometry.
- Libretro documentation: https://docs.libretro.com/
- RetroArch team for the frontend.
- GLEW and linmath.h contributors.
- https://bitbucket.org/Themaister/libretro-gl/src/master/
- point out the how to set up opengl