From 45d1a969f70e1b127eb0aaab94dfce33b18e42ee Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Thu, 7 May 2020 17:54:36 +0200 Subject: work --- src/assets.h | 194 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 97 insertions(+), 97 deletions(-) (limited to 'src/assets.h') 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 -- cgit v1.2.3-70-g09d2