This repository contains simple OpenGL 3.3 examples for educational purposes.
All examples are written in C++11 and use 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 tap homebrew/versions
brew install glm glfw3 glew
You can also install CMake and use it to generate project files for your IDE of choice.
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 select TDM64 as the toolchain (default is C:/TDM64..)
- Setup the rest of the settings as you see fit.
- Open this directory as an existing project, all the examples should now build.
- For some examples you need to set working directory to the
_install
folder that can be generated by building therun_install
target.
A good alternative IDE for Windows is QTCreator that should work out of the box with TDM64 and CMake. For other IDEs see below.
When using CLion you should first build the run_install
target. This will generate a installation with all resources present in a {project_root}/_install
folder. After that set the working direcotry to this folder for each target manually.
- NEVER store projects in paths and directories that contain spaces or non-ascii characters.
- If you are unfortunate enough to have a Windows username with non-ascii characters builds will fail unless you edit CLion configuration manually.
# Edit idea.properties file in CLion install directory and add
idea.system.path=C:/clion/system
# Make sure the directory exists
-
Ubuntu 14.04 based distributions do not have GLFW3!
- Install libglfw3 deb then install libglfw3-dev
-
My linux does not have OpenGL, missing -lGL
- Try to install
mesa-common-dev
,libgl1-mesa-dev
andlibglu1-mesa-dev
- Try to install
Using CMake from command-line 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]
cmake --build . --target install
When building on Windows CMake might not be able to automatically find all the needed dependencies and will require 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 alternatively 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"
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
Rudolf Getel for free ship model.
- GLM official documentation and samples
- GLFW official documentation and guide
- GLEW use guide
- CMake basic use and tutorial