An open API service indexing awesome lists of open source software.

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

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

![MIT License](https://img.shields.io/badge/License-MIT-green) ![Commercial Services Available](https://img.shields.io/badge/Services-Optional-blue)
![Platform](https://img.shields.io/badge/Platform-Windows%20%7C%20Linux-brightgreen)
![C++](https://img.shields.io/badge/C++-17-blue.svg)

## ℹ️ 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

---





WSL Template Stacks



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

─── ✦ ───