Merge pull request #124 from clasher113/main

Block animation speed fix + win32 build fix
This commit is contained in:
MihailRis 2024-01-22 14:00:14 +03:00 committed by GitHub
commit 0c2b58c8ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -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);

View File

@ -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);