예제 #1
0
/* register_font_file_type_exit:
 *  Free list of registered bitmap file types.
 */
static void register_font_file_type_exit(void)
{
   FONT_TYPE_INFO *iter = font_type_list, *next;

   while (iter) {
      next = iter->next;
      _AL_FREE(iter->ext);
      _AL_FREE(iter);
      iter = next;
   }
   
   font_type_list = NULL;

   /* If we are using a destructor, then we only want to prune the list
    * down to valid modules. So we clean up as usual, but then reinstall
    * the internal modules.
    */
   #ifdef ALLEGRO_USE_CONSTRUCTOR
      _register_font_file_type_init();
   #endif

   _remove_exit_func(register_font_file_type_exit);
}
예제 #2
0
 /* font_filetype_constructor:
  *  Register font filetype functions if this object file is linked
  *  in. This isn't called if the load_font() function isn't used 
  *  in a program, thus saving a little space in statically linked 
  *  programs.
  */
 void font_filetype_constructor(void)
 {
    _register_font_file_type_init();
 }
예제 #3
0
파일: allegro.c 프로젝트: Yurand/tw-light
/* _install_allegro:
 *  Initialises the Allegro library, activating the system driver.
 */
static int _install_allegro(int system_id, int *errno_ptr, int (*atexit_ptr)(void (*func)(void)))
{
   RGB black_rgb = {0, 0, 0, 0};
   char tmp1[64], tmp2[64];
   int i;

   #ifndef ALLEGRO_USE_CONSTRUCTOR
      /* call constructor functions manually */
      extern void _initialize_datafile_types();
      extern void _midi_constructor();
      extern void _mouse_constructor();

      _initialize_datafile_types();
      _midi_constructor();
      _mouse_constructor();
      _register_bitmap_file_type_init();
      _register_sample_file_type_init();
      _register_font_file_type_init();
   #endif

   if (errno_ptr)
      allegro_errno = errno_ptr;
   else
      allegro_errno = &errno;

   /* set up default palette structures */
   for (i=0; i<256; i++)
      black_palette[i] = black_rgb;

   for (i=16; i<256; i++)
      desktop_palette[i] = desktop_palette[i & 15];

   /* lock some important variables */
   LOCK_VARIABLE(screen);
   LOCK_VARIABLE(gfx_driver);
   LOCK_VARIABLE(gfx_capabilities);
   LOCK_VARIABLE(_last_bank_1);
   LOCK_VARIABLE(_last_bank_2);
   LOCK_VARIABLE(_gfx_bank);
   LOCK_VARIABLE(_drawing_mode);
   LOCK_VARIABLE(_drawing_pattern);
   LOCK_VARIABLE(_drawing_x_anchor);
   LOCK_VARIABLE(_drawing_y_anchor);
   LOCK_VARIABLE(_drawing_x_mask);
   LOCK_VARIABLE(_drawing_y_mask);
   LOCK_VARIABLE(_current_palette);
   LOCK_VARIABLE(os_type);

   /* nasty stuff to set up the config system before the system driver */
   system_driver = _system_driver_list[0].driver;

   /* needed in case set_config_file was called before allegro_init */
   _reload_config();

   reload_config_texts(NULL);

   if (system_id == SYSTEM_AUTODETECT)
      system_id = get_config_id(uconvert_ascii("system", tmp1), uconvert_ascii("system", tmp2), SYSTEM_AUTODETECT);

   system_driver = NULL;

   /* initialise the system driver */
   usetc(allegro_error, 0);

   for (i=0; _system_driver_list[i].driver; i++) {
      if ((_system_driver_list[i].id == system_id) ||
	  ((_system_driver_list[i].autodetect) && (system_id == SYSTEM_AUTODETECT))) {
	 system_driver = _system_driver_list[i].driver;
	 system_driver->name = system_driver->desc = get_config_text(system_driver->ascii_name);
	 if (system_driver->init() != 0) {
	    system_driver = NULL;
	    if (system_id != SYSTEM_AUTODETECT)
	       break;
	 }
	 else
	    break;
      }
   }

   if (!system_driver)
      return -1;

   /* disable close button */
   set_close_button_callback(NULL);

   /* detect CPU type */
   check_cpu();

#if defined(ALLEGRO_UNIX) || defined(ALLEGRO_WINDOWS)
   /* detect filename encoding used by libc */
   /* XXX This should be done for all platforms but I'm not set up to check
    * that all platforms have been covered before making the 4.2.3 release.
    * --pw
    */
   _al_detect_filename_encoding();
#endif

   /* set up screensaver policy */
   _screensaver_policy = get_config_int(uconvert_ascii("system", tmp1),
                                        uconvert_ascii("disable_screensaver", tmp2),
                                        FULLSCREEN_DISABLED);

   /* install shutdown handler */
   if (_allegro_count == 0) {
      if (atexit_ptr)
	 atexit_ptr(allegro_exit_stub);
   }

   _allegro_count++;

   TRACE(PREFIX_I "Allegro initialised (instance %d)\n", _allegro_count);
   return 0;
}