Make pools with generations and bind mouse position logic
This commit is contained in:
+12
-11
@@ -48,6 +48,7 @@ struct Event {
|
||||
KEY_DOWN,
|
||||
TEXT_INPUT,
|
||||
SCROLL,
|
||||
MOUSE_LEAVE,
|
||||
MOUSE_BUTTON_UP,
|
||||
MOUSE_BUTTON_DOWN,
|
||||
MOUSE_MOVE
|
||||
@@ -80,13 +81,13 @@ struct Event {
|
||||
};
|
||||
|
||||
struct Animation {
|
||||
std::vector<int> frames;
|
||||
std::vector<uint64_t> frames;
|
||||
float frame_rate;
|
||||
bool loop;
|
||||
int reference_count = 0;
|
||||
|
||||
~Animation() {
|
||||
for (int frame_id : frames)
|
||||
for (uint64_t frame_id : frames)
|
||||
image_pool.release(frame_id);
|
||||
}
|
||||
};
|
||||
@@ -103,18 +104,18 @@ public:
|
||||
~Window();
|
||||
|
||||
// Rendering functions
|
||||
int load_image(const char *path, float alpha = 1.0f, bool pixel_art = false);
|
||||
Vec2<float> get_image_size(int image_id);
|
||||
uint64_t load_image(const char *path, float alpha = 1.0f, bool pixel_art = false);
|
||||
Vec2<float> get_image_size(uint64_t image_id);
|
||||
|
||||
int load_font(const char *path, int font_size, bool bold = false, bool italic = false, bool underline = false, bool pixel_art = false);
|
||||
uint64_t load_font(const char *path, int font_size, bool bold = false, bool italic = false, bool underline = false, bool pixel_art = false);
|
||||
|
||||
// text is copied internally, so it can be free'd by the caller after the text is created.
|
||||
int create_text(int font_id, const char *text, uint32_t length, Color color);
|
||||
Vec2<float> get_text_size(int text_id);
|
||||
uint64_t create_text(uint64_t font_id, const char *text, uint32_t length, Color color);
|
||||
Vec2<float> get_text_size(uint64_t text_id);
|
||||
|
||||
bool write(int text_id, Vec2<float> position, float z, float angle = 0.0f, Vec2<float> scale = {1.0f, 1.0f});
|
||||
bool write(uint64_t text_id, Vec2<float> position, float z, float angle = 0.0f, Vec2<float> scale = {1.0f, 1.0f});
|
||||
|
||||
bool draw(int image_id, Vec2<float> position, float z, float angle = 0.0f, Vec2<float> scale = {1.0f, 1.0f});
|
||||
bool draw(uint64_t image_id, Vec2<float> position, float z, float angle = 0.0f, Vec2<float> scale = {1.0f, 1.0f});
|
||||
|
||||
bool draw_rect(Rect rect, Color color, float z, float angle = 0.0f);
|
||||
|
||||
@@ -172,12 +173,12 @@ private:
|
||||
|
||||
union {
|
||||
struct {
|
||||
int image_id;
|
||||
uint64_t image_id;
|
||||
Vec2<float> position;
|
||||
} draw_image;
|
||||
|
||||
struct {
|
||||
int text_id;
|
||||
uint64_t text_id;
|
||||
Vec2<float> position;
|
||||
} draw_text;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user