예제 #1
0
  System::System (int& argc, char**& argv)
      : m_impl(new Impl)
  {
      visual_log (VISUAL_LOG_INFO, "Starting Libvisual %s", get_version ().c_str ());

#if ENABLE_NLS
      bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
      bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif

      __lv_progname = visual_strdup (argv[0]);

      /* Initialize CPU caps */
      visual_cpu_initialize ();

      /* Initialize Mem system */
      visual_mem_initialize ();

      /* Initialize CPU-accelerated graphics functions */
      visual_alpha_blend_initialize ();

      /* Initialize high-resolution timer system */
	  Time::init ();

      /* Initialize Thread system */
      visual_thread_initialize ();

      /* Initialize FFT system */
      Fourier::init ();

      /* Initialize the plugin registry */
      PluginRegistry::init ();

      m_impl->params = visual_param_container_new ();
      init_params (m_impl->params);
  }
예제 #2
0
/**
 * Initialize libvisual. Sets up a plugin registry, register the program name and such.
 *
 * @param argc Pointer to an int containing the number of arguments within argv or NULL.
 * @param argv Pointer to a list of strings that make up the argument vector or NULL.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_LIBVISUAL_ALREADY_INITIALIZED,
 *	-VISUAL_ERROR_LIBVISUAL_NO_REGISTRY or error values returned by visual_init_path_add () on failure.
 */
int visual_init (int *argc, char ***argv)
{
	char temppluginpath[FILENAME_MAX+1];
	char *homedir = NULL;
	int ret = 0;

#if ENABLE_NLS
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif

	if (__lv_initialized == TRUE) {
		visual_log (VISUAL_LOG_ERROR, _("Over initialized"));
                return -VISUAL_ERROR_LIBVISUAL_ALREADY_INITIALIZED;
        }

	if (argc == NULL || argv == NULL) {
		if (argc == NULL && argv == NULL) {
			__lv_progname = strdup (_("no progname"));


			if (__lv_progname == NULL)
				visual_log (VISUAL_LOG_WARNING, _("Could not set program name"));
		} else
			visual_log (VISUAL_LOG_ERROR, _("Initialization failed, bad argv, argc"));

	} else {
                /*
                 * We must copy the argument, to let the client
                 * call this method from any context.
                 */
#ifdef __USE_GNU
                __lv_progname = strndup (*argv[0], 1024);
#else
                __lv_progname = strdup (*argv[0]);
#endif
                if (__lv_progname == NULL)
                        visual_log (VISUAL_LOG_WARNING, _("Could not set program name"));
        }

	/* Initialize CPU caps */
	visual_cpu_initialize ();

	/* Initialize Mem system */
	visual_mem_initialize ();

	/* Initialize Thread system */
	visual_thread_initialize ();

	/* Initialize FFT system */
	visual_fourier_initialize ();

	/* Add the standard plugin paths */
	ret = visual_init_path_add (PLUGPATH"/actor");
	visual_log_return_val_if_fail (ret == VISUAL_OK, ret);

	ret = visual_init_path_add (PLUGPATH"/input");
	visual_log_return_val_if_fail (ret == VISUAL_OK, ret);

	ret = visual_init_path_add (PLUGPATH"/morph");
	visual_log_return_val_if_fail (ret == VISUAL_OK, ret);

	ret = visual_init_path_add (PLUGPATH"/transform");
	visual_log_return_val_if_fail (ret == VISUAL_OK, ret);

#if !defined(VISUAL_OS_WIN32)
	/* Add homedirectory plugin paths */
	homedir = getenv ("HOME");

	if (homedir != NULL) {
		temppluginpath[sizeof (temppluginpath) - 1] = 0;

		snprintf (temppluginpath, sizeof (temppluginpath) - 1, "%s/.libvisual/actor", homedir);
		ret = visual_init_path_add (temppluginpath);
		visual_log_return_val_if_fail (ret == VISUAL_OK, ret);

		snprintf (temppluginpath, sizeof (temppluginpath) - 1, "%s/.libvisual/input", homedir);
		ret = visual_init_path_add (temppluginpath);
		visual_log_return_val_if_fail (ret == VISUAL_OK, ret);

		snprintf (temppluginpath, sizeof (temppluginpath) - 1, "%s/.libvisual/morph", homedir);
		ret = visual_init_path_add (temppluginpath);
		visual_log_return_val_if_fail (ret == VISUAL_OK, ret);

		snprintf (temppluginpath, sizeof (temppluginpath) - 1, "%s/.libvisual/transform", homedir);
		ret = visual_init_path_add (temppluginpath);
		visual_log_return_val_if_fail (ret == VISUAL_OK, ret);
	}
#endif

	/* And null terminate the list */
	ret = visual_init_path_add (NULL);
	visual_log_return_val_if_fail (ret == VISUAL_OK, ret);

	__lv_plugins = visual_plugin_get_list ((const char**)__lv_plugpaths, TRUE);
	visual_log_return_val_if_fail (__lv_plugins != NULL, -VISUAL_ERROR_LIBVISUAL_NO_REGISTRY);

	__lv_plugins_actor = visual_plugin_registry_filter (__lv_plugins, VISUAL_PLUGIN_TYPE_ACTOR);
	__lv_plugins_input = visual_plugin_registry_filter (__lv_plugins, VISUAL_PLUGIN_TYPE_INPUT);
	__lv_plugins_morph = visual_plugin_registry_filter (__lv_plugins, VISUAL_PLUGIN_TYPE_MORPH);
	__lv_plugins_transform = visual_plugin_registry_filter (__lv_plugins, VISUAL_PLUGIN_TYPE_TRANSFORM);

	__lv_paramcontainer = visual_param_container_new ();
	init_params (__lv_paramcontainer);
	__lv_userinterface = make_userinterface ();

	__lv_initialized = TRUE;

	/* Free the strdupped plugpaths */
	free_plugpaths ();

	return VISUAL_OK;
}