From 4060da7f566a1f58355089f00216265bb21bcec3 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Thu, 31 Jul 2014 21:12:03 +0200 Subject: [PATCH] Implemented sprite rotations for SDLRenderer --- src/video/sdl/sdl_painter.cpp | 54 +++++++++++++------------------------------ 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/src/video/sdl/sdl_painter.cpp b/src/video/sdl/sdl_painter.cpp index b47c7f1a6..ff241b3b4 100644 --- a/src/video/sdl/sdl_painter.cpp +++ b/src/video/sdl/sdl_painter.cpp @@ -24,7 +24,7 @@ void SDLPainter::draw_surface(SDL_Renderer* renderer, const DrawingRequest& request) { - //FIXME: support parameters request.angle, request.blend + //FIXME: support parameters request.blend const Surface* surface = (const Surface*) request.request_data; boost::shared_ptr sdltexture = boost::dynamic_pointer_cast(surface->get_texture()); @@ -41,34 +41,23 @@ SDLPainter::draw_surface(SDL_Renderer* renderer, const DrawingRequest& request) SDL_SetTextureColorMod(sdltexture->get_texture(), r, g, b); SDL_SetTextureAlphaMod(sdltexture->get_texture(), a); - if (surface->get_flipx()) + SDL_RendererFlip flip = SDL_FLIP_NONE; + if (surface->get_flipx() || request.drawing_effect == HORIZONTAL_FLIP) { - SDL_RenderCopyEx(renderer, sdltexture->get_texture(), NULL, &dst_rect, 0, NULL, SDL_FLIP_HORIZONTAL); + flip = SDL_FLIP_HORIZONTAL; } - else + else if (request.drawing_effect == VERTICAL_FLIP) { - switch(request.drawing_effect) - { - case VERTICAL_FLIP: - SDL_RenderCopyEx(renderer, sdltexture->get_texture(), NULL, &dst_rect, 0, NULL, SDL_FLIP_VERTICAL); - break; - - case HORIZONTAL_FLIP: - SDL_RenderCopyEx(renderer, sdltexture->get_texture(), NULL, &dst_rect, 0, NULL, SDL_FLIP_HORIZONTAL); - break; - - default: - case NO_EFFECT: - SDL_RenderCopy(renderer, sdltexture->get_texture(), NULL, &dst_rect); - break; - } + flip = SDL_FLIP_VERTICAL; } + + SDL_RenderCopyEx(renderer, sdltexture->get_texture(), NULL, &dst_rect, request.angle, NULL, flip); } void SDLPainter::draw_surface_part(SDL_Renderer* renderer, const DrawingRequest& request) { - //FIXME: support parameters request.angle, request.blend + //FIXME: support parameters request.blend const SurfacePartRequest* surface = (const SurfacePartRequest*) request.request_data; const SurfacePartRequest* surfacepartrequest = (SurfacePartRequest*) request.request_data; @@ -93,28 +82,17 @@ SDLPainter::draw_surface_part(SDL_Renderer* renderer, const DrawingRequest& requ SDL_SetTextureColorMod(sdltexture->get_texture(), r, g, b); SDL_SetTextureAlphaMod(sdltexture->get_texture(), a); - if (surface->surface->get_flipx()) + SDL_RendererFlip flip = SDL_FLIP_NONE; + if (surface->surface->get_flipx() || request.drawing_effect == HORIZONTAL_FLIP) { - SDL_RenderCopyEx(renderer, sdltexture->get_texture(), &src_rect, &dst_rect, 0, NULL, SDL_FLIP_HORIZONTAL); + flip = SDL_FLIP_HORIZONTAL; } - else + else if (request.drawing_effect == VERTICAL_FLIP) { - switch(request.drawing_effect) - { - case VERTICAL_FLIP: - SDL_RenderCopyEx(renderer, sdltexture->get_texture(), &src_rect, &dst_rect, 0, NULL, SDL_FLIP_VERTICAL); - break; - - case HORIZONTAL_FLIP: - SDL_RenderCopyEx(renderer, sdltexture->get_texture(), &src_rect, &dst_rect, 0, NULL, SDL_FLIP_HORIZONTAL); - break; - - default: - case NO_EFFECT: - SDL_RenderCopy(renderer, sdltexture->get_texture(), &src_rect, &dst_rect); - break; - } + flip = SDL_FLIP_VERTICAL; } + + SDL_RenderCopyEx(renderer, sdltexture->get_texture(), &src_rect, &dst_rect, request.angle, NULL, flip); } void -- 2.11.0