CMake-based implementation of TheCherno's OpenGL series with minimal code deviance according to videos.
- C++ 17
- CMake - cross-platform build system
- cross-platform dependencies handling
- tested on:
- Windows 10 -
Visual Studio 2022
,VS Code v1.86
:MSVC
19.34,Clang
17.0.4,GCC
13.2 (Rev2, Built by MSYS2 project) - Linux Mint 20 -
VS Code v1.75
:GCC
9.4,Clang
10.0 - MacOS (Mac Mini M2) -
VS Code
:GCC
,Apple-Clang
- Windows 10 -
- perfect commits - reached through git-history rewriting
- pros: clean diffs between commits (best for learn-repositories)
- pros: no typo/logic fixing or improving separate commits
- cons: unstable (ever changing) commit hashes and timestamps
- commands:
rebase -i <commit>~
/rebase -i --root
; (then followstatus
hints)git rm <submodule_path>
# the only way to change submodule <name> fieldgit filter-repo --refs <branch> --replace-text <(echo 'regex:Dependencies/==>deps/')
git filter-repo --refs <branch> --replace-text <(echo 'regex:^\xEF\xBB\xBF==>')
# strip BOM- see doc/note.sh for other commands and use cases
- git submodules - each dependency present as a submodule
- much clear dependency-introduction commits
- up-to-date source of dependencies' repositories
- no need for additional downloads during the install stage
- header-only due to my laziness :) - more compact codebase 👍
- error-logging - debug output with
GL_KHR_debug
:glDebugMessageCallback()
(if possible):- debugging stuff moved from
Renderer.hpp
to newUtility.hpp
- detailed GPU-vendor error description with debug output:
- can be implemented in OpenGL versions prior to 4.3 (by GPU-vendor)
- worked on OpenGL 4.0 (Intel CPU) (on old tiny laptop)
- debugging stuff moved from
- imgui docking branch - allows moving imgui-windows outside and to dock them to each other
- batch rendering episodes - adopted with last 4 commits
- The Cherno explained with non-related source code (repository)
- some stl::type_traits related bragging 😎 (
Utility.hpp
:GLASSERT(<gl_(un)signed_int_ret>)
macro)
- headers-definitions (without sources), single
.cpp
file withint main()
- maybe allows to switch easier to the
C++20 modules
- maybe allows to switch easier to the
All concerns can be expressed via GitHub Project's Issues (one issue per concern)
git clone --recurse --shallow-submodules "https://github.com/Challanger524/ChernoOpenGL-CMake.git"
- CMake - cross-platform build automation system
- (for minimal version see CMakeLists.txt#L1)
- Ninja - small build system with a focus on speed
- C++ compiler (any): MSVC / GCC / Clang
- on GNU Linux:
- install dev libs listed below and/or google CMake log for other required
sudo apt-get install
:libxi-dev libxrandr-dev libxcursor-dev libxinerama-dev libopengl-dev
Visual Studio
Official documentation: CMake projects in Visual Studio
C++ CMake tools for Windows
module must be installed (see docs Installation part)
- open the project folder with Visual Studio (and enable CMake via dialog prompt, if any)
- in the upper toolbar choose
MSVC
configuration - Project->Configure ChernoOpenGL
- Build->Build All
- set
CMakeLists.txt
as Startup Item via Solution Explorer (or see Debugging CMake projects part) - Debug->Start Debugging
VS Code
Official documentation: Get started with CMake Tools on Linux (less suitable article then as for Visual Studio)
1.
C/C++
and 2.CMake Tools
extensions (by Microsoft) must be installed (see docs Prerequisites part)
Note: on Windows...
when building with msvc
preset, to rid off unconfigured preset messages - you need to run VS Code from a Developer Command Prompt for Visual Studio
I created a shorcut to launch VS Code with next Target
:
%comspec% /C "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" & code
with
/C
option it should close itself automatically, but sometimes it is not - so just close it manually after VS Code launched.
- open the project folder
- configure from preset via dialog (CMake) prompt, or:
- select preset - open Command Palette (
Ctrl+Shift+P
) and typeCMake: Select Configure Preset
then choose suitable - configure - open Command Palette (
Ctrl+Shift+P
) and typeCMake: Configure
(if not started automatically)
- select preset - open Command Palette (
- build - open Command Palette (
Ctrl+Shift+P
) and typeCMake: Build
(or press a build (:radio_button:) button in the bottom toolbar) - run:
- debug - open Command Palette (
Ctrl+Shift+P
) and typeCMake: Debug
(or pressF5
) (or press a debug 🐛 (near▶️ ) in the bottom toolbar) - launch (if debug is unavailable) -
Menu Bar->Run->Run Without Debugging
(orCtrl+F5
) (or▶️ button in the bottom toolbar)
- debug - open Command Palette (
Command Line
Presets were introduced in
CMake 3.19
cmake --list-presets
cmake --preset <preset>
ninja -C out/build/<preset>
./ChernoOpenGL
(or./ChernoOpenGL.exe
on shWindows)
MS Windows 10 (NVIDIA GTX 1060)
Info: Context: Debug - active (supported)
Info: GL: Extension: GL_KHR_debug - OK
Info: GLFW version: 3.4.0 Win32 WGL Null EGL OSMesa MinGW-w64
Info: GLEW version: 2.2.0
Info: GL version: 3.3.0 NVIDIA 537.34
Info: GLSL version: 3.30 NVIDIA via Cg compiler
Info: GPU vendor : NVIDIA Corporation
Info: Renderer : NVIDIA GeForce GTX 1060 3GB/PCIe/SSE2
Info: ImGui version: 1.90.4 +docking +viewport
Trace: Registering test: Clear Color
Trace: Registering test: Texture 2D
Trace: Registering test: Batching
Trace: Registering test: Batching Textures
Trace: Registering test: Batching Textures (dynamic)
Apple Mac Mini M2
Info: Context: Debug - inactive (or unsupported)
Info: GLFW version: 3.4.0 Cocoa NSGL Null EGL OSMesa monotonic
Info: GLEW version: 2.2.0
Info: GL version: 4.1 Metal - 88
Info: GLSL version: 4.10
Info: GPU vendor : Apple
Info: Renderer : Apple M2
Info: ImGui version: 1.90.4 +docking +viewport
Trace: Registering test: Clear Color
Trace: Registering test: Texture 2D
Trace: Registering test: Batching
Trace: Registering test: Batching Textures
Cherno
Hazel
logos andEducational aspect
of the source code - belongs to Yan Chernikov TheCherno the way YouTube OpenGL series doesrestoration
polishing
fixing
(over)correcting
(for_perfectiest_solution) researhing
(folder) structuring/renaming
dependency managing
perfect git-history keeping
doc/ -umenting
CMake -ing
readme.md composing
.editorconfig -ing
.gitignore -ing
cross-platform -ing
codestyling
- was done (outprocrastinated and overthinked) by Daniil Semenenko Challanger524- other
tools
sources
materials
are not hided or appropriated (at least not intentionally) and are provided withlinks
to the originalsources
whenever possible - additional thanks to speauty's ChernoOpenGL implementation for working and mostly accurate code, that was used as a reference for clarification of certain moments and typos, that greatly saved some of my time.
Changelog: doc/changelog.md
- It took a bit more than a month to finish this project and half a day to port on Linux (and a week to polish all warnings and complete documentation)
- And it took years to polish it all 😐🚬
- This project helped me to cure 👨⚕️ my 👩💻
git-
andcmake-anxiety
;) - Cherno is the only and the best C++ teacher, see also his C++ playlist.
- Motto: "in case of anything - stay ironically-cynic and/or cynically-ironic
¯\_(ツ)_/¯
🃏"