Here is a real simple example of how to build a basic project with CMake and Qt. Hopefully this should be enough to get you started. In Qt just click open project and select the CMakeLists.txt file. Select the build folder and you are done. The code structure below works with any source files in the same folder as your CMakeLists.txt file. I set it up to build to a Debug folder in the parent directory/folder of the CMakeLists.txt file.
This CMake file will build my ModernTriangle example of how to use Qt 5.5 with modern OpenGL. Skip to the bottom of this post for some more info on why you might want to use CMake with Qt Creator. Continue reading
Have a look at Part 1 if you are new to OpenGL or Qt. In Part 1 I introduced the two technologies and gave some important tips for getting started correctly. If you want to build this project with CMake and Qt Creator, here is a CMakeLists.txt file with instructions on how to do it.
Let’s get started!
This tutorial will show you how to draw a colored triangle similar to the QOpenGLWindow example that ships with Qt but using modern OpenGL. I don’t want to just explain the code, but instead plan on gathering all the little tips and gotchas I have found in order to really help you understand where to go from here. I chose to develop for OpenGL version 3.1 because that is the max my laptop has and for anyone with money and interest to buy a 3D program they probably have that supported by their graphics card in their computer. 3.1 was released on March 24, 2009. Most graphics cards purchased after that will support 3.1. I will try and keep things as close to the existing examples as possible so that you can see exactly what changes when going from straight OpenGL to using Qt. This example will be broken down as follows. Continue reading
I am so excited to post this! This is part 1 in a series of tutorials demonstrating how to render 2D/3D objects using the builtin functions of Qt 5.5. Part 1 will just be information to help you get started on the right foot. Part 2 will be drawing a basic triangle using the QOpenGLWindow class. Click here to go to Part 2 for example code.
I have been working on converting any basic OpenGL tutorial using modern OpenGL (3+) and Qt for a while now. Many OpenGL examples you see use the outdated fixed pipeline OpenGL.
I haven’t found a good place to host files for free online so I am just going to paste the file text here. Copy the text and save it as whatever name you want.xml and move to C:\Users<your username here>\AppData\Roaming\QtProject\qtcreator\styles. Enjoy. Continue reading
Many people tell you that you need to learn C++ (or any coding language) the hard way. They mean you need to do examples to really learn the language. What they forget is that when you want to learn a programming language there are often dozens of other tools related to the language that you need to understand how to use to even begin learning said programming language. Trying to learn a topic from several different angles at once is obviously difficult and confusing! Continue reading