https://github.com/nicojane/wsl-development-stack-glfw-skia-cpp-template
C++, template, GLFW, SKIA, WSL, Linux, Windows
https://github.com/nicojane/wsl-development-stack-glfw-skia-cpp-template
cmake cpp cross-platform debian glfw gui linux skia windows wsl2
Last synced: 2 months ago
JSON representation
C++, template, GLFW, SKIA, WSL, Linux, Windows
- Host: GitHub
- URL: https://github.com/nicojane/wsl-development-stack-glfw-skia-cpp-template
- Owner: NicoJanE
- Created: 2025-07-10T12:03:24.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2025-07-11T13:44:49.000Z (12 months ago)
- Last Synced: 2025-07-11T15:04:21.588Z (12 months ago)
- Topics: cmake, cpp, cross-platform, debian, glfw, gui, linux, skia, windows, wsl2
- Language: CMake
- Homepage: https://nicojane.github.io/WSL-Development-Stack-GLFW-Skia-CPP-Template/
- Size: 48.8 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
π Table of Contents
- [Introduction](#introduction)
- [Quick Setup](#qsetup)
- [Libraries GLFW & Skia](#lib)
- [The Template Project Architecture](#temp)
- [More Instructions](#more)
# 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.json` file 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 significant time (especially 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
πͺ 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
β¨ General
General Information
General Page Index
*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)
Document type
Location
Project Build Instruction
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](https://www.glfw.org/) is a lightweight, cross-platform library. Itβs commonly used for building real-time applications like games, simulations, and custom GUI frameworks. It provides:
- **OpenG**L - OpenGL ES, and Vulkan context creation
- **Window** - creation and management
- **Input** - handling (keyboard, mouse, etc.)
#### Skia, 2D Graphics Engine
[Skia](https://skia.org/) 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.exe` is first in your PATH, not `depot_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
---
License
This file is part of: GLFW-Skia C++ Template Stack Copyright (c) 2025-2026 Nico Jan Eelhart. This repository is MIT licensedand free to use. For optional commercial support, customization, training, or long-term maintenance, see COMMERCIAL.md
βββ β¦ βββ