| 49 void asc_context_initialize(void) { |
49 void asc_context_initialize(void) { |
| 50 if (asc_test_flag(asc_context.flags, ASC_FLAG_INITILIZED)) |
50 if (asc_test_flag(asc_context.flags, ASC_FLAG_INITILIZED)) |
| 51 return; |
51 return; |
| 52 memset(&asc_context, 0, sizeof(AscContext)); |
52 memset(&asc_context, 0, sizeof(AscContext)); |
| 53 |
53 |
| |
54 // initialize default paths |
| |
55 asc_context.font_path = cx_strdup(CX_STR("./fonts")); |
| |
56 asc_context.shader_path = cx_strdup(CX_STR("./shader")); |
| |
57 asc_context.texture_path = cx_strdup(CX_STR("./textures")); |
| |
58 |
| 54 // initialize the font cache |
59 // initialize the font cache |
| 55 asc_font_cache_init(); |
60 asc_font_cache_init(); |
| 56 |
61 |
| 57 // set a default font but do not load it |
62 // set a default font but do not load it |
| 58 asc_context.active_font.style = ASC_FONT_REGULAR; |
63 asc_context.active_font.style = ASC_FONT_REGULAR; |
| 100 |
105 |
| 101 // destroy the error buffer |
106 // destroy the error buffer |
| 102 cxBufferDestroy(&asc_context.error_buffer); |
107 cxBufferDestroy(&asc_context.error_buffer); |
| 103 asc_context.flags = 0; |
108 asc_context.flags = 0; |
| 104 asc_dprintf("Ascension context destroyed."); |
109 asc_dprintf("Ascension context destroyed."); |
| |
110 |
| |
111 // destroy the path information |
| |
112 cx_strfree(&asc_context.font_path); |
| |
113 cx_strfree(&asc_context.shader_path); |
| |
114 cx_strfree(&asc_context.texture_path); |
| 105 } |
115 } |
| 106 |
116 |
| 107 void asc_context_quit(void) { |
117 void asc_context_quit(void) { |
| 108 asc_set_flag(asc_context.flags, ASC_FLAG_QUIT); |
118 asc_set_flag(asc_context.flags, ASC_FLAG_QUIT); |
| 109 } |
119 } |
| 189 asc_context.frame_nanos = frame_nanos; |
199 asc_context.frame_nanos = frame_nanos; |
| 190 asc_context.total_nanos = ns; |
200 asc_context.total_nanos = ns; |
| 191 |
201 |
| 192 return !asc_test_flag(asc_context.flags, ASC_FLAG_QUIT); |
202 return !asc_test_flag(asc_context.flags, ASC_FLAG_QUIT); |
| 193 } |
203 } |
| |
204 |
| |
205 void asc_set_font_path(const char *path) { |
| |
206 cx_strcpy(&asc_context.font_path, cx_str(path)); |
| |
207 } |
| |
208 |
| |
209 void asc_set_shader_path(const char *path) { |
| |
210 cx_strcpy(&asc_context.shader_path, cx_str(path)); |
| |
211 } |
| |
212 |
| |
213 void asc_set_texture_path(const char *path) { |
| |
214 cx_strcpy(&asc_context.texture_path, cx_str(path)); |
| |
215 } |