diff options
| author | Aldrik Ramaekers <aldrik.ramaekers@protonmail.com> | 2020-05-07 17:54:36 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik.ramaekers@protonmail.com> | 2020-05-07 17:54:36 +0200 |
| commit | 45d1a969f70e1b127eb0aaab94dfce33b18e42ee (patch) | |
| tree | 12bc0629c4f6d55d01fe8b335dc4320583c049c6 /src/assets.h | |
| parent | 2289cde164c0270c8e60f185b20ba89c73707913 (diff) | |
work
Diffstat (limited to 'src/assets.h')
| -rw-r--r-- | src/assets.h | 194 |
1 files changed, 97 insertions, 97 deletions
diff --git a/src/assets.h b/src/assets.h index a9816b5..a2b02da 100644 --- a/src/assets.h +++ b/src/assets.h @@ -1,98 +1,98 @@ -/* -* BSD 2-Clause “Simplified” License -* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com -* All rights reserved. -*/ - -#ifndef INCLUDE_ASSETS -#define INCLUDE_ASSETS - -typedef struct t_image { - u8 *start_addr; - u8 *end_addr; - bool loaded; - bool keep_in_memory; - s32 width; - s32 height; - s32 channels; - void *data; - s16 references; - GLuint textureID; -} image; - -#define TEXT_CHARSET_START 0 -#define TEXT_CHARSET_END 2000 -#define TOTAL_GLYPHS TEXT_CHARSET_END-TEXT_CHARSET_START - -typedef struct t_glyph -{ - s32 width; - s32 height; - s32 advance; - s32 lsb; - s32 xoff; - s32 yoff; - void *bitmap; - GLuint textureID; -} glyph; - -typedef struct t_font -{ - u8 *start_addr; - u8 *end_addr; - bool loaded; - s16 references; - s16 size; - s32 px_h; - float32 scale; - stbtt_fontinfo info; - glyph glyphs[TOTAL_GLYPHS]; -} font; - -typedef enum t_asset_task_type -{ - ASSET_IMAGE, - ASSET_FONT, -} asset_task_type; - -typedef struct t_asset_task -{ - s8 type; - bool valid; - union { - image *image; - font *font; - }; -} asset_task; - -typedef struct t_asset_queue { - array queue; -} asset_queue; - -typedef struct t_assets { - array images; - array fonts; - asset_queue queue; - array post_process_queue; - bool valid; - bool done_loading_assets; -} assets; - -char *binary_path; - -mutex asset_mutex; -assets global_asset_collection; - -void assets_create(); -void assets_destroy(); - -void assets_do_post_process(); -void *assets_queue_worker(); - -image *assets_load_image(u8 *start_addr, u8 *end_addr, bool keep_in_memory); -void assets_destroy_image(image *image); - -font *assets_load_font(u8 *start_addr, u8 *end_addr, s16 size); -void assets_destroy_font(font *font); - +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_ASSETS
+#define INCLUDE_ASSETS
+
+typedef struct t_image {
+ u8 *start_addr;
+ u8 *end_addr;
+ bool loaded;
+ bool keep_in_memory;
+ s32 width;
+ s32 height;
+ s32 channels;
+ void *data;
+ s16 references;
+ GLuint textureID;
+} image;
+
+#define TEXT_CHARSET_START 0
+#define TEXT_CHARSET_END 2000
+#define TOTAL_GLYPHS TEXT_CHARSET_END-TEXT_CHARSET_START
+
+typedef struct t_glyph
+{
+ s32 width;
+ s32 height;
+ s32 advance;
+ s32 lsb;
+ s32 xoff;
+ s32 yoff;
+ void *bitmap;
+ GLuint textureID;
+} glyph;
+
+typedef struct t_font
+{
+ u8 *start_addr;
+ u8 *end_addr;
+ bool loaded;
+ s16 references;
+ s16 size;
+ s32 px_h;
+ float32 scale;
+ stbtt_fontinfo info;
+ glyph glyphs[TOTAL_GLYPHS];
+} font;
+
+typedef enum t_asset_task_type
+{
+ ASSET_IMAGE,
+ ASSET_FONT,
+} asset_task_type;
+
+typedef struct t_asset_task
+{
+ s8 type;
+ bool valid;
+ union {
+ image *image;
+ font *font;
+ };
+} asset_task;
+
+typedef struct t_asset_queue {
+ array queue;
+} asset_queue;
+
+typedef struct t_assets {
+ array images;
+ array fonts;
+ asset_queue queue;
+ array post_process_queue;
+ bool valid;
+ bool done_loading_assets;
+} assets;
+
+char *binary_path;
+
+mutex asset_mutex;
+assets global_asset_collection;
+
+void assets_create();
+void assets_destroy();
+
+void assets_do_post_process();
+void *assets_queue_worker();
+
+image *assets_load_image(u8 *start_addr, u8 *end_addr, bool keep_in_memory);
+void assets_destroy_image(image *image);
+
+font *assets_load_font(u8 *start_addr, u8 *end_addr, s16 size);
+void assets_destroy_font(font *font);
+
#endif
\ No newline at end of file |
