C++ - NVIDIA CUDA - Using the compute_xy and sm_xy compile options to generate an executable

To use an NVIDIA GPU (the graphic card processor) you need a CUDA driver. And if you want to compile a program for a GPU you’ll have to use the CUDA toolkit. In this tutorial we’re going to see how to compile your project in order to generate an executable able to function on all available NVIDIA GPU (past, present and future). By saying “all” we say not deprecated yet of course. ...

June 22, 2022

C++ - Qt Framework - Mixing native OpenGL functions with Qt ones

Having the Qt Framework as GUI for OpenGL can be helpful of course but sometimes it seems easier to use the native OpenGL functions directly. This is exactly what we are going to see in this tutorial by mixing Qt and native OpenGL functions. First to all For this tutorial recipe we are going to use: 2 different pairs of shaders (vertex and fragment) 2 VAOs 2 VBOs 2 EBOs Shaders will be placed in the “shader/” directory and other files directly at the root. ...

May 20, 2022

C++ - Qt Framework - Using QOpenGLWidget to display a shape with lighting and normal vectors

Lighting is certainly one of the most interesting effect that we can make with OpenGL. Combined with colors and normal vectors, lighting becomes visually realistic. In this tutorial we are going to see how to draw a main shape (kind of a rectangular cube), another one inside the first one and a third representing our lighting source. We are also going to add normal vectors to these two shapes but with opposite directions. ...

October 28, 2021

C++ - OpenCV - Hello world

In a previous tutorial we set up OpenCV with Visual Studio. This time we are going to make our first Hello world OpenCV project. Let’s see that. Firs​t of all In this tutorial we’ll change the color model of our image. Choose an image with colors because we are going to change them into a grayscale model. We’ll be able to come back to the original image colors. To achieve this 2 keys will be used: ...

October 12, 2021

C++ - OpenCV - Setting up with Visual Studio

OpenCV is an interesting library aimed to computer vision. But before playing with it, it’s necessary to set up your IDE. This IDE will be Visual Studio for this tutorial. So let’s get started. First of all Let’s start by downloading the OpenCV library from the official GitHub. For this tutorial we’ll use the 4.5.3 version: https://github.com/opencv/opencv/releases/tag/4.5.3 For the latest version, it should be there: https://github.com/opencv/opencv/releases Take the following file for our tutorial: ...

October 10, 2021

C++ - Qt Framework - Using QOpenGLWidget to display a window for moving shapes with keyboard and mouse

In the past tutorials about Qt and OpenGL we saw how to deal with some basic tasks. Let’s see this time something a bit more advanced with the QOpenGLWidget class in order to display a scene from a window with a shape. This shape (a cube) can be rotated, translated, zoomed with the keyboard and the mouse. I added some options to change this cube into a colored or texured shape directly from the GUI. ...

April 6, 2021

C++ - Qt Framework - Using OpenGL texture with index array

Playing with colors can be fun but what about textures? What about something really realistic? In this OpenGL tutorial for Qt we are going to apply a texture on our dear triangles. Yes in OpenGL there are only triangles, no other kinds of shapes available but with some variations though (the famous primitives). First of all We are going to see how to create a struct named StructVertex to handle a vertex and its texture in one object. ...

January 21, 2021

C++ - Qt Framework - Using 1 OpenGL VAO and 2 VBOs with only 1 array for both position and color of each vertex

As we saw, in the last tutorial about using a VAO and VBO to handle 2 different objects on the scene with OpenGL, it’s possible to have 2 arrays of vertex: one to manage the position and one to deal with the color. This time we are going to see how to handle it with only one array. So let’s get started. First of all It’s an easy example with only 3 points on the screen and each one with one different color: red, green and blue (the famous RGB). ...

January 13, 2021

C++ - Qt Framework - Using OpenGL VAO and VBO to handle 2 different objects on the scene

VAO (Vertex Array Object) and VBO (Vertex Buffer Object) were introduced to help programmers since OpenGL 3.0. So it’s not a recent features but if you just started learning OpenGL it could be very complex to understand. Furthermore if you are learning OpenGL and want to use it with Qt together, it becomes a real nightmare. So what are these vertex objects and how to use them to manage two different objects on the scene? ...

January 1, 2021

C++ - Boost - Converting std::vector to Boost.Python Numpy ndarray

You have a C++ std::vector and you want to convert it to a Boost.Python Numpy ndarray. But, once the ndarray got, you want to get back to the C++ array. How to do that? Let’s see that in this Boost.Python tutorial. First of all We need to install Python 3 and Boost on your computer. So in order to have the exact same software and libraries installed in the exact same locations, I suggest to follow the 2 following tutorials: ...

November 25, 2019