This repository contains simple OpenGL 3.3 examples for educational purposes.
All examples are written in C++11 and use Makefiles AND CMake build system. Additionally the following dependencies are required:
On Linux install the following dependencies using your package manager, for example on Ubuntu do:
sudo apt-get install libglew-dev libglfw3-dev libglm-dev
On OSX install Homebrew package manager and install
brew install glm glfw3 glew
Additionally you can also install CMake and use it to generate project files for your IDE of choice.
Recommended for OSX and Linux is to simply use make. For Windows see next section.
cd ppgso/src
make
./gl_gradient
Windows is a special case as always, however it is a lot easier if you avoid Visual Studio entirely. The recommended software is as follows:
- Download and install TDM64, this is the latest GCC compiler for Windows in a nice installer.
- Download CLion IDE, the trial is free for 30days and you can register for a FREE COPY using university mail.
- Run CLion and open this directory as project, it should be ready to go.
- For some examples you need to set working directory to the project folder.
A good alternative IDE for Windows is QTCreator that should work out of the box with TDM64 and CMake. For other IDEs see below.
Using CMake from commandline you can generate the project files as shown below. The placeholder [YOUR_GENERATOR] should be replaced with the generator appropriate for your IDE/environment. Usually removing the option entirely will generate the default for the given platform. To find out all available generators just run cmake --help
cd ppgso
mkdir _build && cd _build
cmake .. -G[YOUR_GENERATOR] -DCMAKE_INSTALL_PREFIX=../_install
cmake --build . --target install
When building on Windows CMake might not be able to automatically find all the needed dependencies and will rerquire additional pointers. This is done by setting CMake variables such as GLEW_INCLUDE_DIRS which should point to the headers of the glew library that you want to use. Same principle applies for other dependencies. You can alternaticely use cmake GUI and point it to the work directory, it will allow you to edit the variables more comfortably.
cd ppgso/_build
cmake .. -DGLFW_INCLUDE_DIRS="C:\libs\glfw3\include" -DGLFW_LIBRARIES="C:\libs\glfw3\glfw3.dll" -DGLEW_INCLUDE_DIRS=...
cmake --build . --target install
After installation the files should be installed into a new _install
subdirectory. You can then run the examples as follows:
cd ppgso/_install
./gl_gradient