No description
Find a file
2025-12-18 18:20:33 +05:30
assets project structure refactor 2025-12-13 05:09:22 +05:30
cmake build cglm as a static library as it benefits from the simd optimizations 2025-12-18 06:20:41 +05:30
libs include GNUInstallDirs in libs/glad/CMakeLists.txt 2025-12-18 03:46:09 +05:30
scripts add a shell-file for local testing & a README to generate artifacts for website 2025-12-17 00:59:58 +05:30
source compiler specific defines don't exist until the project command is executed 2025-12-18 06:10:02 +05:30
.clang-format clang-format indent PPDirectives 2025-12-13 10:11:44 +05:30
.editorconfig initial commit 2025-11-08 08:47:32 +05:30
.gitattributes update .gitattributes, no-one-knows what's in the update :) 2025-11-30 12:02:53 +05:30
.gitignore add graphviz subdirectory 2025-12-14 08:38:50 +05:30
.gitmodules remove libs/glad; we need a custom one to generate dlls 2025-12-18 00:33:18 +05:30
CMakeLists.txt compiler specific defines don't exist until the project command is executed 2025-12-18 06:10:02 +05:30
Makefile update readme & use makefile for local builds 2025-12-17 05:41:03 +05:30
README.md we now build shared libraries both on windows and on linux (not wasm) 2025-12-18 18:20:33 +05:30
UNLICENSE add unlicense 2025-12-02 09:50:40 +05:30

LearnOpenGL

Project Structure

The project uses external libraries cloned as git submodules in /libs directory. Common project assets like logo are stored in /assets, CMake specific files live in /cmake and these include header only projects, config template files, graph generation steps etc. /source contains all the source files

The project is organized into modules like source/core, source/loader, source/tutorials. core provides the core functionality like windowing and logging while loader as the name suggests, provids the loading functionality. core and loader are built as libraries used by executable modules in the tutorials module.

 assets
 cmake
 libs
 scripts
 source
│  core
│ │  include
│ │  source
│ │  CMakeLists.txt
│  loader
│ │  include
│ │  source
│ │  CMakeLists.txt
│ ...
│  tutorials
│ │  hello-triangle
│ │ │  assets
│ │ │  source
│ │ │  CMakeLists.txt
│ │ │ 󰂺 README.md
│ │ ...
 CMakeLists.txt

Emscripten Specific Details

The cmake build files use if (EMSCRIPTEN) conditional blocks to separate normal build commands from wasm specific commands. Each tutorial generates three files index.{html,js,wasm}. These are copied over to prefix/bin/${tutorial} directory during installation.

Tutorial specific asset files live in the tutorial's local assets directory while common assets live in the /assets directory. Both can be accessed from within the build tutorials using ASSETS_DIR and COMMON_ASSETS_DIR definitions respectively. This way asset location can be changed just by changing the build files.

Code Usage:

shader = shCreateFromFile(
    ASSETS_DIR "shaders/shader.vert",
    ASSETS_DIR "shaders/shader.frag"
);

Wasm builds use the scripts/index.html shell file by default unless USE_GENERATED_INDEX_HTML:BOOLEAN GENERATED_GRAPHICS_DIR_PATH:STRING are defined. These allow us to use a different shell file. You can also see each tutorial has a README.md file with a similar header.

---
title: Hello Triangle
date: 2025-12-17
---

{{ include(path="/canvas.md") }}

This is some dummy text, should be removed later.

This README.md file is copied over to my [website] which then uses zola (a static site generator) to generate a new shell file. Then the wasm/html files are generated using the generated shell file & finally everything is copied & deployed on the website. See scripts and the gitlab-ci file for more details.

Dependencies

See dependencies.sh, it's a shell script to install all the required dependencies on archlinux and MSYS2 (Winodws). I will later create a dependencies.bat file to install dependencies on windows.

How to Build

cd learnopengl
cmake -B build -S .                    # for normal build
emcmake cmake -B build -S .            # for wasm build
cmake --build build -j $(nproc)        # build
cmake --install build --prefix install # install