This is template OpenGL cmake project for project for computer graphics course in gist.
Due to the scope of the lecture, the OpenGL version is intentionally set to 3.1.
You should install CMake and Git on your system. Other libraries will be installed automatically.
- CMake, Install it your self
- Git, Install it your self
- glfw , Windowing library
- glad, OpenGL function loading library
- glm, Math library for OpenGL and GLSL shader
- tinyobjloader, Minimal Wavefront .obj file loading library
- python, Python(GLAD) use python to load opengl functions
Use git recursive clone to download the template.
You should use Your link in your repository.
git clone --recursive https://github.com/YOUR-ASSIGNMENT-REPO/glskeleton.git
-
Create build folder in project root
-
Run cmake gui(Configure and Generate)
You need to re-run cmake whenever you add more source files (*.h, *.cpp) See more deatil about this at here.
Set source code directory to project-root.
Set build directory to project-root/build.
- Configure
- Generate
-
Build the project
-
Go to build folder
-
Open glSkeleton.sln file
-
Make glSkeleton as startup project and build it
After the build process you will get directory structure like this.
.
├── build
│ ├── CMakeFiles
│ ├── bin # you can find your executable here
│ ├── extern
│ ├── lib # you can find your static libraries
│ ├── src
│ └── glskeleton.sln # your project file
├── extern # external projects
│ ├── CMakeLists.txt # DO NOT TOUCH THIS
│ ├── glad
│ ├── glm
│ └── tinyobjloader
├── doc # your report/report template
└── src # your source code
└── CMakeLists.txt
└── CMakeLists.txt
12 directories
- Run cmake
You need to re-run cmake command whenever you add more source files (*.h, *.cpp) See more deatil about this at here.
cd <PROJECT_ROOT>
mkdir build
cd build
cmake ..
- Build and compile
make -j4
After the build process you will get directory structure like this.
.
├── build
│ ├── CMakeFiles
│ ├── bin # you can find your executable here
│ ├── extern
│ ├── lib # you can find your static libraries
│ └── src
├── extern # external projects
│ ├── CMakeLists.txt # DO NOT TOUCH THIS
│ ├── glad
│ ├── glm
│ └── tinyobjloader
├── doc # your report/report template
└── src # your source code
└── CMakeLists.txt
└── CMakeLists.txt
12 directories
If you want to add more sources to build your executable, see following instruction
- Open the CMakeLists.txt in src folder
- Add your sources (headers(.h) or sources(.cpp))
add_executable(glskeleton
main.cpp
...
your_source_file.h
your_source_file.cpp
...
)
- Rerun cmake (See here for details)
- Open the CMakeLists.txt in project root
- Change the string in project function
project(glskeleton) # Change this
- Open the CMakeLists.txt in src folder
- Change the glskeleton to
add_executable(glskeleton # Change this word
main.cpp
...
)
If you didn't use recursive option when you cloned the repo, you should init and update submodules by following commands.
git submodule init
git submodule update
WARNING, if you are taking our course, you should not change the OpenGL version
Go to src/main.cpp. Edit following lines.
Original
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE);
OpenGL 4.5 with core profile
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);