The short answer is No.
As a rule of thumb, each time you call SDL_RenderPresent, you are given a new framebuffer, containing total garbage (if you’re lucky it’s blank, but don’t bet on it), this is especially true if you
are using a multi-gpu computer that assigns each Present to a different GPU sequentially (this is known as AFR - Alternate Frame Rendering - and is used on AMD Crossfire and NVIDIA SLI technologies).
You may also have to do more than one Present before any new image is shown to the user, due to the driver telling the GPU to present an image multiple frames after it was issued by the application,
usually as part of “double buffering” or “triple buffering”, or as a result of the render-to-texture behind the scenes in a compositing desktop environment (which many are today, even on Android and iOS).
So in general you want to spin your main loop and constantly refresh, if you want to get clever you may be able to stop calling your refresh function from your main loop after a sufficient number of
frames have been rendered since the last user interaction - for this I think 3 frames is a good number, but it may have to be more in multi-gpu configurations.
One other concern with this sort of clever limited refreshing is that some menu overlays and things (such as on game consoles, but also on PC in the case of Steam Community Overlay) require you to
keep refreshing or they may become unresponsive to the user (and because they are eating nearly all of your events, so you won’t know the user is doing anything).On 02/13/2014 12:03 PM, Alvin Beach wrote:
Is it acceptable/correct/OK to call SDL_RenderPresent() when none of the rendering functions have
been called (e.g. SDL_RenderCopy, SDL_RenderDrawLine, etc)?
I initially render my screen (widgets, icons, images, text, etc.). The last thing my main loop does
is call SDL_RenderPresent. Initially, everything is fine in that the widgets, icons, images, text
etc. are presented on the display.
On the next iteration of my main loop, none of those elements have changed. Therefore, none of the
rendering functions have been called (e.g. SDL_RenderCopy() is not called). For example, I do not
need to change the image for a button since the user is not pressing it.
With the above, all is well when I run the program on the desktop. However, when I run it on my
Android device, the screen flickers. From what I can determine, it seems that calling
SDL_RenderPresent when none of the rendering functions have been called is the culprit.
I used to clear the screen for each iteration of the main loop and re-render all the elements
(widgets, icons, text, etc.). The flickering stops on Android if I do this, however, I thought it
would be more efficient not to re-render things that have not changed.
Should I be seeing screen flicker when calling SDL_RenderPresent when none of the rendering
functions have been called? Or is this expected and I should avoid calling that if I haven’t called
any of the rendering functions?
Any advice would be appreciate.
SDL mailing list
SDL at lists.libsdl.org
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged demo." - James Klass
"A game is a series of interesting choices." - Sid Meier