Since we have already learned how to draw our first rectangle on screen, we will further enhance it in this section. We will take the previous example and continue from there.
Rendering 2D shapes
How to do it...
Let's get started by following this example:
- Open up renderwindow.h and add two more VBOs, one called vbo_vertices2 and another called vbo_colors, as highlighted in the following code:
private:
QOpenGLContext* openGLContext;
QOpenGLFunctions* openGLFunctions;
QOpenGLShaderProgram* shaderProgram;
QOpenGLVertexArrayObject* vao;
QOpenGLBuffer* vbo_vertices;
QOpenGLBuffer* vbo_vertices2;
QOpenGLBuffer* vbo_colors;
- Open up renderwindow.cpp and add the following code to the shader code, as highlighted...