From bdc21df5c7a863e1a0efeb81aec7a2b390c0af91 Mon Sep 17 00:00:00 2001 From: "@clasher113" Date: Mon, 22 Jan 2024 10:50:49 +0200 Subject: [PATCH 1/2] Block animation speed fix --- src/graphics/TextureAnimation.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/graphics/TextureAnimation.cpp b/src/graphics/TextureAnimation.cpp index 368c077d..81175df9 100644 --- a/src/graphics/TextureAnimation.cpp +++ b/src/graphics/TextureAnimation.cpp @@ -25,13 +25,17 @@ void TextureAnimator::update(float delta) { frameBuffer->bind(); for (auto& elem : animations) { - if (changedTextures.find(elem.dstTexture->id) == changedTextures.end()) changedTextures.insert(elem.dstTexture->id); - elem.timer -= delta; - Frame& frame = elem.frames[elem.currentFrame]; - if (elem.timer <= 0) { - elem.timer = frame.duration; + elem.timer += delta; + size_t frameNum = elem.currentFrame; + Frame frame = elem.frames[elem.currentFrame]; + while (elem.timer >= frame.duration) { + elem.timer -= frame.duration; elem.currentFrame++; if (elem.currentFrame >= elem.frames.size()) elem.currentFrame = 0; + frame = elem.frames[elem.currentFrame]; + } + if (frameNum != elem.currentFrame){ + if (changedTextures.find(elem.dstTexture->id) == changedTextures.end()) changedTextures.insert(elem.dstTexture->id); glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, elem.srcTexture->id, 0); glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, elem.dstTexture->id, 0); From 1b2c0a0f21874711576418f1227e21ed647c1f0e Mon Sep 17 00:00:00 2001 From: "@clasher113" Date: Mon, 22 Jan 2024 11:05:49 +0200 Subject: [PATCH 2/2] Build fix --- src/coders/png.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coders/png.cpp b/src/coders/png.cpp index b1770b0d..36287669 100644 --- a/src/coders/png.cpp +++ b/src/coders/png.cpp @@ -225,7 +225,7 @@ int _png_write(const char* filename, uint width, uint height, const ubyte* data, printf("spng_get_png_buffer() error: %s\n", spng_strerror(ret)); } else { - files::write_bytes(filename, (const char*)png_buf, png_size); + files::write_bytes(filename, (const unsigned char*)png_buf, png_size); } fflush(stdout); spng_ctx_free(ctx);