contrib/
: External dependencies likeglew
,freeglut
andglm
src/
: C++ and GLSL source codesCMakeLists.txt
: Lists of all examplescommon.h
: common header used by the examplescommon_tessellation.h
: common header used by the tesselation executablesmain.cpp
: Main function driver codemain_tessellation.cpp
: Main function driver code for the tesselation examplesexample0/
:.cpp
and GLSL shader filesCMakeLists.txt
: contains example-specific configurations, including which file to compile and settting working directory for Visual Studio or XCode*.cpp
and shaders
CMakeLists.txt
: CMake rules to find dependenciescmake/
: CMake helper macros
- Delete unused targets from
src/
, andsrc/CMakeLists.txt
- Rename the target folder, and change folder name accordingly in
src/CMakeLists.txt
For example, ifsrc/example0
was renamed tosrc/Assignment1
, then insrc/CMakeLists.txt
, lineshould beadd_subdirectory(example0)
add_subdirectory(Assignment1)
- Inside the target folder, change filenames in
CMakeLists.txt
For example, givenAssignment1.cpp
andAssignment1.hpp
,src/Assignment1/CMakeLists.txt
should be modified fromtotarget_sources(${TARGET_NAME} PUBLIC FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/.. FILES ../common.h) # more headers go here target_sources(${TARGET_NAME} PUBLIC example0.cpp) # C++ codes go here
target_sources(${TARGET_NAME} PUBLIC FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/.. FILES ../common.h Assignment1.hpp) # more headers go here target_sources(${TARGET_NAME} PUBLIC Assignment1.cpp) # C++ codes go here
- Inside the top-level
CMakeLists.txt
, modify the linetoset_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT example0)
in order to set targetset_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Assignment1)
Assignment1
as the startup project in Visual Studio.
Make sure you have a recent and working C++ compiler, and CMake version 3.23+.
Most of the dependencies are build out-of-tree and installed at contrib/install
. CMake is told to find dependencies from here.
Official GLEW repo: https://github.com/nigels-com/glew
- Very bad CMake support
- Source is generated using Unix-only tools and very complicated
- It's better to take the binaries instead of compiling.
- For Windows:
- Download the latest Win32 binary
- Copy
lib/Release/x64/glew32s.lib
from the ZIP file tocontrib/install/lib
- For dynamic linkage, copy
lib/Release/x64/glew32.lib
from the ZIP file tocontrib/install/lib
, andbin/Release/x64/glew32.dll
from the ZIP file tocontrib/install/bin
- For macOS and Linux:
Install binary packages from their respective package manager, see Linux/Unix specific
- For Windows:
Regardless of platform, run this:
cd contrib
# GLM
cmake -B buildglm -S glm -DCMAKE_INSTALL_PREFIX="./install"
cmake --buildglm build --config Release
# FreeGLUT
cmake -B buildfreeglut -S glm -DCMAKE_INSTALL_PREFIX="./install"
cmake --build buildfreeglut --config Release
macOS and Linux can install binary packages of FreeGLUT from their respective package manager instead of compiling it, see Linux/Unix specific
For all platforms:
cmake -B build -S . # configure
cmake --build build # build
There are a few configure options available:
Option | Description | Default Value |
---|---|---|
OPENMP |
Use OpenMP acceleration, can siginificantly speed up rendering, especially for raytracer | ON except MSVC |
STATIC_GLEW |
Link to static verion of GLEW | ON except Linux |
STATIC_FREEGLUT |
Link to static verion of FreeGLUT | ON except Linux |
Configure using these options like this:
cmake -B build -S . -DOPENMP=OFF
To run the compiled executables:
# change to glsl directory
cd src/example0
# run the executable from where the GLSL shaders are
../../build/example0
- You can open
build/COMP4490.sln
using Visual Studio. Each executable insrc/
should be a project inside the solution - Make sure the the startup project is assigned to a project other than
ALL_BUILD
andZERO_CHECK
.
You can open build/COMP4490.xcodeproj
using XCode.
OpenGL related libraries are to be installed via their respective package manager first.
For Ubuntu, the following packages need to be installed:
libglu1-mesa-dev freeglut3-dev mesa-common-dev libglew-dev
If using Ninja or Makefile as generator, regardless of IDE or editor you are using, please make sure the working directory to where your GLSL shaders are (in this case, where your .cpp
files are) before debugging and running.