45 void asc_context_initialize(void) { |
45 void asc_context_initialize(void) { |
46 if (asc_test_flag(asc_context.flags, ASC_FLAG_INITILIZED)) |
46 if (asc_test_flag(asc_context.flags, ASC_FLAG_INITILIZED)) |
47 return; |
47 return; |
48 memset(&asc_context, 0, sizeof(AscContext)); |
48 memset(&asc_context, 0, sizeof(AscContext)); |
49 |
49 |
|
50 // nothing is active right after initialization |
|
51 asc_context.active_window = ASC_MAX_WINDOWS; |
|
52 asc_context.active_font = ASC_MAX_FONTS; |
|
53 |
50 // initialize error buffer |
54 // initialize error buffer |
51 cxBufferInit( |
55 cxBufferInit( |
52 &asc_context.error_buffer, |
56 &asc_context.error_buffer, |
53 NULL, |
57 NULL, |
54 256, |
58 256, |
70 asc_dprintf("Ascension context initialized."); |
74 asc_dprintf("Ascension context initialized."); |
71 } |
75 } |
72 |
76 |
73 void asc_context_destroy(void) { |
77 void asc_context_destroy(void) { |
74 for (unsigned int i = 0 ; i < ASC_MAX_WINDOWS ; i++) { |
78 for (unsigned int i = 0 ; i < ASC_MAX_WINDOWS ; i++) { |
75 asc_window_destroy(&asc_context.windows[i]); |
79 asc_window_destroy(i); |
76 } |
80 } |
77 asc_font_cache_clear(); |
81 // TODO: fix that fonts are currently leaking by reworking the font cache |
78 |
82 |
79 // quit SDL |
83 // quit SDL |
80 if (TTF_WasInit()) |
84 if (TTF_WasInit()) |
81 TTF_Quit(); |
85 TTF_Quit(); |
82 SDL_Quit(); |
86 SDL_Quit(); |