From 0289b0224ba4820cf07115aa7b8fb9a4a653d024 Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Wed, 13 Jun 2018 23:15:23 +0200 Subject: [PATCH] WIP: add handling support for desktop fullscreen mode --- src/pixmap.cxx | 24 ++++++++++++++++++++++++ src/pixmap.h | 1 + 2 files changed, 25 insertions(+) diff --git a/src/pixmap.cxx b/src/pixmap.cxx index fea7c0d..9d1be99 100644 --- a/src/pixmap.cxx +++ b/src/pixmap.cxx @@ -57,6 +57,7 @@ CPixmap::CPixmap (CEvent * event) m_lpSDLCursors[i] = nullptr; m_lpCurrentCursor = nullptr; + this->mainTexture = nullptr; this->event = event; } @@ -85,6 +86,9 @@ CPixmap::~CPixmap () if (m_lpSDLBlupi) SDL_FreeSurface (m_lpSDLBlupi); + + if (this->mainTexture) + SDL_DestroyTexture (this->mainTexture); } // Cr�e l'objet DirectDraw principal. @@ -143,8 +147,24 @@ CPixmap::BltFast (Sint32 chDst, size_t channel, Point dst, Rect rcRect) dstRect.x = dst.x; dstRect.y = dst.y; + if (!this->mainTexture && g_bFullScreen && g_zoom == 1) + { + SDL_SetHint (SDL_HINT_RENDER_SCALE_QUALITY, "best"); + this->mainTexture = SDL_CreateTexture ( + g_renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, LXIMAGE, + LYIMAGE); + SDL_SetHint (SDL_HINT_RENDER_SCALE_QUALITY, "nearest"); + } + else if (this->mainTexture && !(g_bFullScreen && g_zoom == 1)) + { + SDL_DestroyTexture (this->mainTexture); + this->mainTexture = nullptr; + } + + SDL_SetRenderTarget (g_renderer, this->mainTexture); res = SDL_RenderCopy ( g_renderer, m_SDLTextureInfo[channel].texture, &srcRect, &dstRect); + SDL_SetRenderTarget (g_renderer, nullptr); } else { @@ -602,6 +622,10 @@ bool CPixmap::Display () { m_bBackDisplayed = true; + + if (this->mainTexture) + SDL_RenderCopy (g_renderer, this->mainTexture, nullptr, nullptr); + SDL_RenderPresent (g_renderer); return true; } diff --git a/src/pixmap.h b/src/pixmap.h index 52abe0f..ceeacc3 100644 --- a/src/pixmap.h +++ b/src/pixmap.h @@ -111,5 +111,6 @@ protected: SDL_Cursor * m_lpCurrentCursor; SDL_Cursor * m_lpSDLCursors[MAXCURSORS]; SDL_Surface * m_lpSDLBlupi; + SDL_Texture * mainTexture; std::unordered_map m_SDLTextureInfo; };