Open-source project
McNopper/OpenGL avatar
McNopper/OpenGL

McNopper/OpenGL: 52 GLSL Examples for OpenGL 3 and 4

OpenGL 3 and 4 examples using GLSL

2,609 stars689 forksCMIT

At a glance

What is it?
A C-language teaching repository that pairs each OpenGL 3.x and 4.x feature with a small, buildable example, from a first triangle to compute shaders and 3D Gaussian splatting. The trade-off is that it is a reference collection, not a framework.
Who is it for?
Adopt it if you learn OpenGL by reading complete, compilable programs and want one example per technique rather than a tutorial series. Skip it if you need a maintained rendering framework, a stable API to build a product on, or a codebase with versioned guarantees beyond the tagged releases.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 6 days ago.
What is it written in?
Mainly C, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 24, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What McNopper/OpenGL Is For

The repository is a set of 52 numbered C programs, each demonstrating one OpenGL technique with GLSL shaders. The README lists them from Example01, a basic window and OpenGL 3 initialization, through Example52, 3D Gaussian Splatting with view-direction spherical-harmonics rotation. In between sit the usual teaching milestones: a triangle, a grey filter, a Phong-lit sphere, normal mapping, cube mapping, GPU particles, a geometry shader, reflection and refraction, shadow mapping, tessellation, terrain, water, model loading, clipping planes, render-to-texture, compute shaders, shadow volumes and displacement mapping.

That numbering is the organising idea. Each directory is self-contained enough to read on its own, and the progression means you can pick the technique you need instead of working through a book. The audience is someone who already writes C or C++ and wants to see how a specific OpenGL feature is wired up: which buffers get created, what the shader stages look like, and how the draw call is issued. It is not aimed at people who want a scene graph or a renderer they can drop into an application.

How the Examples Are Built and What GLUS Provides

The root CMakeLists.txt drives everything. Dependencies are downloaded and built through CMake FetchContent, and the README names them: GLFW 3.4 for windowing and input, GLEW 2.2.0 as the extension wrangler, and GLUS, which is the author's own utility library. GLUS is taken from a sibling local checkout at ../GLUS when one exists, otherwise fetched from github.com/McNopper/GLUS. That sibling-first behaviour matters if you keep both repositories side by side for development.

GLUS is not incidental. Version v3.2.0 migrated the glTF examples, 48 through 52, onto the GLUS glTF 2.0 loader through glusGltfLoadScene and glusGltfGetCgltfData, and the copied OpenGL/GLUS/ folder was removed. GLUS now supplies cgltf and stb_image and exposes its shader directory through the GLUS_SHADER_DIR compile definition. The current changelog entry, v3.2.2, requires GLUS v1.1.2 and EGL v1.0.9, and pins both to tagged releases after Example50's EGL had been tracking a moving main ref.

Data flow is the standard immediate-mode pattern: the application creates a window through GLFW, loads entry points through GLEW, builds vertex and index buffers, compiles GLSL shaders, and renders in a loop. The examples do not hide this behind an abstraction layer, which is the point.

Building It and Running Your First Example

Prerequisites are CMake 3.14 or higher, a C/C++ compiler (Visual Studio 2013+ on Windows, GCC or Clang on Linux, Xcode Command Line Tools on macOS), Git, and an OpenGL 3.2+ capable driver. The README suggests verifying the toolchain first:

bash
cmake --version
git --version

The first should report 3.14 or higher. Then configure and build. On Linux or macOS the README gives:

bash
mkdir build && cd build
cmake ..
make

On Windows with Visual Studio the equivalent is:

bash
mkdir build && cd build
cmake ..
cmake --build .

Executables land in the Binaries/ directory, which is also a top-level entry in the repository. Run the first one to confirm the toolchain end to end; Example01 is described in the README as a basic window and OpenGL 3 initialization, so a successful run is a window that opens and clears. If it fails, the README's prerequisite list points at the driver rather than the build, since GLFW and GLEW are fetched automatically and OpenGL itself is the system library.

The Changelog Is the Most Useful Part of the Documentation

Most example repositories rot silently. This one records what was wrong. Version v3.2.1 is a security and correctness pass across all 52 examples, and the entries are specific: Example36's SSBO allocation used a std430 stride of 24 bytes instead of 32, leaving it 25 percent undersized; missing glMemoryBarrier calls were added in Examples 21, 30, 36 and 45; Example15 passed a float count to glUniform4fv and glUniform2fv where vec4 and vec2 elements were meant; 900 KB stack arrays in Examples 29 and 37 moved to static storage; glDeleteRenderbuffers was being called on texture names in Examples 12 and 34.

That list is a fair description of the failure modes these examples had, and it is also a warning. Code copied from an older checkout carries those bugs. The same release replaced the deprecated FetchContent_Populate in the root CMakeLists.txt and added return-value checks at 316 GLUS call sites. Version v3.2.2 continued with dependency pinning, widened count * stride products, parenthesised negative #define literals in Examples 24, 30 and 46, and added cppcheck and clang-tidy analysis lanes plus an AGENTS.md file. If you vendor any example, start from the current tag.

Where This Repository Is the Wrong Tool

The examples are demonstrations, not a library. There is no public API to link against, no versioning promise on the example code itself, and no deprecation policy. If you need rendering inside a shipping application, copying Example12's shadow mapping or Example36's SSBO setup means you own that code from then on, including the fixes listed above.

The hardware floor is another boundary. The README requires an OpenGL 3.2+ driver, and the example list marks several entries as OpenGL 4.1 or 4.3: tessellation and terrain are 4.1, compute shaders are 4.3. On a machine that only reaches 3.3, the later examples will not run, and the README does not document a fallback path. The build also assumes a normal desktop toolchain; the documentation covers Windows, Linux and macOS, and says nothing about Android or a mobile GLES target, so the OpenGL ES questions that surround the OpenGL name do not apply here.

Finally, the README does not document rollback, per-example troubleshooting, or what to do when a driver rejects a shader. When something fails, the changelog and the source are the documentation.

Compared With a Framework Like SDL or a Modern API

The nearest alternative in the search data is SDL, and the difference is scope. SDL is a cross-platform windowing and input library that you link against and keep; McNopper/OpenGL is a set of programs you read. SDL does not teach you what a framebuffer completeness check looks like, and this repository does, down to the FBO checks added in Examples 09, 33, 48, 49 and 50.

Against Vulkan, the split is the same one the examples make explicit. OpenGL's driver does the state management and validation for you, which is why each example here fits in one directory; Vulkan asks the application to do that work, and a comparable example would be several times longer. That is a reason to learn here first and a reason not to treat these programs as a migration path. If your goal is a modern explicit API, this repository teaches the concepts, not the API.

Licence and Maintenance Cost

The project is distributed under the MIT License, with the LICENSE file at the repository root. That covers the example code. It does not cover everything you get when you build: GLUS is also MIT but bundles glfw, glew, cgltf and stb, whose notices live in GLUS's THIRD-PARTY.md. The dependencies and assets added by this repository, McNopper/EGL (MIT) and the Einstein and phoenix 3D models (CC-BY-4.0), are documented in this repository's THIRD-PARTY.md, with per-example attributions in the README. The CC-BY-4.0 models carry an attribution requirement that MIT does not, so check that file before redistributing assets. None of this is legal advice.

The upgrade cost is real but bounded. Because GLUS is pulled by FetchContent and pinned to tagged releases, moving forward means moving GLUS and EGL together: v3.2.0 requires GLUS v1.1.0, v3.2.1 requires v1.1.1, v3.2.2 requires v1.1.2 and EGL v1.0.9. If you keep a sibling ../GLUS checkout, the build prefers it, which is convenient for development and a trap for reproducible builds. The last push to the repository was on 2026-09-24, and the most recent release is v3.2.1 from 2026-08-01, so the changelog describes work that is ahead of the tagged releases.

Editorial conclusion

Adopt it if you learn OpenGL by reading complete, compilable programs and want one example per technique rather than a tutorial series. Skip it if you need a maintained rendering framework, a stable API to build a product on, or a codebase with versioned guarantees beyond the tagged releases. Before relying on any example, check the example directory itself, confirm your driver reports OpenGL 3.2 or higher, and note that examples 21 and above require OpenGL 4.3 or 4.1 class hardware.

Frequently asked questions

What is McNopper/OpenGL and what is it used for?

It is a C repository of 52 OpenGL 3 and OpenGL 4 examples written with GLSL shaders, each demonstrating one technique from a basic window up to compute shaders and 3D Gaussian splatting. It is used for learning how a specific OpenGL feature is set up in a complete, compilable program.

How do I install and build McNopper/OpenGL?

Install CMake 3.14 or higher, a C/C++ compiler and Git, then create a build directory, run cmake .. and build with make on Linux or macOS or cmake --build . on Windows. GLFW, GLEW and GLUS are downloaded and built automatically through CMake FetchContent, and the executables appear in the Binaries/ directory.

Can I use McNopper/OpenGL examples in C++ or from Visual Studio?

The examples are written in C and the README lists Visual Studio 2013+ (MSVC) as a supported Windows compiler, with the build configured by CMake. The README does not document a separate C++ or Visual Studio Code workflow.

Official sources

  1. Issues
  2. License: MIT
  3. McNopper/OpenGL on GitHub
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/mcnopper-opengl.svg)](https://hysenlabs.com/projects/mcnopper-opengl)