src/context.c

changeset 65
9c44c55d327a
parent 63
e3cacdd636e4
child 66
8297afa1c29c
equal deleted inserted replaced
64:f18dc427f86f 65:9c44c55d327a
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();
141 } 145 }
142 } 146 }
143 147
144 // sync the windows 148 // sync the windows
145 for (unsigned int i = 0 ; i < ASC_MAX_WINDOWS ; i++) { 149 for (unsigned int i = 0 ; i < ASC_MAX_WINDOWS ; i++) {
146 if (asc_context.windows[i].id > 0) { 150 asc_window_sync(i);
147 asc_window_sync(&asc_context.windows[i]);
148 }
149 } 151 }
150 152
151 // compute frame time 153 // compute frame time
152 uint64_t frame_nanos, ns; 154 uint64_t frame_nanos, ns;
153 do { 155 do {

mercurial