src/context.c

changeset 11
d83af80eb09b
parent 7
9dd76cbd6c90
child 15
362b7659dc76
equal deleted inserted replaced
10:05d329adcecc 11:d83af80eb09b
37 AscContext asc_context; 37 AscContext asc_context;
38 38
39 void asc_context_initialize(void) { 39 void asc_context_initialize(void) {
40 if (asc_test_flag(asc_context.flags, ASC_FLAG_INITILIZED)) 40 if (asc_test_flag(asc_context.flags, ASC_FLAG_INITILIZED))
41 return; 41 return;
42 asc_clear_flag(&asc_context.flags, ASC_FLAG_HAS_ERROR); 42 memset(&asc_context, 0, sizeof(AscContext));
43 43
44 // initialize error buffer 44 // initialize error buffer
45 cxBufferInit( 45 cxBufferInit(
46 &asc_context.error_buffer, 46 &asc_context.error_buffer,
47 NULL, 47 NULL,
48 256, 48 256,
49 NULL, 49 NULL,
50 CX_BUFFER_AUTO_EXTEND 50 CX_BUFFER_AUTO_EXTEND
51 ); 51 );
52
53 // initialize data
54 memset(asc_context.windows, 0, sizeof (asc_context.windows));
55 52
56 // initialize SDL 53 // initialize SDL
57 if (SDL_Init(SDL_INIT_VIDEO) < 0) { 54 if (SDL_Init(SDL_INIT_VIDEO) < 0) {
58 asc_error(SDL_GetError()); 55 asc_error(SDL_GetError());
59 } else { 56 } else {
69 void asc_context_destroy(void) { 66 void asc_context_destroy(void) {
70 // destroy data 67 // destroy data
71 for (unsigned int i = 0 ; i < ASC_MAX_WINDOWS ; i++) { 68 for (unsigned int i = 0 ; i < ASC_MAX_WINDOWS ; i++) {
72 asc_window_destroy(&asc_context.windows[i]); 69 asc_window_destroy(&asc_context.windows[i]);
73 } 70 }
71 asc_font_cache_clear();
74 72
75 // quit SDL 73 // quit SDL
76 if (TTF_WasInit()) 74 if (TTF_WasInit())
77 TTF_Quit(); 75 TTF_Quit();
78 SDL_Quit(); 76 SDL_Quit();

mercurial