mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 19:41:51 +00:00
Merge pull request #124 from clasher113/main
Block animation speed fix + win32 build fix
This commit is contained in:
commit
0c2b58c8ac
2 changed files with 10 additions and 6 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue