This is a GLFW-based program that demonstrates OpenGL context creation, GLSL shader compilation, geometry upload, and rendering. It is intended to be used as a starting-point for developing a Minimal, Complete, and Verifiable Example (MCVE) or Short, Self Contained, Correct (Compilable), Example (SSCCE) for sites like Stack Overflow.
Common OpenGL-related dependencies are included as git submodules and are built using CMake:
- GLFW: Cross-platform window & OpenGL context management
- GLAD: OpenGL function/extension loader
- GLM: C++ vector/matrix math library with syntax & semantics that mirror GLSL's
- stb-image: Image file loader/decoder library
- C++11 compiler
- CMake >= 3.7.2
- CMake-compatible build system/IDE
- Functioning OpenGL drivers for your GPU (though Mesa's software renderer can be used in a pinch)
Clone, configure, and build:
git clone --recursive https://github.com/genpfault/glfw-mcve-base.git
cd glfw-mcve-base
mkdir build
cd build
cmake ../
cmake --build .
-
-G "<generator name>"
, selects a generator:If you don't like the build system CMake defaults to you can use
-G
to select another generator. You can see the list of available generators by usingcmake --help
Examples:
cmake ../ -G "Unix Makefiles" cmake ../ -G "Ninja"
For Visual Studio generators you can use
CMAKE_GENERATOR_PLATFORM
to select between 32-bit & 64-bit:cmake ../ -G "Visual Studio 15 2017" -DCMAKE_GENERATOR_PLATFORM=Win32 cmake ../ -G "Visual Studio 15 2017" -DCMAKE_GENERATOR_PLATFORM=x64
-
Controls debug/optimization options. Values:
- Debug
- Release
- RelWithDebInfo
- MinSizeRel
Examples:
cmake ../ -DCMAKE_BUILD_TYPE=Debug cmake ../ -DCMAKE_BUILD_TYPE=Release
-
CMAKE_C_COMPILER
/CMAKE_CXX_COMPILER
:Which compiler to use. Helpful to switch between gcc/clang on Unix-y systems:
cmake ../ -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ cmake ../ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++