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
Launch your .exe from renderdoc and take a gpu capture. From there you should be able to see:
- Did it actually dispatch more than 1 draw call? If not, then there’s a problem in your source file not dispatching all your draws
- If it dispatched multiple draws, inspect the VS output. Did they all just project offscreen or to a singular point or to the exact same points so they’re all on top of each other? If so you have an error in your VS shader or your constants
- If the VS output is correct, then the problem lies in your pixel shader or output merger. Pixel shader might be 0’ing out your pixels, blend state might be alpha-0, write mask might be turned off, a whole bunch of possibilities.
Renderdoc is your best friend for these bugs
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 intomodel
, 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.thank you