Using OpenGL and Assimp in a Qt Widget application to render 3D models / practice writing GLSL shaders
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.4 KiB


Practice project for learning about using OpenGL in Qt widget applications. Model loader using Assimp within a Qt widget application.

You can import your own models within mainwdget.cpp, inside the MainWidget::initObjects() function. I've commented throughout the code there to explain which model or example I'm modifying. Rotations and translations happen in MainWidget::update(), to get textures loading on models look into material files and see some examples in the resources/models/ directory. For more in-depth examples, see scene.h and scene.cpp

Can be built with cmake manually or using Qt Creator. For the build to be successful, I've found through testing on VMs that the system requires around 6GB of RAM. This is mostly due to the large .obj files that are built into the project using Qt Resource System

This project has been ported to Qt6, which is not yet available in Ubuntu apt repositories. To run this project, you will need to install Qt6 Open Source Binaries for your system. Be sure to take note of the Qt6 installation directory, as we will need it to correctly set our CMAKE_PREFIX_PATH in the next steps.

Once Qt6 is installed, to build and run qtk on Ubuntu -

sudo apt update -y && sudo apt install freeglut3-dev libassimp-dev cmake build-essential git
git clone
cmake -DCMAKE_PREFIX_PATH=$HOME/Qt/6.3.1/gcc_64 -S qtk/ -B qtk/build/ && cmake --build qtk/build/ -j $(nprocs)

You can fly around the scene if you hold the right mouse button and use WASD. If you see a small triangle floating by a model it represents the light source that is being used for the shader rendering the model. These appear on models using phong, specular, and diffuse lighting techniques.

Spartan with no normals -

Spartan with normals -

Model Artists

"Alien Hominid" ( by Nwilly_art is licensed under Creative Commons Attribution (

"Scythe World Of Warcraft" ( by Warcraft-3D-Models is licensed under Creative Commons Attribution (

"Spartan Armour MKV - Halo Reach" ( by McCarthy3D is licensed under Creative Commons Attribution (

"Survival Guitar Backpack (Low Poly)" ( by Berk Gedik is licensed under Creative Commons Attribution ( Model by Berk Gedik, from: Modified ( material assignment (Joey de Vries) for easier load in OpenGL model loading chapter, and renamed albedo to diffuse and metallic to specular to match non-PBR lighting setup.

"Terror-bird (NHMW-Geo 2012/0007/0001)" ( by Natural History Museum Vienna is licensed under Creative Commons Attribution-NonCommercial (

"Golden Lion Sitting OBJ Low Poly FREE" ( by LordSamueliSolo is licensed under Creative Commons Attribution (