Hi guys,

I’m fairly new to OpenGL and have been trying to learn it by following the textbook : “Learn OpenGL” by Joe DeVries. I am stuck on one of the exercises they provided, i.e:

[ATTACH=CONFIG]2798[/ATTACH][ATTACH=CONFIG]2798[/ATTACH]

I have taken a look at their solution (https://learnopengl.com/code_viewer.php?code=getting-started/transformations-exercise2) however have not been successful in drawing 2 triangles with 2 different transformations.

Apart from a few differences (I do not use a separate ‘shader class’ and I have not included textures) my code appears to be very similar to the solution, however the result I get is that of a stationary triangle that has rotated once but does not continue to rotate (which I assume it should since it is in a while loop).

```
void MyOpenGL::render()
{
glfwPollEvents();
glClearColor(0.f, 0.f, 0.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(shaderProgram);
glm::mat4 trans;
trans = glm::rotate(trans, glm::radians(20.f),glm::vec3(0.5f, 0.f, 0.f));
GLuint transformLoc = glGetUniformLocation(shaderProgram, "transform");
glUniformMatrix4fv(transformLoc, 1, GL_FALSE, &trans[0][0]);
glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(vao);
trans = glm::mat4();
//trans = glm::translate(trans, glm::vec3(0.01f, 0.f, 0.f));
trans = glm::rotate(trans, glm::radians(10.f), glm::vec3(0.f, 0.f, 1.0f));
glUniformMatrix4fv(transformLoc, 1, GL_FALSE, &trans[0][0]);
glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(0);
glfwSwapBuffers(window);
}
//main loop
int main()
{
MyOpenGL one;
while (!one.shouldWindowClose())
{
one.render();
}
one.terminate();
return 0;
}
//my vertex shader
#version 330 core
in layout (location = 0) vec2 position;
in layout (location = 1) vec3 vertexColour;
out vec3 theColour;
uniform mat4 transform;
void main()
{
gl_Position = transform * vec4(position, 0.0f, 1.0f);
theColour = vertexColour;
};
```

I have noticed that if I put the “glm::mat4 trans” as a private variable of MyOpenGL class and comment trans = glm::mat4();, then I will get a single triangle that rotates on the x and z axis. But what I am trying to achieve is having 2 triangles drawn: one that rotates on the x axis and the other rotating on the z axis.

I am using version 3.3 of OpenGL.

Thank you for your time