In the DEKO3D TextureCube example, what's the proper way to render 2 cubes?
Posted: Sat May 06, 2023 7:08 pm
In the default program under the render function (Example04_TextureCube.cpp) you can see that it does the following under bool onFrame:
I've been able to get 2 cubes to draw with the below code, but to be honest I'm not sure what I'm doing is right. For starters, it has an annoying flicker. I come from an OpenGL background, which has so far helped me quite a bit in integrating libnx into my pc game engine. But, this still looks very different from your typical swap buffers / clear screen / render methodology. As you can see, I just copied the transformState, changed the transform/scale and called render again.
I see that render does the below. So calling something here twice is causing that flicker evidently. I'd just like to know what I can do to draw 2 cubes devoid of any kind of flickering. Sadly I couldn't find an example in the switch folder that does anything remotely similar to that. It's always just 1 vertex array.
Code: Select all
transformState.mdlvMtx = glm::mat4{1.0f};
transformState.mdlvMtx = glm::translate(transformState.mdlvMtx, glm::vec3{0.0f, 0.0f, -3.0f});
transformState.mdlvMtx = glm::rotate(transformState.mdlvMtx, sinf(period2 * tau) * tau / 8.0f, glm::vec3{1.0f, 0.0f, 0.0f});
transformState.mdlvMtx = glm::rotate(transformState.mdlvMtx, -period1 * tau, glm::vec3{0.0f, 1.0f, 0.0f});
transformState.mdlvMtx = glm::scale(transformState.mdlvMtx, glm::vec3{0.5f});
render();
Code: Select all
transformState.mdlvMtx = glm::mat4{1.0f};
transformState.mdlvMtx = glm::translate(transformState.mdlvMtx, glm::vec3{0.0f, 0.0f, -3.0f});
transformState.mdlvMtx = glm::rotate(transformState.mdlvMtx, sinf(period2 * tau) * tau / 8.0f, glm::vec3{1.0f, 0.0f, 0.0f});
transformState.mdlvMtx = glm::rotate(transformState.mdlvMtx, -period1 * tau, glm::vec3{0.0f, 1.0f, 0.0f});
transformState.mdlvMtx = glm::scale(transformState.mdlvMtx, glm::vec3{0.5f});
render();
transformState.mdlvMtx = glm::mat4{1.0f};
transformState.mdlvMtx = glm::translate(transformState.mdlvMtx, glm::vec3{1.5f, 0.0f, -3.0f});
transformState.mdlvMtx = glm::rotate(transformState.mdlvMtx, sinf(period2 * tau) * tau / 8.0f, glm::vec3{1.0f, 0.0f, 0.0f});
transformState.mdlvMtx = glm::rotate(transformState.mdlvMtx, -period1 * tau, glm::vec3{0.0f, 1.0f, 0.0f});
transformState.mdlvMtx = glm::scale(transformState.mdlvMtx, glm::vec3{0.65f});
render();
Code: Select all
dynmem.begin(dyncmd);
dyncmd.pushConstants(transformUniformBuffer.getGpuAddr(), transformUniformBuffer.getSize(),0, sizeof(transformState), &transformState);
queue.submitCommands(dynmem.end(dyncmd));
int slot = queue.acquireImage(swapchain);
queue.submitCommands(framebuffer_cmdlists[slot]);
queue.submitCommands(render_cmdlist);
queue.presentImage(swapchain, slot);