A Windows SDL2-based port and demo for the Simple Graphics Library (SGL).
This repository provides a Windows implementation of SGL using SDL2 as the graphics backend. It includes a complete demo application showcasing various SGL features including widgets, graphics primitives, and user interface elements.
Tip for VS Code users: Once the environment is set up, you can build the demo instantly with Ctrl+Shift+B (default build task).
git clone https://github.com/sgl-org/sgl-port-windows.git
cd sgl-port-windows
git submodule init
git submodule update --remote1. Enter demo directory
2. run build.bat script
The script automatically detects and sets up the correct MinGW-w64 toolchain, and run the exe app
# Ensure MinGW-w64 is in your PATH, then:
cd demo
make -j8
or
mingw32-make -j8
make run
or
mingw32-make runOr directly:
build\sgl_simulator.exeThis project requires 64-bit MinGW-w64 (not 32-bit MinGW) because the included SDL2 libraries are compiled for 64-bit Windows.
- Download and install MSYS2
- Open "MSYS2 MSYS" from the Start menu
- Update the package database:
pacman -Syu
- Install the required toolchain:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-make
- Add
C:\msys64\mingw64\binto your system PATH environment variable
sgl-port-windows/
├── demo/ # Demo application
│ ├── main.c # Main application entry point
│ ├── sgl_port_sdl2.c # SDL2 port implementation
│ ├── test.c # Test/demo code
│ ├── bg.c # Background rendering
│ ├── sdl/ # SDL2 library (headers, libs, DLLs)
│ ├── Makefile # Build configuration
│ ├── build.bat # Windows build script
│ └── BUILD.md # Detailed build instructions
└── sgl/ # SGL library (git submodule)
└── source/ # SGL source code
The demo showcases:
- Various SGL widgets (buttons, sliders, checkboxes, text input, etc.)
- Graphics primitives (lines, rectangles, circles, arcs, rings)
- Text rendering with multiple fonts
- Event handling (mouse and keyboard input)
- Memory management with lwmem
- Animation support
cd demo
make clean
make -j8makeormake all- Build the executablemake clean- Remove all build artifactsmake run- Build and run the application
You're using 32-bit MinGW instead of 64-bit MinGW-w64. The SDL2 libraries in this project are built for x86_64 (64-bit). Install MSYS2 with MinGW-w64 as described in the Prerequisites section.
MinGW-w64 is not in your PATH. Either:
- Use
build.batwhich handles PATH setup automatically - Add
C:\msys64\mingw64\binto your system PATH - Run from MSYS2 MinGW 64-bit shell
The SDL2.dll should be automatically copied to the build directory when you run make or make run. If it's missing, manually copy it:
copy sdl\bin\SDL2.dll build\Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.
See the LICENSE file in the SGL submodule for library licensing information.
- SGL (Simple Graphics Library) - The main SGL library
- SDL2 - Simple DirectMedia Layer
For more detailed build instructions, troubleshooting, and configuration options, see demo/BUILD.md.