[SDL] SDL_RenderCopy android

David Olofson david at olofson.net
Sat Mar 9 08:01:14 PST 2013

On Sat, Mar 9, 2013 at 4:06 PM, wboe <w.boeke at upcmail.nl> wrote:
> It would be nice if you could create apps that look like normal Android apps, the user
> should see no difference. So if native Android has no problems with partial screen
> updates, this should be possible with SDL-for-Android too.

If you want to implement "smart refresh" on a true page flipping
display (which is what you typically have on Android devices, in my
experience), you need to figure out how many pages you actually have
(usually two, but it's possible to force three or four via the driver
in some environments), and keep one set of dirty rectangles or similar
for each page. That is, every partial screen update will eventually be
performed once for each page.

The simple, brute force variant is to simply loop { repaint_area();
swapbuffers(); } once for each page whenever you render something.

The clever, efficient variant would be to have the GPU copy repainted
areas into the other pages as needed. I'm not sure if you can
generally do this via public APIs (FBOs?), but I suspect most
environments that implement a desktop or similar over 3D accelerators
are doing this one way or another.

All that said, I believe the nice, safe, "simple," portable approach
is still to set up VBOs or similar for your windows, GUI components
and whatnot, so you can just repaint the screen without re-rendering
all the details. This has the bonus of making translucent objects,
move/scale/zoom effects and the like easy and efficient to implement,
as each object, regardless of what it contains, is just a texture.

//David Olofson - Consultant, Developer, Artist, Open Source Advocate

.--- Games, examples, libraries, scripting, sound, music, graphics ---.
|   http://consulting.olofson.net          http://olofsonarcade.com   |

More information about the SDL mailing list