GLFW-Skia C++ Template - Docker Container
ℹ️ Introduction
This is a template C++ project using the GLFW and Skia libraries (built from source) to create a cross-platform graphical user interface (GUI) for Windows and Linux. It uses CMake as the build system and includes a Skia-based sample application to demonstrate integration.
The project is preconfigured with:
- Visual Studio Code launch and task files for streamlined development.
- A
CMakePresets.jsonfile for easy integration with Visual Studio 2022/2026 on Windows. - Build instruction for building the GLFW and Skia libraries from source.
- A sample (template) project with source using GLFW and Skia.
⚙️🏃♂️ Library Setup Instructions
⏱️ Note: Building GLFW and Skia from source is a comprehensive process that can take some time (especially Windows Skia). Follow the detailed setup guides below. To access the installation instructions, use one of the links below. For more details, read the rest of this document.
| Platform | Purpose | Setup Guide | Agent Mode (experimental) |
|---|---|---|---|
| 🪟 Windows | Native development, VS Code, debugging | Windows Setup | 💫 VSC Agent Mode Windows |
| 🐧 WSL Linux | Cross-platform builds, Linux testing | Linux Setup | 💫 VSC Agent Mode Linux |
| *Both setups work together — you'll develop on Windows but can build/test on Linux seamlessly. | |||
⚙️🏃♂️ Building the sample project
A sample project is included and can be used after the above libraries are set up. For build instructions, see:
| 📚 Other Instructions (next step) | |
|---|---|
| Build & use the Sample Template Project | Instructions Here |
📦 More about GLFW & Skia
This project uses two complementary, cross-platform libraries: GLFW for creating windows, managing graphics contexts, and handling user input, and Skia for high-performance, hardware-accelerated 2D drawing. GLFW focuses on windowing and input management without providing graphics rendering itself, which is why Skia is used to handle all rendering of text, images, and shapes with GPU acceleration. Together, they provide a robust foundation for building responsive and visually rich applications across Windows, Linux, and macOS.
GLFW, Windowing & Input
GLFW is a lightweight, cross-platform library. It’s commonly used for building real-time applications like games, simulations, and custom GUI frameworks. It provides:
- OpenGL - OpenGL ES, and Vulkan context creation
- Window - creation and management
- Input - handling (keyboard, mouse, etc.)
Skia, 2D Graphics Engine
Skia is a high-performance 2D graphics library. It supports text rendering, vector shapes, images, gradients, and more, all with hardware acceleration. In this project, Skia handles all 2D drawing, while GLFW handles the window and input. Note that it is also used by: Google Chrome, Flutter, Mozilla Firefox (Canvas API)
- Backend flexibility – Unified API for CPU/GPU via OpenGL, Vulkan, Metal, or software.
- Precision rendering – Anti-aliased text, vector shapes, and subpixel accuracy.
- Versatile output – Renders to OpenGL surfaces, images, PDFs, or SVG.
🧰 Skia Build Requirements:
Skia library build requires
📚 Python 3
📚 Git
📚 Depot Tools
📚 Ninja build system
These dependencies must be installed and configured following the detailed setup procedures linked above. The Skia build process is comprehensive and involves cloning the repository, syncing dependencies, and building with specific configurations.
⚠️ OpenGL vs Vulkan Compatibility Notes
OpenGL or Vulkan
Both GLFW and Skia support OpenGL or Vulkan, but they must be configured to use the same graphics API.
For OpenGL, Skia uses classes like GrGLInterface, GrBackendRenderTarget, and GrDirectContext.
For Vulkan, Skia uses GrVkBackendContext and Vulkan-specific setup.
Skia’s API is mostly consistent across backends, so much of your drawing code stays the same, only the backend setup differs.
Choice The sample in this project assumes you use OpenGL because it’s simpler, mature, cross-platform, and well-supported by Skia and GLFW.
Converting Converting from OpenGL to Vulkan in this project is doable with some effort; it mainly involves changing the graphics backend initialization and context management (GLFW). Skia’s drawing code remains unchanged.
Supporting macOS is more challenging because Apple chose to not support Vulkan and instead reinvent the wheel with their own Metal API, making things harder for cross-platform developers.
⚠️ Common Setup Pitfalls
Windows-specific issues to avoid:
- Path length limits – Skia builds can fail with “file name too long” errors. Use short paths like
C:\libs\skia - 🚫 ninja.exe vs ninja.bat – Ensure the official
ninja.exeis first in your PATH, notdepot_tools\ninja.bat - 🚫 Old environment variables – Previous Skia builds can leave conflicting EMSDK variables
- ⏱️ Build time – Skia builds can take significant time; plan accordingly
- 🚫 Spaces in paths – Avoid spaces or special characters in project paths
See the detailed setup guides for complete troubleshooting information.
⚡The Template Project Architecture
This template consists of a template project for building a GUI control sample application based on the GLFW library and the Skia library. Supporting both Windows and Linux (Debian 12) operating systems. For Windows, the MSBuild toolchain of Visual Studio 2022/2026 Community Edition is used, and for Debian the GNU Compiler Collection is used.
The folder structure ( some folders and files are not include because they are Github specific files(layout ect.) :
📁 Project
├──📂.vscode ➜ VSC Tasks & Launchers
├──📂_README ➜ Documentation
│ └──🧾 README.md ➜ The readme instruction file (this file)
├──📂cmake ➜ Specialized, customizable, CMake files for Windows and Linux
│ ├──📦CMakeLists_Init-env.bat➜ Path to env variables for MS VC compiler(vcvars64.bat)
│ ├──📦CMakeLists_start.sh.in ➜ Creates startup app logic in Linux builds
│ ├──📦linux.cmake ➜ The file to customize for Linux builds
│ ├──📦linux_utilities.cmake ➜ Linux utilities to display hard/software info.
│ └──📦windows.cmake ➜ The file to customize for Windows builds
├──📂dependencies/win ➜ Dependent libraries needed for the source like GLFW & Skia
│ ├──📂win ➜ Windows location for specialized libs
│ │ └──📂Your Lib ➜ Add libraries you need here
│ └──📂linux ➜ Linux location for specialized libs
│ └──📂Your Lib ➜ Add libraries you need here
├──📂src ➜ GLFW and Skia sample source
├──⚡build.ps1 ➜ Windows script to invoke the build
├──⚡build.sh ➜ Linux script to invoke the build
├──📦CMakeLists.txt ➜ Main CMake file
├──📦CMakePresets.json ➜ Used to load the project in Visual Studio 2022
Libraries: OpenGL, OpenGL ES, and Vulkan
Both GLFW and Skia support OpenGL or Vulkan, but they must be configured to use the same graphics API.
- For OpenGL, Skia uses classes like
GrGLInterface,GrBackendRenderTarget, andGrDirectContext. - For Vulkan, Skia uses
GrVkBackendContextand Vulkan-specific setup.
Skia’s API is mostly consistent across backends, so much of your drawing code stays the same, only the backend setup differs.
Decision in this project
The sample is this project assume you use OpenGL because it’s simpler, mature, cross-platform, and well-supported by Skia and GLFW.
Converting
Converting from OpenGL to Vulkan in this project is doable with some effort; it mainly involves changing the graphics backend initialization and context management (GLFW). Skia’s drawing code remains unchanged.
MacOS specifics
Supporting macOS is more challenging because Apple chose to not support Vulkan and instead reinvent the wheel with their own Metal API, making things harder for drawing cross-platform developers.
License
This file is part of: GLFW-Skia C++ Template Stack Copyright (c) 2025-2026 Nico Jan Eelhart.This repository is MIT licensed and free to use. For optional commercial support, customization, training, or long-term maintenance, see COMMERCIAL.md.
─── ✦ ───