void initialize() { initialize_cache(); create_text_texture(); fs_gl_add_context_notification(context_notification_handler, NULL); g_buffer = g_malloc(TEXTURE_WIDTH * 32 * 4); g_initialized = 1; }
static void context_notification_handler(int notification, void *data) { if (notification == FS_GL_CONTEXT_DESTROY) { if (g_text_texture != 0) { glDeleteTextures(1, &g_text_texture); g_text_texture = 0; } // FIXME: clear text cache.. //printf("FIXME: clear text cache\n"); GList* list = g_cache; while (list) { cache_item *item = (cache_item *) list->data; g_free(item->text); g_free(item); list = list->next; } g_list_free(g_cache); g_cache = NULL; initialize_cache(); } else if (notification == FS_GL_CONTEXT_CREATE) { create_text_texture(); } }
static void initialize() { g_texture_width = 2048; g_texture_height = 2048; int max_texture_size = fs_ml_get_max_texture_size(); if (max_texture_size > 0) { if (max_texture_size < g_texture_width) { g_texture_width = max_texture_size; } if (max_texture_size < g_texture_height) { g_texture_height = max_texture_size; } } fs_log("using text cache texture size %dx%d\n", g_texture_width, g_texture_height); initialize_cache(); create_text_texture(); fs_gl_add_context_notification(context_notification_handler, NULL); g_buffer = malloc(g_texture_width * 32 * 4); #ifdef USE_FREETYPE init_freetype(); #endif g_initialized = 1; }