aboutsummaryrefslogtreecommitdiff
path: root/src/Gif.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Gif.cpp')
-rw-r--r--src/Gif.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Gif.cpp b/src/Gif.cpp
index 2391872..983030c 100644
--- a/src/Gif.cpp
+++ b/src/Gif.cpp
@@ -81,7 +81,8 @@ namespace dchat
Gif::Gif(StringView _fileContent) :
fileContent(move(_fileContent)),
currentFrame(0),
- timeElapsedCs(0.0)
+ timeElapsedCs(0.0),
+ created(false)
{
try
{
@@ -120,9 +121,6 @@ namespace dchat
}
}
while(code != GIF_OK);
-
- if(!createTexture(gif.width, gif.height))
- throw GifLoadException("Failed to create texture for gif");
}
Gif::~Gif()
@@ -138,6 +136,13 @@ namespace dchat
void Gif::update()
{
+ if(!created)
+ {
+ created = true;
+ if(!createTexture(gif.width, gif.height))
+ throw GifLoadException("Failed to create texture for gif");
+ }
+
double timeElapsedMilli = (double)frameTimer.getElapsedTimeMillis();
// If gif is not redrawn for a while, then we reset timer (gif is paused). This happens when gif is not visible and then appears visible
// (because it's visible in window). The reason this is done is to prevent too much time between rendering gif frames, as processing a gif