I'm using openGL 3.3 to draw 4 polygons in a window. My program calculates the vertices of 2 polygons (m and n sides) and applies some transformation to draw and animate 2 polygons of m sides and 2 of n sides.
My problem is that I need to store the vertices of the 2 polygons in different memory locations, since I want to apply different transformations, but I'm not able to retrieve and display both the objects from my vertex shader.
#version 330
in vec3 a_vertex;
uniform mat4 transform;
void main(void)
{
gl_Position = transform * vec4(a_vertex, 1.0);
}
This shader shows only the first 2 objects (whose vertices are stored in location 0). The same happens if I write layout (location = 0) in vec3 a_vertex;
.
Otherwise writing layout (location = 1) in vec3 a_vertex;
I can only see the other two polygons (whose vertices are stored in location 1).
This seems reasonable. Now my question is: how can I show all the 4 polygons?
P.S.: I think Multiple objects drawing (OpenGL) previous question contains the answer but the explanation is so high level that I cannot translate it into code.