this post was submitted on 17 Oct 2023
0 points (50.0% liked)

C++

1760 readers
1 users here now

The center for all discussion and news regarding C++.

Rules

founded 1 year ago
MODERATORS
 

I was trying to replicate an example of the last example of this section of this opengl tutorial, but without the textures, with wireframe cubes and with all the cubes rotating but when i run it only 1 cube is rendered.

I tried to do it again from scratch but only with c style code (except by the shaders and the glfw window) and i got the same result. Why it only renders 1 cube?

vertex shader: https://pastebin.com/6VzJKwBN fragment shader: https://pastebin.com/Ns9dLmqe the source file: https://pastebin.com/MvQtQG3g canned_glfw_window.hpp: https://pastebin.com/h2zD1WbK canned_glfw_window.cpp: https://pastebin.com/N2WX7NT8

you are viewing a single comment's thread
view the rest of the comments
[โ€“] scinde@discuss.tchncs.de 2 points 1 year ago (1 children)

In the loop where you iterate over the positions, you translate the matrix model with the position correctly, but when you rotate it in the next line, you rotate the identity matrix, not the translated matrix, and put the result into model, which resets the position. And so all the cubes get rendered at the same place which results in it looking like only one cube is being rendered.