Theme Catppuccin
Make yourself at homeCatppuccin

A softer light for long learning sessions.

Appearance

Loading your preference…

Dark palette

Choose a dark palette to try it.

Light uses Latte. Your choices stay in this browser.

Back to your source shelf

Inside the companion

The Shader Workshop

Open a native OpenGL window, draw a triangle, then move a camera around three exhibits.

Project files 8

Connect the OpenGL dependencies

Discover GLFW, GLEW, and OpenGL; build the starter and CPU contract checks.

37 lines CMakeLists.txt
cmake_minimum_required(VERSION 3.25)
project(ChromaticObservatory VERSION 0.1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(OBSERVATORY_SANITIZERS "Enable address and undefined-behavior sanitizers" OFF)
if(OBSERVATORY_SANITIZERS)
  if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
    message(FATAL_ERROR "This sanitizer recipe requires Clang or GCC")
  endif()
  add_compile_options(-fsanitize=address,undefined -fno-omit-frame-pointer)
  add_link_options(-fsanitize=address,undefined)
endif()

# Dependencies are discovered locally. Configuration never downloads or installs.
find_package(OpenGL REQUIRED)
find_package(glfw3 3.3 CONFIG REQUIRED)
find_package(GLEW REQUIRED)

add_executable(observatory main.cpp)
target_link_libraries(observatory PRIVATE glfw GLEW::GLEW OpenGL::GL)
target_compile_definitions(observatory PRIVATE
  OBSERVATORY_SHADER_DIR="${CMAKE_CURRENT_SOURCE_DIR}/shaders")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
  target_compile_options(observatory PRIVATE -Wall -Wextra -Wpedantic -Wconversion -Wshadow)
endif()

include(CTest)
if(BUILD_TESTING)
  add_executable(observatory-contracts contracts_test.cpp)
  if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
    target_compile_options(observatory-contracts PRIVATE -Wall -Wextra -Wpedantic -Wconversion -Wshadow)
  endif()
  add_test(NAME observatory-cpu-contracts COMMAND observatory-contracts)
  # Context creation is deliberately a manual test, not a hidden display requirement.
endif()

This is the file included with the course. Copy and download give you its complete source.

Taking your work offline? Download all course companions