[SDL] RenderCopy + rotations: sdl_gfx or OpenGL?

Mārtiņš Možeiko martins.mozeiko at gmail.com
Sun Jul 31 23:30:45 PDT 2011

You can not use SDL_gfx with new SDL textures/renderer. SDL_gfx
operates directly on bytes to do rendering (it's a software renderer).
new SDL textures/renderer is hardware accelerated - it keeps all the
textures on GPU side. So CPU can not access individual bytes unless it
reads everything back - and that is slow. Nowdays when GPU is
everywhere SDL_gfx is much slower that direct manipulation on textures
on GPU side.

So if you want performance - do the texture rendering yourself using GL/GLES.

Martins Mozeiko

On Mon, Aug 1, 2011 at 8:46 AM, William Dyce <wilbefast at gmail.com> wrote:
> Hey guys,
> I'm going to need image rotation for this Android contract. Apparently
> "SDL_gfx" is a fairly simple library, but less efficient than OpenGL (or
> GLES since this is Android). I'm not all that familiar with OpenGL though.
> void Thing::draw(SDL_Renderer* renderer)
> {
>     static SDL_Rect draw_dest;
>     draw_dest.x = position.x - size.x/2;
>     draw_dest.y = position.y - size.y/2;
>     draw_dest.w = size.x;
>     draw_dest.h = size.y;
>     SDL_RenderCopy(renderer, sprite, NULL, &draw_dest);
> }
> Assuming that I get everything to work with RenderCopy, can I use SDL_gfx
> with my SDL 1.3 code (textures, renderer, etc), or do I need to go back to
> the drawing board (pun not intended) and do everything myself using GLES for
> rotations? And if both options are possibilities, what's the catch: why do
> people say SDL_gfx is slower?
> Thanks,
> William
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

More information about the SDL mailing list