From 22e0bcc01fd84f0bd05a9ad2f15019314ed2679a Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Tue, 19 Jun 2018 12:14:33 +0200 Subject: [PATCH] introduce GFX2_UpdateScreen() --- src/input.c | 8 +++++++- src/screen.h | 4 ++++ src/sdlscreen.c | 16 +++++++++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/input.c b/src/input.c index c7d15223..898820c4 100644 --- a/src/input.c +++ b/src/input.c @@ -1093,11 +1093,17 @@ int Get_input(int sleep_time) { Compute_paintbrush_coordinates(); Display_cursor(); +#if defined(USE_SDL2) + //GFX2_UpdateScreen(); +#endif return 1; } if (user_feedback_required) return 1; - + +#if defined(USE_SDL2) + GFX2_UpdateScreen(); +#endif // Nothing significant happened if (sleep_time) SDL_Delay(sleep_time); diff --git a/src/screen.h b/src/screen.h index baffe2a4..6a04fbbf 100644 --- a/src/screen.h +++ b/src/screen.h @@ -57,4 +57,8 @@ extern volatile int Allow_colorcycling; /// Activates or desactivates file drag-dropping in program window. void Allow_drag_and_drop(int flag); +#if defined(USE_SDL2) +void GFX2_UpdateScreen(void); +#endif + #endif // SCREEN_H_INCLUDED diff --git a/src/sdlscreen.c b/src/sdlscreen.c index 29e6fed6..8d659f72 100644 --- a/src/sdlscreen.c +++ b/src/sdlscreen.c @@ -178,8 +178,13 @@ static void GFX2_UpdateRect(int x, int y, int width, int height) source_rect.x = x; source_rect.y = y; - source_rect.w = width; - source_rect.h = height; + if (width == 0 && height == 0) { + source_rect.w = Screen_SDL->w; + source_rect.h = Screen_SDL->h; + } else { + source_rect.w = width; + source_rect.h = height; + } if (RGBcopy == NULL) { @@ -196,7 +201,12 @@ static void GFX2_UpdateRect(int x, int y, int width, int height) memcpy(pixels + line * pitch, RGBcopy->pixels + source_rect.x * 4 + (source_rect.y+line)* RGBcopy->pitch, source_rect.w * 4 ); } SDL_UnlockTexture(Texture_SDL); - SDL_RenderCopy(Renderer_SDL, Texture_SDL, &source_rect, &source_rect); + //SDL_RenderCopy(Renderer_SDL, Texture_SDL, &source_rect, &source_rect); +} + +void GFX2_UpdateScreen(void) +{ + SDL_RenderCopy(Renderer_SDL, Texture_SDL, NULL, NULL); SDL_RenderPresent(Renderer_SDL); } #endif