Viewport Render Clear Oddity

It appears that if you do the following:

  • Set a viewport of a portion of the window
  • Render to the viewport
  • Set a viewport to the entirety of the window
  • Render Clear

Only the last viewport to be drawn to will be cleared. However, if you render to the “fullwindow” viewport before clearing, the entire screen will be cleared as normal. If the “fullwindow” viewport is 1 pixel smaller than the window, the render clear will clear the entire screen as normal.

This doesn’t really seem like intended behavior? At the vary least I just wanted to document in case somebody runs into this issue in the future as I couldn’t find anything related.

The documentation of SDL_RenderClear is quite explicit: “This function clears the entire rendering target, ignoring the viewport and the clip rectangle”. So if it is only clearing the viewport something is seriously wrong.

This is likely a bug, where cached state (or lack thereof) is confusing things.

Presumably this is the OpenGL renderer, and we’re not changing the scissor rect properly (glClear will not clear past the scissor rect).

I have added this to the bugtracker for 2.0.16:

This was fixed last night, and the fix will be in 2.0.16.