2018-02-06 07:19:25 +01:00
|
|
|
/*
|
|
|
|
* This software is licensed under the terms of the MIT-License
|
|
|
|
* See COPYING for further information.
|
|
|
|
* ---
|
2019-01-23 21:10:43 +01:00
|
|
|
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
|
|
|
|
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@alienslab.net>.
|
2018-02-06 07:19:25 +01:00
|
|
|
*/
|
|
|
|
|
2019-01-23 21:10:43 +01:00
|
|
|
#ifndef IGUARD_resource_sprite_h
|
|
|
|
#define IGUARD_resource_sprite_h
|
|
|
|
|
2018-02-06 07:19:25 +01:00
|
|
|
#include "taisei.h"
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
#include "resource.h"
|
2018-02-06 07:19:25 +01:00
|
|
|
#include "texture.h"
|
|
|
|
|
|
|
|
typedef struct Sprite {
|
|
|
|
Texture *tex;
|
|
|
|
FloatRect tex_area;
|
2019-05-18 15:48:21 +02:00
|
|
|
union {
|
|
|
|
FloatRect sprite_area;
|
|
|
|
struct {
|
|
|
|
union {
|
|
|
|
FloatOffset offset;
|
|
|
|
struct { float x, y; };
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
FloatExtent extent;
|
|
|
|
struct { float w, h; };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2018-02-06 07:19:25 +01:00
|
|
|
} Sprite;
|
|
|
|
|
2019-05-18 15:48:21 +02:00
|
|
|
static_assert(offsetof(Sprite, sprite_area.offset) == offsetof(Sprite, offset), "Sprite struct layout inconsistent with FloatRect");
|
|
|
|
static_assert(offsetof(Sprite, sprite_area.extent) == offsetof(Sprite, extent), "Sprite struct layout inconsistent with FloatRect");
|
|
|
|
|
2018-02-06 07:19:25 +01:00
|
|
|
char* sprite_path(const char *name);
|
2018-04-12 16:08:48 +02:00
|
|
|
void* load_sprite_begin(const char *path, uint flags);
|
|
|
|
void* load_sprite_end(void *opaque, const char *path, uint flags);
|
2018-02-06 07:19:25 +01:00
|
|
|
bool check_sprite_path(const char *path);
|
|
|
|
|
|
|
|
void draw_sprite(float x, float y, const char *name);
|
|
|
|
void draw_sprite_p(float x, float y, Sprite *spr);
|
2018-04-12 16:08:48 +02:00
|
|
|
void draw_sprite_batched(float x, float y, const char *name);
|
|
|
|
void draw_sprite_batched_p(float x, float y, Sprite *spr);
|
|
|
|
void draw_sprite_ex(float x, float y, float scale_x, float scale_y, bool batched, Sprite *spr);
|
2018-02-06 07:19:25 +01:00
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
void begin_draw_sprite(float x, float y, float scale_x, float scale_y, Sprite *spr);
|
2018-02-06 07:19:25 +01:00
|
|
|
void end_draw_sprite(void);
|
|
|
|
|
|
|
|
Sprite* get_sprite(const char *name);
|
|
|
|
Sprite* prefix_get_sprite(const char *name, const char *prefix);
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
extern ResourceHandler sprite_res_handler;
|
|
|
|
|
2018-02-06 07:19:25 +01:00
|
|
|
#define SPRITE_PATH_PREFIX "res/gfx/"
|
|
|
|
#define SPRITE_EXTENSION ".spr"
|
2019-01-23 21:10:43 +01:00
|
|
|
|
|
|
|
#endif // IGUARD_resource_sprite_h
|