summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-24 06:43:26 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-24 09:35:38 (EDT)
commit9a54ab34a2f524a4c1798c7065e86928868bd223 (patch)
tree70d79423ad3bc3d213254a37349581da3cfad542
parent6a7786f86faf22b7e0a2c844126ec99d7c622d24 (diff)
downloaddodge-balls-9a54ab34a2f524a4c1798c7065e86928868bd223.zip
dodge-balls-9a54ab34a2f524a4c1798c7065e86928868bd223.tar.gz
dodge-balls-9a54ab34a2f524a4c1798c7065e86928868bd223.tar.bz2
texture: Add accessor and texture creation funcs
-rw-r--r--src/tileset.c45
-rw-r--r--src/tileset.h9
2 files changed, 54 insertions, 0 deletions
diff --git a/src/tileset.c b/src/tileset.c
index 382220d..0871602 100644
--- a/src/tileset.c
+++ b/src/tileset.c
@@ -28,6 +28,7 @@
struct db_tileset {
char *game_id;
SDL_Surface *image;
+ SDL_Texture *texture;
int tw;
int th;
int tc;
@@ -410,3 +411,47 @@ db_tileset_new(const char *game_id, const char *file, int firstgid,
return tileset;
}
+
+int
+db_tileset_tilewidth(struct db_tileset *tileset)
+{
+ return tileset->tw;
+}
+
+int
+db_tileset_tileheight(struct db_tileset *tileset)
+{
+ return tileset->th;
+}
+
+int
+db_tileset_tilecount(struct db_tileset *tileset)
+{
+ return tileset->tc;
+}
+
+int
+db_tileset_columns(struct db_tileset *tileset)
+{
+ return tileset->cols;
+}
+
+int
+db_tileset_firstgid(struct db_tileset *tileset)
+{
+ return tileset->firstgid;
+}
+
+struct db_tileset *
+db_tileset_next(struct db_tileset *tileset)
+{
+ return tileset->next;
+}
+
+int
+db_tileset_create_texture(struct db_tileset *tileset, SDL_Renderer *renderer)
+{
+ tileset->texture = SDL_CreateTextureFromSurface(renderer,
+ tileset->image);
+ return (tileset->texture != NULL ? 0 : -1);
+}
diff --git a/src/tileset.h b/src/tileset.h
index 7a3a06a..8d660b7 100644
--- a/src/tileset.h
+++ b/src/tileset.h
@@ -24,5 +24,14 @@ struct db_tileset;
struct db_tileset *db_tileset_new(const char *game_id, const char *file,
int firstgid, struct db_tileset *prev);
+int db_tileset_tilewidth (struct db_tileset *tileset) __attribute__((__pure__));
+int db_tileset_tileheight(struct db_tileset *tileset) __attribute__((__pure__));
+int db_tileset_tilecount (struct db_tileset *tileset) __attribute__((__pure__));
+int db_tileset_columns (struct db_tileset *tileset) __attribute__((__pure__));
+int db_tileset_firstgid (struct db_tileset *tileset) __attribute__((__pure__));
+struct db_tileset *db_tileset_next(struct db_tileset *tileset)
+ __attribute__((__pure__));
+int db_tileset_create_texture(struct db_tileset *tileset,
+ SDL_Renderer *renderer);
#endif /* DB_TILESET_H_ */