Added pixel texture element
This commit is contained in:
+27
-2
@@ -32,6 +32,15 @@ struct Text {
|
||||
}
|
||||
};
|
||||
|
||||
struct Scripted {
|
||||
SDL_Texture *texture;
|
||||
Vec2<float> size;
|
||||
|
||||
~Scripted() {
|
||||
SDL_DestroyTexture(texture);
|
||||
}
|
||||
};
|
||||
|
||||
// Image pool
|
||||
inline Pool<Image> image_pool;
|
||||
|
||||
@@ -41,6 +50,9 @@ inline Pool<Font> font_pool;
|
||||
// Text pool
|
||||
inline Pool<Text> text_pool;
|
||||
|
||||
// Scripted pool
|
||||
inline Pool<Scripted> scripted_pool;
|
||||
|
||||
struct Event {
|
||||
enum Type {
|
||||
NONE,
|
||||
@@ -107,12 +119,19 @@ public:
|
||||
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);
|
||||
|
||||
uint64_t create_scripted(Vec2<float> size, bool pixel_art);
|
||||
Vec2<float> get_scripted_size(uint64_t scripted_id);
|
||||
|
||||
bool update_scripted(uint64_t scripted_id, Rect content_rect, const char *new_content, uint32_t length);
|
||||
|
||||
bool write(uint64_t text_id, Vec2<float> position, float z, float angle, Vec2<float> pivot, Vec2<float> scale, float alpha);
|
||||
|
||||
bool draw(uint64_t image_id, Vec2<float> position, float z, float angle, Vec2<float> pivot, Vec2<float> scale, float alpha);
|
||||
|
||||
bool draw_rect(Rect rect, Color color, float z, float angle, Vec2<float> pivot, Vec2<float> scale, float alpha);
|
||||
|
||||
bool draw_scripted(uint64_t scripted_id, Vec2<float> position, float z, float angle, Vec2<float> pivot, Vec2<float> scale, float alpha);
|
||||
|
||||
void render(); // the rest of the calls only build the instruction list, this actually renders everything added to the screen (following z order)
|
||||
|
||||
void clear(); // clears the instruction list
|
||||
@@ -147,7 +166,8 @@ private:
|
||||
enum Type {
|
||||
DRAW_IMAGE,
|
||||
DRAW_TEXT,
|
||||
DRAW_RECT
|
||||
DRAW_RECT,
|
||||
DRAW_SCRIPTED
|
||||
} type;
|
||||
|
||||
float z;
|
||||
@@ -171,10 +191,15 @@ private:
|
||||
Rect rect;
|
||||
Color color;
|
||||
} draw_rect;
|
||||
|
||||
struct {
|
||||
uint64_t scripted_id;
|
||||
Vec2<float> position;
|
||||
} draw_scripted;
|
||||
};
|
||||
};
|
||||
|
||||
std::vector<struct RenderInstruction> render_instructions;
|
||||
std::vector<RenderInstruction> render_instructions;
|
||||
|
||||
void compute_transform();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user