From 88effe6802b76fad47308d312969ef6455134078 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Thu, 31 Jul 2014 05:21:32 +0200 Subject: [PATCH] Implemented Texture color modification --- src/video/sdl/sdl_renderer.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/video/sdl/sdl_renderer.cpp b/src/video/sdl/sdl_renderer.cpp index 654e729b5..a83a14f9e 100644 --- a/src/video/sdl/sdl_renderer.cpp +++ b/src/video/sdl/sdl_renderer.cpp @@ -93,7 +93,7 @@ SDLRenderer::~SDLRenderer() void SDLRenderer::draw_surface(const DrawingRequest& request) { - //FIXME: support parameters request.alpha, request.angle, request.blend + //FIXME: support parameters request.angle, request.blend const Surface* surface = (const Surface*) request.request_data; boost::shared_ptr sdltexture = boost::dynamic_pointer_cast(surface->get_texture()); @@ -103,6 +103,13 @@ SDLRenderer::draw_surface(const DrawingRequest& request) dst_rect.w = sdltexture->get_image_width(); dst_rect.h = sdltexture->get_image_height(); + Uint8 r = static_cast(request.color.red * 255); + Uint8 g = static_cast(request.color.green * 255); + Uint8 b = static_cast(request.color.blue * 255); + Uint8 a = static_cast(request.color.alpha * request.alpha * 255); + SDL_SetTextureColorMod(sdltexture->get_texture(), r, g, b); + SDL_SetTextureAlphaMod(sdltexture->get_texture(), a); + if (surface->get_flipx()) { SDL_RenderCopyEx(renderer, sdltexture->get_texture(), NULL, &dst_rect, 0, NULL, SDL_FLIP_HORIZONTAL); @@ -130,7 +137,7 @@ SDLRenderer::draw_surface(const DrawingRequest& request) void SDLRenderer::draw_surface_part(const DrawingRequest& request) { - //FIXME: support parameters request.alpha, request.angle, request.blend + //FIXME: support parameters request.angle, request.blend const SurfacePartRequest* surface = (const SurfacePartRequest*) request.request_data; const SurfacePartRequest* surfacepartrequest = (SurfacePartRequest*) request.request_data; @@ -148,6 +155,13 @@ SDLRenderer::draw_surface_part(const DrawingRequest& request) dst_rect.w = surfacepartrequest->size.x; dst_rect.h = surfacepartrequest->size.y; + Uint8 r = static_cast(request.color.red * 255); + Uint8 g = static_cast(request.color.green * 255); + Uint8 b = static_cast(request.color.blue * 255); + Uint8 a = static_cast(request.color.alpha * request.alpha * 255); + SDL_SetTextureColorMod(sdltexture->get_texture(), r, g, b); + SDL_SetTextureAlphaMod(sdltexture->get_texture(), a); + if (surface->surface->get_flipx()) { SDL_RenderCopyEx(renderer, sdltexture->get_texture(), &src_rect, &dst_rect, 0, NULL, SDL_FLIP_HORIZONTAL); -- 2.11.0