mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 12:31:51 +00:00
src/graphics moved to src/graphics/core
This commit is contained in:
parent
ba762584a7
commit
b56408a202
63 changed files with 156 additions and 147 deletions
52
src/graphics/core/TextureAnimation.h
Normal file
52
src/graphics/core/TextureAnimation.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#ifndef GRAPHICS_CORE_TEXTURE_ANIMATION_H_
|
||||
#define GRAPHICS_CORE_TEXTURE_ANIMATION_H_
|
||||
|
||||
#include "../../typedefs.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <vector>
|
||||
|
||||
class Assets;
|
||||
class Texture;
|
||||
class Framebuffer;
|
||||
|
||||
constexpr float DEFAULT_FRAME_DURATION = 0.150f;
|
||||
|
||||
struct Frame {
|
||||
glm::ivec2 srcPos;
|
||||
glm::ivec2 dstPos;
|
||||
glm::ivec2 size;
|
||||
float duration = DEFAULT_FRAME_DURATION;
|
||||
};
|
||||
|
||||
class TextureAnimation {
|
||||
public:
|
||||
TextureAnimation(Texture* srcTex, Texture* dstTex) : srcTexture(srcTex), dstTexture(dstTex) {};
|
||||
~TextureAnimation() {};
|
||||
|
||||
void addFrame(const Frame& frame) { frames.emplace_back(frame); };
|
||||
|
||||
size_t currentFrame = 0;
|
||||
float timer = 0.f;
|
||||
Texture* srcTexture;
|
||||
Texture* dstTexture;
|
||||
std::vector<Frame> frames;
|
||||
};
|
||||
|
||||
class TextureAnimator {
|
||||
public:
|
||||
TextureAnimator();
|
||||
~TextureAnimator();
|
||||
|
||||
void addAnimation(const TextureAnimation& animation) { animations.emplace_back(animation); };
|
||||
void addAnimations(const std::vector<TextureAnimation>& animations);
|
||||
|
||||
void update(float delta);
|
||||
private:
|
||||
uint fboR;
|
||||
uint fboD;
|
||||
|
||||
std::vector<TextureAnimation> animations;
|
||||
};
|
||||
|
||||
#endif // GRAPHICS_CORE_TEXTURE_ANIMATION_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue