Kenix3 / libultraship

Porting games to the PC
MIT License
90 stars 64 forks source link

Reapply viewport and scissor when resetting back to the main framebuffer #558

Closed Archez closed 1 week ago

Archez commented 1 week ago

When changing to another framebuffer, especially one smaller than the main framebuffer, if the viewport/scissor is ever changed the rendering API may truncate the values to align with the smaller framebuffer. This can cause unintended clipping when switching back to the larger main framebuffer.

Setting g_rdp.viewport_or_scissor_changed to true and wiping out the current rendering state allows the next triangle draw to reapply the original viewport/scissor values again based on the main framebuffer size.

If more ports in the future do different things with switching framebuffers, we may want to consider tracking viewport values per framebuffer so that we can re-apply as needed.