Skip to content

Commit f2f17d4

Browse files
committed
Fix flickering during window resize.
Textures still turn white when letting go of the mouse button, though.
1 parent df0dbd3 commit f2f17d4

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

libgag/include/EventListener.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class EventListener {
3939
void run();
4040
void stop();
4141
bool isRunning();
42+
bool isResizing();
4243
int poll(SDL_Event* e);
4344
static EventListener *instance();
4445
~EventListener();

libgag/src/EventListener.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ void EventListener::paint()
129129
//! Handle user resizing the game window on Microsoft Windows.
130130
// TODO: Handle window resizing on macOS
131131
//https://stackoverflow.com/a/51597338/8890345
132-
#ifdef WINDOWS_OR_MINGW
133132
bool sizeMoveTimerRunning = false;
133+
#ifdef WINDOWS_OR_MINGW
134134
int eventWatch(void* self, SDL_Event* event) {
135135
if (event->type == SDL_SYSWMEVENT)
136136
{
@@ -156,6 +156,10 @@ int eventWatch(void* self, SDL_Event* event) {
156156
}
157157
#endif
158158

159+
bool EventListener::isResizing()
160+
{
161+
return sizeMoveTimerRunning;
162+
}
159163
/** Listens for events and adds them to a queue.
160164
* Call EventListener::poll to get an event from the queue.
161165
*/

libgag/src/GraphicContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,7 @@ namespace GAGCore
16751675
if (_gc->optionFlags & GraphicContext::USEGPU)
16761676
{
16771677
// upload
1678-
if (surface->dirty)
1678+
if (surface->dirty || EventListener::instance()->isResizing())
16791679
surface->uploadToTexture();
16801680

16811681
// state change

0 commit comments

Comments
 (0)