/** * Remove the specified list from the linked list of visible lists and * deinitialize it. * @param list * List to remove. */ void list_remove(list_struct *list) { uint32_t col; if (!list) { return; } if (list->data) { efree(list->data); } list_clear(list); efree(list->col_widths); efree(list->col_spacings); efree(list->col_centered); /* Free column names. */ for (col = 0; col < list->cols; col++) { if (list->col_names[col]) { efree(list->col_names[col]); } } if (list->font != NULL) { font_free(list->font); } efree(list->col_names); efree(list); }
int trap_FreeFont(lua_State *s) { FONT *f; trap_args(s, "FreeFont", "p", &f); font_free(f); return 0; }
int mlua_free_font(lua_State* L) { assert(L); Font* font = pop_font(L, 1); font_free(font); return 0; }
void game_free(game_t g) { if ( g ) { renderer_free(g->g_render); font_free(g->con_font); texture_put(g->con_back); free(g); } }
/** * Set font of the specified button. * @param button * Button. * @param font * Font to set. */ void button_set_font(button_struct *button, font_struct *font) { if (button->font) { font_free(button->font); } if (font) { FONT_INCREF(font); } button->font = font; }
/** * Change list's font. * @param list * Which list to change font for. * @param font * Font to use. */ void list_set_font(list_struct *list, font_struct *font) { if (list->font != NULL) { font_free(list->font); } if (font != NULL) { FONT_INCREF(font); } list->font = font; }
void ctx_destroy(struct context *ctx, const char *reason) { glfwDestroyWindow(ctx->win); glfwTerminate(); infof("ctx", "terminating (reason: %s)", reason); ctx_free_programs(ctx); font_free(ctx->font); framebuffer_free(ctx->screen); list_consume(&ctx->transforms, free); free(ctx); }
void clean_up( void ) { sound_free(); game_list_free(); submenu_free(); platform_free(); menu_free(); hint_free(); font_free(); bg_free(); location_free(); event_free(); snap_free(); video_free(); sdl_free(); }
void con_init_display(font_t font, texture_t conback) { font_free(con_default->font); texture_put(con_default->conback); con_default->font = font; con_default->conback = conback; if (con_default->conback) { con_printf("using conback (%d x %d)\n", texture_height(con_default->conback), texture_width(con_default->conback)); } con_default->cvars = cvar_ns_new("console"); cvar_register_uint(con_default->cvars, "lines", CVAR_FLAG_SAVE_NOTDEFAULT, &con_display_lines); cvar_ns_load(con_default->cvars); }
int dgreed_main(int argc, const char** argv) { params_init(argc, argv); rand_init(time(NULL)); layouts_init(); layouts_set("dvorak"); bool fullscreen = true; if(params_find("-windowed") != ~0) fullscreen = false; video_init_ex(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, "KeyMingler", fullscreen); font = font_load(FONT_FILE); float text_width = font_width(font, LOADING_TEXT); float text_height = font_height(font); Vector2 pos = vec2((SCREEN_WIDTH - text_width) / 2.0f, (SCREEN_HEIGHT - text_height) / 2.0f); font_draw(font, LOADING_TEXT, 0, &pos, COLOR_WHITE); video_present(); system_update(); game_init(); sounds_init(); music = sound_load_stream(MUSIC_FILE); sound_play(music); while(system_update()) { game_update(); game_render(); video_present(); sound_update(); if(key_up(KEY_QUIT)) break; } font_free(font); sound_free(music); sounds_close(); game_close(); video_close(); layouts_close(); return 0; }
void gfx_shutdown () { int i, j; for (i = 0; i < 9; i++) { SDL_FreeSurface (menuimages[i]); if (i < 3) for (j = 0; j < 3; j++) { SDL_FreeSurface (menubuttonimages[j][i]); if (j < 2) SDL_FreeSurface (menuentryimages[j][i]); } for (j = 0; j < 2; j++) SDL_FreeSurface (menulistimages[j][i]); } for (i = 0; i < gfx.player_gfx_count; i++) { if (gfx.players[i].small_image != NULL) { SDL_FreeSurface (gfx.players[i].small_image); gfx.players[i].small_image = NULL; } if (gfx.players[i].menu_image != NULL) { SDL_FreeSurface (gfx.players[i].menu_image); gfx.players[i].menu_image = NULL; } } if (gfx.ghost != NULL) SDL_FreeSurface (gfx.ghost); if (gfx.ghost_small != NULL) SDL_FreeSurface (gfx.ghost_small); for (i = 0; i < FT_max; i++) if (gfx.menu_field[i] != NULL) { SDL_FreeSurface (gfx.menu_field[i]); gfx.menu_field[i] = NULL; } SDL_FreeSurface (gfx.logo); SDL_FreeSurface (gfx.menuselect.image); gfx.screen = SDL_SetVideoMode (gfx.res.x, gfx.res.y, 16, SDL_HWSURFACE | SDL_DOUBLEBUF); SDL_FreeSurface (gfx.screen); font_free(); };
void greed_gui_free(void) { tex_free(gui_tex); font_free(huge_font); font_free(big_font); font_free(small_font); }
void font_pause( void ) { font_free(); }
int main(int argc,char **argv) { font_data *data; // Need dopus library if (!(DOpusBase=OpenLibrary("dopus5.library",LIB_VERSION))) if (!(DOpusBase=OpenLibrary("dopus5:libs/dopus5.library",55))) return(10); #ifdef __amigaos4__ if (!(IDOpus = (struct DOpusIFace *)GetInterface(DOpusBase, "main", 1, NULL))) { CloseLibrary(DOpusBase); return(10); } #endif // Allocate data if (!(data=AllocVec(sizeof(font_data),MEMF_CLEAR))) { font_free(0); return(5); } // Parse arguments data->args= ReadArgs( "FONT,SIZE/N,B=BOLD/S,I=ITALIC/S,U=ULINE/S,PUBSCREEN/K", (APTR)data->arg_array, NULL); // Default to topaz 8 #ifdef __AROS__ strcpy(data->font_name,"ttcourier.font"); #else strcpy(data->font_name,"topaz.font"); #endif data->font_size=8; // Got font name? if (data->arg_array[ARG_FONT]) font_get_name(data,(char *)data->arg_array[ARG_FONT]); // Got a font size? if (data->arg_array[ARG_SIZE] && *((long *)data->arg_array[ARG_SIZE])) { data->font_size=*((long *)data->arg_array[ARG_SIZE]); data->first=TRUE; } // Initialise locale init_locale_data(&data->locale); // Got locale library? if (LocaleBase) { BPTR lock; // Change PROGDIR: to dopus5: if ((lock=Lock("dopus5:",ACCESS_READ))) #ifdef __AROS__ // the lock returned here is the initial PROGDIR: which belongs to the system, // so it's not a very good idea to just UnLock it SetProgramDir(lock); #else UnLock(SetProgramDir(lock)); #endif // Initialise data->locale.li_LocaleBase=LocaleBase; data->locale.li_Catalog=OpenCatalogA(0,"viewfont.catalog",0); data->locale.li_Locale=OpenLocale(0); } // Create message port data->appport=CreateMsgPort(); // Open window if (!(font_open(data))) { font_free(data); return(5); } // Initial gadget settings if (data->arg_array[ARG_BOLD]) SetGadgetValue(data->list,GAD_FONT_BOLD,1); if (data->arg_array[ARG_ITALIC]) SetGadgetValue(data->list,GAD_FONT_ITALIC,1); if (data->arg_array[ARG_ULINE]) SetGadgetValue(data->list,GAD_FONT_ULINE,1); // Show font font_show_font(data,FALSE); // Initialise refresh hook data->refresh_hook.h_Entry=(ULONG (*)())font_refresh; data->refresh_hook.h_Data=data; // Event loop FOREVER { struct IntuiMessage *msg; BOOL quit_flag=FALSE; // AppWindow? if (data->appwindow) { struct AppMessage *amsg; // Get messages while ((amsg=(struct AppMessage *)GetMsg(data->appport))) { // Got file? if (amsg->am_NumArgs>0) { char buf[256]; // Get name DevNameFromLockDopus(amsg->am_ArgList[0].wa_Lock,buf,256); if (amsg->am_ArgList[0].wa_Name && *amsg->am_ArgList[0].wa_Name) AddPart(buf,amsg->am_ArgList[0].wa_Name,256); // Get font name font_get_name(data,buf); // Get new font font_get_font(data); font_show_font(data,FALSE); } // Reply to message ReplyMsg((struct Message *)amsg); } } // Requester? if (data->about) { // Handle requester if (SysReqHandler(data->about,0,0)>=0) { // Close requester FreeSysRequest(data->about); data->about=NULL; } } // Intuition messages if (data->window) { while ((msg=GetWindowMsg(data->window->UserPort))) { struct IntuiMessage msg_copy; UWORD id=0; // Copy message and reply msg_copy=*msg; ReplyWindowMsg(msg); // Get gadget ID if (msg_copy.Class==IDCMP_GADGETUP) id=((struct Gadget *)msg_copy.IAddress)->GadgetID; // Look at message switch (msg_copy.Class) { // Close window case IDCMP_CLOSEWINDOW: quit_flag=TRUE; break; // New size case IDCMP_NEWSIZE: // Redraw font font_show_font(data,FALSE); // Set flag to say we resized data->resized=TRUE; break; // Menu case IDCMP_MENUPICK: { struct MenuItem *item; // Get item if (!(item=ItemAddress(data->window->MenuStrip,msg_copy.Code))) break; // Get ID id=GTMENUITEM_USERDATA(item); // Fall through } // Gadget case IDCMP_GADGETUP: switch (id) { // Show requester case GAD_FONT_FONT_POPUP: case MENU_OPEN_FONT: // Ask for name font_ask_name(data); break; // Font name typed case GAD_FONT_FONT: // Get name font_get_name(data,(char *)GetGadgetValue(data->list,GAD_FONT_FONT)); // Get new font font_get_font(data); font_show_font(data,FALSE); break; // Font size up/down case GAD_FONT_UP: case GAD_FONT_DOWN: { short size; // Get next size size=font_get_size(data,(id==GAD_FONT_UP)?1:-1); // No change? if (size==data->font_size) break; // Use this size data->font_size=size; SetGadgetValue(data->list,GAD_FONT_SIZE,size); } // Font size given case GAD_FONT_CYCLE: // Check id if (id==GAD_FONT_CYCLE) { short size; // Get size if (!(size=atoi(data->size_labels[msg_copy.Code]))) break; // Refresh gadget data->font_size=size; SetGadgetValue(data->list,GAD_FONT_SIZE,data->font_size); } // Font size case GAD_FONT_SIZE: // Entered size if (id==GAD_FONT_SIZE) { // Bounds check gadget data->font_size= BoundsCheckGadget( data->list, GAD_FONT_SIZE, 4, 255); } // Get new font font_get_font(data); font_show_font(data,FALSE); break; // Styles changed case GAD_FONT_BOLD: case GAD_FONT_ITALIC: case GAD_FONT_ULINE: // Redraw font font_show_font(data,FALSE); break; // Save settings case MENU_SAVE_SETTINGS: font_save_settings(data); break; // Quit case MENU_QUIT: quit_flag=TRUE; break; // About case MENU_ABOUT: font_show_about(data); break; } break; // Rawkey case IDCMP_RAWKEY: // Help? if (msg_copy.Code==0x5f) font_show_about(data); // Key case IDCMP_VANILLAKEY: // Escape does quit if (msg_copy.Code==0x1b) quit_flag=TRUE; break; // Refresh case IDCMP_REFRESHWINDOW: // Have we just resized? if (data->resized) { // Don't need to refresh BeginRefresh(data->window); EndRefresh(data->window,TRUE); data->resized=FALSE; break; } // Refresh font display font_show_font(data,TRUE); break; } // Check window is still valid if (!data->window) break; } } if (quit_flag) break; // Wait for signal (ctrl-c breaks) if ((Wait(SIGBREAKF_CTRL_C| ((data->window)?(1<<data->window->UserPort->mp_SigBit):0)| ((data->about)?(1<<data->about->UserPort->mp_SigBit):0)| ((data->appwindow)?(1<<data->appport->mp_SigBit):0)))&SIGBREAKF_CTRL_C) break; } // Free stuff font_free(data); return(0); }
/** * Destroy data associated with the specified button. The button structure * itself is not freed. * @param button * Button to destroy. */ void button_destroy(button_struct *button) { if (button->font) { font_free(button->font); } }
void tr_Font_free(mrb_state * mrb, void * ptr) { (void) mrb; LOG("Freeing font %p\n", ptr); font_free((Font*)ptr); }
int init(const platform_env_t* env) { paused = 0; LOGI("Environment:\n Platform: %d\n Assets: %s\n Shared: %s\n Config: %s\n Tmp: %s\n", env->platform, env->assets_dir, env->shared_dir, env->config_dir, env->tmp_dir); io_driver_t* assets = NULL; io_driver_t* config = NULL; io_driver_t* tmp = NULL; io_driver_t* shared = NULL; if (io_init(&io) != 0 || #ifdef ANDROID io_driver_apk_init(&assets, env->platform_specific) != 0 || #else io_driver_fs_init(&assets, env->assets_dir) != 0 || #endif io_driver_fs_init(&config, env->config_dir) != 0 || io_driver_fs_init(&shared, env->shared_dir) != 0 || io_driver_fs_init(&tmp, env->tmp_dir) != 0 || io_bind(io, "/config", config) || io_bind(io, "/tmp", tmp) || io_bind(io, "/shared", shared) || io_bind(io, "/assets", assets) ) { LOGE("Error initializing I/O system"); return -1; } io_set_working_dir(io, "/assets"); io_set_default(io); if (gfx_init(&gfx) != 0) { LOGE("Error initializing GFX system"); return -1; } font_info_t info = { .name = "fonts/default.ttf", .face_index = 0, .width = 0, .height = 14 * 64, .dpi_x = 0, .dpi_y = 72, }; if (font_init(&font, &info, NULL) != 0) { LOGE("Error loading font"); return -1; } info.height = 22 * 64; if (font_init(&big_font, &info, NULL) != 0) { LOGE("Error loading font"); return -1; } if (atlases_load(&atlases, "atlases.dat") != 0) { LOGE("Error loading atlases metadata"); return -1; } if (sprites_load(&sprites, "sprites.dat") != 0) { LOGE("Error loading sprites metadata"); return -1; } stats_load(&global_stats, "/config/player.dat"); if (am_init(&am, achievements_get_all(), achievements_get_count(), achievement_progress, achievement_unlocked)) { LOGE("Unable to initialize achievements manager"); return -1; } achievements_context.am = am; am_load(am, "/config/achievements.dat"); timestamp_set(&timer); timestamp_set(&fps_timer); push_screen(SCREEN_MAIN_MENU); return 0; } void shutdown() { LOGI("shutdown"); atlases_free(atlases); sprites_free(sprites); font_free(font); font_free(big_font); gfx_free(gfx); stats_dump(&global_stats); stats_save(&global_stats, "/config/player.dat"); stats_free(&global_stats); if (am != NULL) { am_save(am, "/config/achievements.dat"); am_dump(am); am_free(am); am = NULL; } io_free(io); io = NULL; atlases = NULL; sprites = NULL; font = NULL; big_font = NULL; gfx = NULL; }
int main(int argc, char** argv) { Display *dpy; Window *windows[NUMWINS]; int inside[NUMWINS]; Font *pcf = font_new (); u32 fg,bg; int i; int vc=-1; i=1; while(i<argc) { if (!strncmp("-c",argv[i],2)) { if (argv[i][2]) vc = atoi (2 + argv[i]); } i++; } if (!pcf_read (pcf, "timR12.pcf")) { font_free (pcf); pcf = NULL; FATAL ("cannot load font"); } short line_height = pcf->ascent + pcf->descent; fg = RGB_YELLOW; bg = RGB_BROWN; short win_w, win_h; dpy = fbui_display_open (); if (!dpy) FATAL ("cannot open display"); srand (time(NULL)); for (i=0; i< NUMWINS; i++) { Window *win; char subtitle[10]; inside[i] = 0; sprintf (subtitle, "%d", i); do { short win_w = 150; short win_h = 150; int x = rand () % (dpy->width - win_w); int y = rand () & (dpy->height - win_h); win = fbui_window_open (dpy, win_w, win_h, &win_w, &win_h, 999,999, x, y, &fg, &bg, "fbmtest", subtitle, FBUI_PROGTYPE_APP, false,false, vc, false, false, i == 3 ? true : false, // hide the 4th window 0,NULL); } while (!win); windows[i] = win; } printf ("MultiTest: All windows created.\n"); while (1) { int total; int need=0; Event ev; Window *win; int x=0, y=0; int type; int err; /* Get any event for ANY of our windows */ if (err = fbui_wait_event (dpy, &ev, FBUI_EVENTMASK_ALL)) { fbui_print_error (err); continue; } win = ev.win; if (!win) FATAL("null window"); type = ev.type; printf ("%s (subwindow %d) got event %s\n", argv[0], win->id, fbui_get_event_name (type)); if (type == FBUI_EVENT_ENTER) inside [win->id] = 1; else if (type == FBUI_EVENT_LEAVE) inside [win->id] = 0; fbui_clear (dpy, win); char expr[100]; sprintf (expr, "This is window %d", win->id); i=0; int in = 0; while(i < NUMWINS) { if (win->id == windows[i]->id) { in = inside[i]; break; } i++; } if (in) fbui_draw_rect (dpy, win, 0, 0, 149,149, RGB_YELLOW); fbui_draw_string (dpy, win, pcf, 6,6, expr, fg); if (type == FBUI_EVENT_MOTION) { fbui_draw_line (dpy, win, 0,0, ev.x, ev.y, RGB_WHITE); fbui_flush (dpy, win); } } fbui_display_close (dpy); }
static void *ctor(renderer_t r, void *common) { struct _world *world = NULL; vec3_t spawn; world = calloc(1, sizeof(*world)); if ( NULL == world ) goto out; world->render = r; renderer_viewangles(r, 45.0, 45.0, 0.0); world->map = map_load(r, "data/maps/level1"); if ( NULL == world->map ) goto out_free; spawn[0] = 0.0; spawn[1] = CHOPPER_HEIGHT; spawn[2] = 0.0; world->apache = chopper_comanche(spawn, 0.785); if ( NULL == world->apache ) goto out_free_map; world->light = light_new(r, LIGHT_CAST_SHADOWS); if ( NULL == world->light ) { goto out_free_chopper; } world->font = font_load(r, "data/font/carbon.png", 16, 16); if ( NULL == world->font ) goto out_free_light; world->lightRate = 1440; world->light_ticks = 10; world->cvars = cvar_ns_new("world"); if ( NULL == world->cvars ) goto out_free_font; cvar_register_float(world->cvars, "time", CVAR_FLAG_SAVE_ALWAYS, &world->lightAngle); cvar_register_float(world->cvars, "lightRate", CVAR_FLAG_SAVE_NOTDEFAULT, &world->lightRate); cvar_register_uint(world->cvars, "tpf", CVAR_FLAG_SAVE_NOTDEFAULT, &world->light_ticks); cvar_ns_load(world->cvars); world->fcnt = (world->lightAngle / (M_PI / world->lightRate)); world->fcnt *= world->light_ticks; /* success */ goto out; out_free_font: font_free(world->font); out_free_light: light_free(world->light); out_free_chopper: chopper_free(world->apache); out_free_map: map_free(world->map); out_free: free(world); world = NULL; out: return world; }
int main( int argc, char *arvg[] ) { int quit = 0; int config_status = 0; int event; #ifdef __WIN32__ freopen( "cabrio.out", "w", stdout ); freopen( "cabrio.err", "w", stderr ); #endif config_status = config_open( NULL ); if( config_status == -1 ) return -1; if( sdl_init() != 0 ) bail(); if( ogl_init() != 0 ) bail(); /* Clear the screen as soon as we can. This avoids graphics * glitches which can occur with some SDL implementations. */ ogl_clear(); sdl_swap(); if( event_init() != 0 ) bail(); if( font_init() != 0 ) bail(); if( config_status == 1 ) { /* Config file didn't exist, so run the setup utility */ if( setup() != 0 ) return -1; config_update(); if( config_create() != 0 ) return -1; } location_init(); /* If config or location results in a new font, it'll be loaded here. */ font_free(); font_init(); /* Large game lists take a while to initialise, * so show the background while we wait... */ bg_init(); bg_clear(); bg_draw(); sdl_swap(); if( platform_init() != 0 ) bail(); if( category_init() != 0 ) bail(); if( game_sel_init() != 0 ) bail(); if( hint_init() != 0 ) bail(); if( snap_init() != 0 ) bail(); if( game_list_create() != 0 ) bail(); if( menu_init() != 0 ) bail(); if( submenu_init() != 0 ) bail(); sound_init(); video_init(); event_flush(); if( !config_get()->iface.theme.menu.auto_hide ) menu_show(); focus_set( FOCUS_GAMESEL ); while( !quit ) { ogl_clear(); bg_draw(); snap_draw(); if (!config_get()->iface.hide_buttons) hint_draw(); menu_draw(); submenu_draw(); game_sel_draw(); sdl_swap(); if (Mix_PlayingMusic() != 1 && config_get()->iface.theme_sound && reader_running == 0) playmusic(); if (( event = event_poll() )) { if( supress_wait == 0 ) { if( event == EVENT_QUIT ) { quit = 1; } else { supress(); event_process( event ); } } } if( supress_wait > 0 ) supress_wait--; sdl_frame_delay(); } clean_up(); return 0; }
void fonts_close() { font_free(&font_small); font_free(&font_large); }