Skip to content

sgl-org/sgl-port-windows

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SGL Port for Windows

A Windows SDL2-based port and demo for the Simple Graphics Library (SGL).

Overview

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.

Quick Start

Tip for VS Code users: Once the environment is set up, you can build the demo instantly with Ctrl+Shift+B (default build task).

Clone the Repository

git clone https://github.com/sgl-org/sgl-port-windows.git
cd sgl-port-windows
git submodule init
git submodule update --remote

Build the Demo

Option 1: Using the build script (easiest)

1. 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

Option 2: Using make directly

Build the demo

# Ensure MinGW-w64 is in your PATH, then:
cd demo
make -j8
or
mingw32-make -j8

Run the Demo

make run
or
mingw32-make run

Or directly:

build\sgl_simulator.exe

Prerequisites

This project requires 64-bit MinGW-w64 (not 32-bit MinGW) because the included SDL2 libraries are compiled for 64-bit Windows.

Recommended: MSYS2 with MinGW-w64

  1. Download and install MSYS2
  2. Open "MSYS2 MSYS" from the Start menu
  3. Update the package database:
    pacman -Syu
  4. Install the required toolchain:
    pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-make
  5. Add C:\msys64\mingw64\bin to your system PATH environment variable

Project Structure

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

Features

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

Building from Scratch

Clean Build

cd demo
make clean
make -j8

Build Targets

  • make or make all - Build the executable
  • make clean - Remove all build artifacts
  • make run - Build and run the application

Troubleshooting

Error: "File format not recognized" or "undefined reference to SDL_*"

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.

Error: "gcc: command not found"

MinGW-w64 is not in your PATH. Either:

  • Use build.bat which handles PATH setup automatically
  • Add C:\msys64\mingw64\bin to your system PATH
  • Run from MSYS2 MinGW 64-bit shell

Application won't start or SDL2.dll missing

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\

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.

License

See the LICENSE file in the SGL submodule for library licensing information.

Related Projects

Additional Documentation

For more detailed build instructions, troubleshooting, and configuration options, see demo/BUILD.md.

About

A windows demo for SGL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors