Skip to content

Commit 06e3983

Browse files
committed
Fix textures turning white after resizing window.
1 parent f2f17d4 commit 06e3983

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

libgag/include/SDLGraphicContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ namespace GAGCore
326326
Uint32 optionFlags;
327327
std::string windowTitle;
328328
std::string appIcon;
329+
int resizeTimer;
329330

330331
public:
331332
//! Constructor. Create a new window of size (w,h). If useGPU is true, use GPU for accelerated 2D (OpenGL or DX)

libgag/src/GraphicContext.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,8 +1674,10 @@ namespace GAGCore
16741674
#ifdef HAVE_OPENGL
16751675
if (_gc->optionFlags & GraphicContext::USEGPU)
16761676
{
1677+
if (!resizeTimer && EventListener::instance()->isResizing())
1678+
resizeTimer++;
16771679
// upload
1678-
if (surface->dirty || EventListener::instance()->isResizing())
1680+
if (surface->dirty || resizeTimer)
16791681
surface->uploadToTexture();
16801682

16811683
// state change
@@ -1967,7 +1969,8 @@ namespace GAGCore
19671969

19681970
GraphicContext::GraphicContext(int w, int h, Uint32 flags, const std::string title, const std::string icon):
19691971
windowTitle(title),
1970-
appIcon(icon)
1972+
appIcon(icon),
1973+
resizeTimer(0)
19711974
{
19721975
// some assert on the universe's structure
19731976
assert(sizeof(Color) == 4);
@@ -2275,6 +2278,8 @@ namespace GAGCore
22752278
{
22762279
SDL_UpdateWindowSurface(window);
22772280
}
2281+
if (resizeTimer)
2282+
resizeTimer--;
22782283
}
22792284
}
22802285

0 commit comments

Comments
 (0)