A simple example of a rotating 3D cube using OpenGL 3.3, GLFW, and C++.
The project will not work without this. I cannot do this for you.
- Go to https://glad.dav1d.de/
- Language: C/C++
- Specification: OpenGL
- API: gl -> Version 3.3 (Profile: Core)
- Options: Check Generate a loader
- Click Generate
- Download the zip file (
glad.zip) - Extract the contents.
- Copy the folders
includeandsrcfrom the zip into thelibs/glad/folder of this project.- CHECK: You must have
libs/glad/include/glad/glad.h - CHECK: You must have
libs/glad/src/glad.c
- CHECK: You must have
This is the easiest way on Windows.
- Open Visual Studio (2019 or 2022).
- Select "Open a local folder".
- Navigate to this project folder (
c:/Users/nicho/source/repos/test) and select it. - Visual Studio will detect
CMakeLists.txtand configure the project automatically.- Note: If it fails, check the "Output" window. It likely means you didn't do the GLAD setup above.
- Select
OpenGLCube.exefrom the startup item dropdown (green play button). - Click Play / Start.
Only works if you have CMake installed and in your PATH.
- Open CMD or PowerShell in this folder.
- Run:
cmake -S . -B build cmake --build build - Run the game:
./build/bin/OpenGLCube.exe
- Ensure you have dependencies installed (e.g.,
build-essential,cmake,libxrandr-dev,libxinerama-dev,libxcursor-dev,libxi-dev,libgl1-mesa-dev). - Open a terminal in this folder.
- Make the build script executable:
chmod +x build_project.sh
- Run the build script:
./build_project.sh
- Or manually:
cmake -S . -B build cmake --build build ./build/bin/OpenGLCube