Fix main loop, add example and cleanup
This commit is contained in:
+13
-6
@@ -4,6 +4,11 @@
|
||||
#include "pch.h"
|
||||
#include "utils.h"
|
||||
|
||||
struct Image {
|
||||
SDL_Texture *texture;
|
||||
Vec2<float> size;
|
||||
};
|
||||
|
||||
struct Font {
|
||||
TTF_Font *font;
|
||||
bool pixel_art;
|
||||
@@ -59,11 +64,12 @@ public:
|
||||
// title can be free'd by the caller after the window is created, as it's copied internally.
|
||||
Window(Vec2<float> size, const char *title);
|
||||
|
||||
void update(Vec2<float> new_size, const char *new_title);
|
||||
|
||||
~Window();
|
||||
|
||||
// Rendering functions
|
||||
|
||||
int load_image(const char *path, bool pixel_art = false);
|
||||
int load_image(const char *path, float alpha = 1.0f, bool pixel_art = false);
|
||||
void unload_image(int image_id);
|
||||
Vec2<float> get_image_size(int image_id);
|
||||
|
||||
@@ -77,7 +83,7 @@ public:
|
||||
|
||||
bool write(int 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}, float alpha = 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_rect(Rect rect, Color color, float z, float angle = 0.0f);
|
||||
|
||||
@@ -123,10 +129,10 @@ private:
|
||||
SDL_Texture *white_tex;
|
||||
|
||||
// Image pool
|
||||
Pool<SDL_Texture *> image_pool;
|
||||
Pool<Image> image_pool;
|
||||
|
||||
// Font pool
|
||||
Pool<struct Font> font_pool;
|
||||
Pool<Font> font_pool;
|
||||
|
||||
// Text pool
|
||||
Pool<SDL_Texture *> text_pool;
|
||||
@@ -146,7 +152,6 @@ private:
|
||||
struct {
|
||||
int image_id;
|
||||
Vec2<float> position;
|
||||
float alpha;
|
||||
} draw_image;
|
||||
|
||||
struct {
|
||||
@@ -172,4 +177,6 @@ private:
|
||||
void draw_letterbox();
|
||||
};
|
||||
|
||||
inline Window window({720, 480}, "Mysth Engine");
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user