I often only render to a part of the SDL_Window on Android. For example, I only draw a 640x480 texture to the center of the SDL_Window and the rest is just blank. Sometimes, however, I need to change the location of 640x480 texture. For example, I now need to draw the 640x480 texture to the top-left corner. To do this, I first have to clear the area where the texture previously was of course.
Simply calling SDL_RenderClear()
and SDL_RenderPresent()
doesn’t seem to be enough for this job because of double or even multi-buffering used by the SDL renderer. So I thought let’s repeat it three times to clear all buffers, i.e. like this:
for(k = 0; k < 3; k++) {
SDL_SetRenderDrawColor(osd->renderer, 0, 0, 0, 255);
SDL_RenderClear(osd->renderer);
SDL_RenderPresent(osd->renderer);
}
However, even this doesn’t seem enough. Most of the time this clears the screen just fine but sometimes it doesn’t clear it so I was wondering if there is a better approach to make sure all buffers are cleared.