Example #1
0
GtkWidget *gui_create_about_sword(void)
{
	GdkPixbuf *about1_logo_pixbuf;
	GtkWidget *about1;
	gchar *about =
	    _("The SWORD Project is an effort to create an ever-expanding \
software package for research and study of God and His Word. \
The SWORD Project framework allows easy use and study of Bible \
texts, commentaries, lexicons, dictionaries, and other books. \
Many frontends are built using this framework. An installed \
set of books may be shared among all frontends using the \
framework.\n\n \
Books can be downloaded from the SWORD Project.");

	about1_logo_pixbuf = pixbuf_finder("sword-big.png", 0, NULL);

	about1 = gtk_about_dialog_new();
	g_signal_connect(about1, "response",
			 G_CALLBACK(on_dialog_response), NULL);
	gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(about1), "The SWORD Project");
	gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about1), (gchar *)main_get_sword_version());
	gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about1), about);

	gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(about1), "http://www.crosswire.org/");
	gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(about1), _("The SWORD Project"));

	gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(about1), about1_logo_pixbuf);

	set_window_icon(GTK_WINDOW(about1));

	return about1;
}
Example #2
0
GtkWidget *gui_create_about_xiphos(void)
{
	GdkPixbuf *about1_logo_pixbuf;
	GtkWidget *about1;
	gchar versionbuild[128];

	snprintf(versionbuild, 120, "%s (%s)", VERSION, BUILD_TYPE);

	about1_logo_pixbuf = pixbuf_finder("about.png", 0, NULL);

	about1 = gtk_about_dialog_new();
	g_signal_connect(about1, "response",
			 G_CALLBACK(on_dialog_response), NULL);

	gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about1), versionbuild);
	gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about1),
				       _("Copyright © 2000-2016 Xiphos Development Team"));
	gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about1),
				      _("\nPowered by The SWORD Project.\nWe would like to thank Troy Griffitts and all the other folks who have given us The SWORD Project."));
	gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(about1),
				     "http://xiphos.org/");
	gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(about1), authors);
	gtk_about_dialog_set_documenters(GTK_ABOUT_DIALOG(about1), documenters);
	gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(about1), translators);
	gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(about1), about1_logo_pixbuf);

	set_window_icon(GTK_WINDOW(about1));

	return about1;
}
Example #3
0
static GtkLabel *eprintf_window(void)
{
  GtkWidget *window = create_error_window();

  gtk_widget_show(window);
  set_window_icon(GTK_WINDOW(window));

  gtk_signal_connect_object(GTK_OBJECT(lookup_widget(window, "ok")), "clicked",
			    GTK_SIGNAL_FUNC(gtk_widget_destroy), (gpointer) window);

  return GTK_LABEL(lookup_widget(GTK_WIDGET(window), "label"));
}
Example #4
0
G_MODULE_EXPORT void
action_about_activate_cb(GtkWidget *widget, EDITOR *e)
{
	GtkWidget *about;
	GdkPixbuf *about_logo;

	about_logo = pixbuf_finder("xiphos-button-125.png", 0, NULL);
	about = gtk_about_dialog_new();

	g_signal_connect(about, "response",
			 G_CALLBACK(on_about_dialog_response), NULL);
	gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(about), "WebKit editor, Xiphos");
	gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about), (gchar *)VERSION);
	gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about), "Replacement for gtkhtml editor");
	gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(about), about_logo);
	set_window_icon(GTK_WINDOW(about));
	gtk_widget_show(about);
}
Example #5
0
File: x11.c Project: engur/fs-uae
void fs_ml_configure_window() {
    SDL_SysWMinfo info;
    SDL_VERSION(&info.version); // this is important!
#ifdef USE_SDL2
    if (!SDL_GetWindowWMInfo(g_fs_ml_window, &info)) {
        fs_log("error getting window information\n");
        return;
    }
    g_display = info.info.x11.display;
    g_window = info.info.x11.window;
#else
    if (!SDL_GetWMInfo(&info)) {
        fs_log("error getting window information\n");
        return;
    }
    g_display = info.info.x11.display;
    g_window = info.info.x11.wmwindow;
#endif

    // Set the PID related to the window for the given hostname, if possible
    //   if (data->pid > 0) {
    //       _NET_WM_PID = XInternAtom(display, "_NET_WM_PID", False);
    //       XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace,
    //                        (unsigned char *)&data->pid, 1);

    Atom UTF8_STRING = XInternAtom(g_display, "UTF8_STRING", False);

    fs_log("requesting dark window manager theme\n");
    Atom _GTK_THEME_VARIANT = XInternAtom(g_display, "_GTK_THEME_VARIANT", False);
    XChangeProperty(g_display, g_window, _GTK_THEME_VARIANT, UTF8_STRING, 8,
            PropModeReplace, (const unsigned char *) "dark", 4);

    set_window_icon();
    if (fs_config_get_int("always_on_top") == 1) {
        set_above_state();
    }
    /*
    set_window_icon(32);
    set_window_icon(48);
    set_window_icon(64);
    set_window_icon(128);
    */
}
Example #6
0
GtkWidget *editor_new(const gchar *title, EDITOR *e)
{
	GtkActionGroup *action_group;
	GtkUIManager *manager;
	GtkWidget *editor;
	GError *error = NULL;

	editor = gtkhtml_editor_new();
	e->window = editor;
	e->html_widget =
	    GTK_WIDGET(gtkhtml_editor_get_html(GTKHTML_EDITOR(editor)));
	gtk_window_set_title(GTK_WINDOW(editor), title);

	set_window_icon(GTK_WINDOW(editor));

	manager = gtkhtml_editor_get_ui_manager(GTKHTML_EDITOR(editor));
	if (e->type == STUDYPAD_EDITOR)
		gtk_ui_manager_add_ui_from_string(manager, file_ui, -1,
						  &error);
	else
		gtk_ui_manager_add_ui_from_string(manager, note_file_ui,
						  -1, &error);

	handle_error(&error);

	gtk_ui_manager_add_ui_from_string(manager, view_ui, -1, &error);
	handle_error(&error);

	if (e->type == STUDYPAD_EDITOR)
		gtk_ui_manager_add_ui_from_string(manager,
						  main_ui_studypad, -1,
						  &error);
	else
		gtk_ui_manager_add_ui_from_string(manager, main_ui_note,
						  -1, &error);

	handle_error(&error);

	action_group = gtk_action_group_new("file");
	gtk_action_group_set_translation_domain(action_group,
						GETTEXT_PACKAGE);
	gtk_action_group_add_actions(action_group, file_entries,
				     G_N_ELEMENTS(file_entries), e);
	gtk_ui_manager_insert_action_group(manager, action_group, 0);

	action_group = gtk_action_group_new("view");
	gtk_action_group_set_translation_domain(action_group,
						GETTEXT_PACKAGE);
	gtk_action_group_add_actions(action_group, view_entries,
				     G_N_ELEMENTS(view_entries), editor);
	gtk_ui_manager_insert_action_group(manager, action_group, 0);

	action_group = gtk_action_group_new("main");
	gtk_action_group_set_translation_domain(action_group,
						GETTEXT_PACKAGE);
	gtk_action_group_add_actions(action_group, main_entries,
				     G_N_ELEMENTS(main_entries), e);
	gtk_ui_manager_insert_action_group(manager, action_group, 0);

	action_group = gtk_action_group_new("context-menu");
	gtk_action_group_set_translation_domain(action_group,
						GETTEXT_PACKAGE);
	gtk_action_group_add_actions(action_group, test_entries,
				     G_N_ELEMENTS(test_entries), e);
	gtk_ui_manager_insert_action_group(manager, action_group, 0);

	gtk_ui_manager_ensure_update(manager);
	gtk_widget_show(editor);

	gtkhtml_editor_drop_undo(GTKHTML_EDITOR(e->window));
	gtkhtml_editor_set_changed(GTKHTML_EDITOR(e->window), FALSE);

	g_signal_connect(editor, "delete-event",
			 G_CALLBACK(app_delete_cb), (EDITOR *)e);
	return editor;
}
Example #7
0
/******************************************************************************
 * Name
 *   create_parallel_dialog
 *
 * Synopsis
 *   #include "parallel_dialog.h"
 *
 *   GtkWidget *create_parallel_dialog(void)
 *
 * Description
 *
 *
 *
 * Return value
 *   GtkWidget *
 */
static GtkWidget *create_parallel_dialog(void)
{
	GtkWidget *box_parallel_labels;
	GtkWidget *dialog_vbox25;
	GtkWidget *toolbar29;
	GtkWidget *dialog_action_area25;
	GtkWidget *hbuttonbox4;
	GtkWidget *btnDockInt;
#ifndef USE_WEBKIT2
	GtkWidget *scrolled_window;
#endif
	gchar title[256];

	sprintf(title, "%s - %s", settings.program_title, _("Parallel"));

	dialog_parallel = gtk_dialog_new();
	gtk_window_set_title(GTK_WINDOW(dialog_parallel), title);

	g_object_set_data(G_OBJECT(dialog_parallel),
			  "dialog_parallel", dialog_parallel);
	gtk_window_resize(GTK_WINDOW(dialog_parallel),
			  settings.parallel_width,
			  settings.parallel_height);
	gtk_window_set_resizable(GTK_WINDOW(dialog_parallel), TRUE);

	dialog_vbox25 =
	    gtk_dialog_get_content_area(GTK_DIALOG(dialog_parallel));
	g_object_set_data(G_OBJECT(dialog_parallel), "dialog_vbox25",
			  dialog_vbox25);
	gtk_widget_show(dialog_vbox25);

	UI_VBOX(vboxInt, FALSE, 0);
	gtk_widget_show(vboxInt);
	gtk_box_pack_start(GTK_BOX(dialog_vbox25), vboxInt, TRUE, TRUE, 0);
	toolbar29 = create_nav_toolbar();
	gtk_widget_show(toolbar29);
	gtk_box_pack_start(GTK_BOX(vboxInt), toolbar29, FALSE, FALSE, 0);

	UI_HBOX(box_parallel_labels, TRUE, 2);
	gtk_widget_show(box_parallel_labels);
	gtk_box_pack_start(GTK_BOX(vboxInt), box_parallel_labels, FALSE,
			   TRUE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(box_parallel_labels),
				       2);

#if 0
	if (settings.parallel_list) {
		GtkWidget *plabel;
		gchar *label;
		gint modidx;

		for (modidx = 0; settings.parallel_list[modidx]; ++modidx) {
			plabel = gtk_label_new(NULL);
			gtk_widget_show(plabel);
			gtk_box_pack_start(GTK_BOX(box_parallel_labels),
					   plabel, FALSE, FALSE, 0);
			gtk_label_set_use_markup(GTK_LABEL(plabel), TRUE);

			label =
			    g_strdup_printf
			    ("<span color='%s' weight='bold'>%s</span>",
			     settings.bible_verse_num_color,
			     settings.parallel_list[modidx]);
			gtk_label_set_markup(GTK_LABEL(plabel), label);
			g_free(label);
		}
	}
#endif /* 0 */

#ifndef USE_WEBKIT2
	scrolled_window = gtk_scrolled_window_new(NULL, NULL);
	gtk_widget_show(scrolled_window);
	gtk_box_pack_start(GTK_BOX(vboxInt), scrolled_window, TRUE, TRUE,
			   0);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
				       GTK_POLICY_AUTOMATIC,
				       GTK_POLICY_ALWAYS);
	gtk_scrolled_window_set_shadow_type((GtkScrolledWindow *)
					    scrolled_window,
					    settings.shadow_type);
#endif

	widgets.html_parallel_dialog =
	    GTK_WIDGET(XIPHOS_HTML_NEW(NULL, FALSE, PARALLEL_TYPE));
	gtk_widget_show(widgets.html_parallel_dialog);
#ifdef USE_WEBKIT2
	gtk_box_pack_start(GTK_BOX(vboxInt), widgets.html_parallel_dialog, TRUE, TRUE, 0);
#else
	gtk_container_add(GTK_CONTAINER(scrolled_window),
			  widgets.html_parallel_dialog);
#endif

	g_signal_connect((gpointer)widgets.html_parallel_dialog,
			 "popupmenu_requested",
			 G_CALLBACK(_popupmenu_requested_cb), NULL);

	dialog_action_area25 =
#ifdef HAVE_GTK_312
	    gtk_dialog_get_content_area(GTK_DIALOG(dialog_parallel));
#else
	    gtk_dialog_get_action_area(GTK_DIALOG(dialog_parallel));
#endif
	g_object_set_data(G_OBJECT(dialog_parallel),
			  "dialog_action_area25", dialog_action_area25);
	gtk_widget_show(dialog_action_area25);
	gtk_container_set_border_width(GTK_CONTAINER(dialog_action_area25), 10);

#ifdef USE_GTK_3
	hbuttonbox4 = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
#else
	hbuttonbox4 = gtk_hbutton_box_new();
#endif
	gtk_widget_show(hbuttonbox4);

#ifdef HAVE_GTK_312
	gtk_box_pack_start(GTK_BOX(dialog_action_area25), hbuttonbox4,
			   FALSE, TRUE, 3);
#else
	gtk_box_pack_start(GTK_BOX(dialog_action_area25), hbuttonbox4,
			   TRUE, TRUE, 0);
#endif

	gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox4),
				  GTK_BUTTONBOX_END);
	btnDockInt =
#ifdef HAVE_GTK_310
	    gtk_button_new_from_icon_name("window-close",
					  GTK_ICON_SIZE_BUTTON);
#else
	    gtk_button_new_from_stock(GTK_STOCK_CLOSE);
#endif
	gtk_widget_show(btnDockInt);
	gtk_container_add(GTK_CONTAINER(hbuttonbox4), btnDockInt);
	gtk_widget_set_can_default(btnDockInt, 1);

	g_signal_connect(G_OBJECT(dialog_parallel), "destroy",
			 G_CALLBACK(on_dlgparallel_destroy), NULL);
	g_signal_connect(G_OBJECT(btnDockInt), "clicked",
			 G_CALLBACK(gui_btnDockInt_clicked), NULL);

	g_signal_connect((gpointer)dialog_parallel,
			 "configure_event",
			 G_CALLBACK(on_parallel_configure_event), NULL);

	settings.display_parallel = 1;
	xml_set_value("Xiphos", "layout", "parallelopen", "1");

	set_window_icon(GTK_WINDOW(dialog_parallel));

	/*
	 * (from xiphos.c)
	 * a little paranoia:
	 * clamp geometry values to a reasonable bound.
	 * sometimes xiphos gets insane reconfig events as it dies,
	 * especially if it's due to just shutting linux down.
	 */
	if ((settings.parallel_x < 0) || (settings.parallel_x > 2000))
		settings.parallel_x = 40;
	if ((settings.parallel_y < 0) || (settings.parallel_y > 2000))
		settings.parallel_y = 40;

	gtk_window_move(GTK_WINDOW(dialog_parallel), settings.parallel_x,
			settings.parallel_y);

	return dialog_parallel;
}
Example #8
0
int video_mode(int f, int w, int h)
{
    //senquack
    /* Enable standard application logging */
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);


    int stereo  = config_get_d(CONFIG_STEREO)      ? 1 : 0;
    int stencil = config_get_d(CONFIG_REFLECTION)  ? 1 : 0;
    int buffers = config_get_d(CONFIG_MULTISAMPLE) ? 1 : 0;
    int samples = config_get_d(CONFIG_MULTISAMPLE);
    int vsync   = config_get_d(CONFIG_VSYNC)       ? 1 : 0;
    int hmd     = config_get_d(CONFIG_HMD)         ? 1 : 0;
    int highdpi = config_get_d(CONFIG_HIGHDPI)     ? 1 : 0;

    int dpy = config_get_d(CONFIG_DISPLAY);

    int X = SDL_WINDOWPOS_CENTERED_DISPLAY(dpy);
    int Y = SDL_WINDOWPOS_CENTERED_DISPLAY(dpy);

    hmd_free();

    if (window)
    {
        SDL_GL_DeleteContext(context);
        SDL_DestroyWindow(window);
    }

    //senquack
//    SDL_GL_SetAttribute(SDL_GL_STEREO,             stereo);

    //senquack - disabled drawing shadows and reflections on GCW Zero, don't need a stencil buffer:
#ifdef GCWZERO
    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,       0);
#endif

    //senquack - don't need or want these on GCW Zero:
#ifndef GCWZERO
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, buffers);
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, samples);
#endif

    /* Require 16-bit double buffer with 16-bit depth buffer. */

   //senquack - GCW Zero port change
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE,     8);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,   8);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,    8);
    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,    8);
    SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE,    32);
//    SDL_GL_SetAttribute(SDL_GL_RED_SIZE,     5);
//    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,   6);
//    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,    5);
//    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,    0);
//    SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE,    16);

    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,  16);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    //senquack
    SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);

    /* Try to set the currently specified mode. */

    log_printf("Creating a window (%dx%d, %s)\n",
               w, h, (f ? "fullscreen" : "windowed"));

    //senquack DEBUG -  DO NOT RUN - loads GLES2.0 for some reason
//    SDL_VideoInit(NULL);

    window = SDL_CreateWindow("", X, Y, w, h,
                              SDL_WINDOW_OPENGL |
                              (highdpi ? SDL_WINDOW_ALLOW_HIGHDPI : 0) |
                              (f ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0));

    if (window)
    {
        if ((context = SDL_GL_CreateContext(window)))
        {
            int buf, smp;

            SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &buf);
            SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &smp);

            /*
             * Work around SDL+WGL returning pixel formats below
             * minimum specifications instead of failing, thus
             * bypassing our fallback path. SDL tries to ensure that
             * WGL plays by the rules, but forgets about extended
             * context attributes such as multisample. See SDL
             * Bugzilla #77.
             */

            if (buf < buffers || smp < samples)
            {
                log_printf("GL context does not meet minimum specifications\n");
                SDL_GL_DeleteContext(context);
                context = NULL;
            }
        }
    }

    if (window && context)
    {
        set_window_title(TITLE);
        set_window_icon(ICON);

        /*
         * SDL_GetWindowSize can be unreliable when going fullscreen
         * on OSX (and possibly elsewhere). We should really be
         * waiting for a resize / size change event, but for now we're
         * doing this lazy thing instead.
         */

        if (f)
        {
            SDL_DisplayMode dm;

            if (SDL_GetDesktopDisplayMode(video_display(), &dm) == 0)
            {
                video.window_w = dm.w;
                video.window_h = dm.h;

//                //senquack
                dm.format = SDL_PIXELFORMAT_RGBA8888;
//    dm.format = SDL_PIXELFORMAT_RGB565;
                dm.w = 320;
                dm.h = 240;
                dm.refresh_rate = 60;
                dm.driverdata = 0;
                SDL_SetWindowDisplayMode(window, &dm);
                printf("setting new video dm..\n");
                SDL_GetCurrentDisplayMode(0, &dm);
                SDL_Log("Screen w: %d h: %d\n", dm.w, dm.h);
                SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(dm.format));
                SDL_Log("Screen dm: ");
                SDL_Log("\n\n");
                SDL_Log("Vendor     : %s\n", glGetString(GL_VENDOR));
                SDL_Log("Renderer   : %s\n", glGetString(GL_RENDERER));
                SDL_Log("Version    : %s\n", glGetString(GL_VERSION));
                SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS));
                SDL_Log("\n");
                fflush(NULL);
            }
        }
        else
        {
            SDL_GetWindowSize(window, &video.window_w, &video.window_h);
        }

        if (highdpi)
        {
            SDL_GL_GetDrawableSize(window, &video.device_w, &video.device_h);
        }
        else
        {
            video.device_w = video.window_w;
            video.device_h = video.window_h;
        }

        video.device_scale = (float) video.device_h / (float) video.window_h;

        log_printf("Created a window (%u, %dx%d, %s)\n",
                   SDL_GetWindowID(window),
                   video.window_w, video.window_h,
                   (f ? "fullscreen" : "windowed"));

        config_set_d(CONFIG_DISPLAY,    video_display());
        config_set_d(CONFIG_FULLSCREEN, f);
        config_set_d(CONFIG_WIDTH,      video.window_w);
        config_set_d(CONFIG_HEIGHT,     video.window_h);

        SDL_GL_SetSwapInterval(vsync);

        if (!glext_init())
            return 0;

        glViewport(0, 0, video.device_w, video.device_h);
        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

        glEnable(GL_NORMALIZE);
        glEnable(GL_CULL_FACE);
        glEnable(GL_DEPTH_TEST);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_LIGHTING);
        glEnable(GL_BLEND);

#if !ENABLE_OPENGLES
        glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,
                      GL_SEPARATE_SPECULAR_COLOR);
#endif

        glPixelStorei(GL_PACK_ALIGNMENT, 1);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glDepthFunc(GL_LEQUAL);

        /* If GL supports multisample, and SDL got a multisample buffer... */

        if (glext_check("ARB_multisample"))
        {
            SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &buffers);
            if (buffers) glEnable(GL_MULTISAMPLE);
        }

        /* Set up HMD display if requested. */

        if (hmd)
            hmd_init();

        /* Initialize screen snapshotting. */

        snapshot_init();

        video_show_cursor();

        /* Grab input immediately in HMD mode. */

        if (hmd_stat())
            SDL_SetWindowGrab(window, SDL_TRUE);

        return 1;
    }

    /* If the mode failed, try it without stereo. */

    else if (stereo)
    {
        config_set_d(CONFIG_STEREO, 0);
        return video_mode(f, w, h);
    }

    /* If the mode failed, try decreasing the level of multisampling. */

    else if (buffers)
    {
        config_set_d(CONFIG_MULTISAMPLE, samples / 2);
        return video_mode(f, w, h);
    }

    /* If that mode failed, try it without reflections. */

    else if (stencil)
    {
        config_set_d(CONFIG_REFLECTION, 0);
        return video_mode(f, w, h);
    }

    /* If THAT mode failed, punt. */

    return 0;
}
Example #9
0
 window_icon_scope(W &wnd, int iconType, HINSTANCE hinst, int iconId)
     : m_hwnd(get_HWND(wnd))
     , m_iconId(iconType)
     , m_hicon(set_window_icon(m_hwnd, iconType, hinst, iconId))
 {}
Example #10
0
 window_icon_scope(W &wnd, int iconType, HICON hicon)
     : m_hwnd(get_HWND(wnd))
     , m_iconId(iconType)
     , m_hicon(set_window_icon(m_hwnd, iconType, hicon))
 {}
Example #11
0
viewer_t *viewer_init(char *title)
{
  GtkTooltips *tooltips;
  GtkWidget *main_box;
  GtkWidget *hbox;
  GtkWidget *button;

  /* New viewer instance */
  viewer_t *viewer = (viewer_t *) malloc(sizeof(viewer_t));

  /* The main window */
  viewer->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_usize(viewer->window, VIEWER_SIZE_WIDTH, VIEWER_SIZE_HIGHT);
  gtk_signal_connect(GTK_OBJECT(viewer->window), "destroy",
                     GTK_SIGNAL_FUNC(viewer_destroyed_handler), viewer);

  /* The window icon */
  set_window_icon(GTK_WINDOW(viewer->window));

  /* The window title */
  if ( title == NULL ) {
    viewer->title = NULL;
    gtk_window_set_title(GTK_WINDOW(viewer->window), TITLE);
  }
  else {
    viewer->title = (char *) malloc(strlen(TITLE)+strlen(title)+4);
    sprintf(viewer->title, TITLE ": %s", title);
    gtk_window_set_title(GTK_WINDOW(viewer->window), viewer->title);
  }

  /* A vertical box to put the list and the button in */
  main_box = gtk_vbox_new(FALSE, 5);
  gtk_container_set_border_width(GTK_CONTAINER(main_box), 5);
  gtk_container_add(GTK_CONTAINER(viewer->window), main_box);
  gtk_widget_show(main_box);

  /* Some tooltips to make life easier */
  tooltips = gtk_tooltips_new();

  /* The result log list */
  viewer->list = list_init(main_box);
  viewer->loaded = 0;

  /* The button box */
  viewer->button_box = gtk_vbox_new(FALSE, 5);
  gtk_widget_show(viewer->button_box);
  gtk_box_pack_start(GTK_BOX(main_box), viewer->button_box, FALSE, FALSE, 0);

  /* The file buttons */
  hbox = gtk_hbox_new(FALSE, 5);
  gtk_widget_show(hbox);
  gtk_box_pack_start(GTK_BOX(viewer->button_box), hbox, FALSE, FALSE, 0);

  button = viewer_button(hbox, "Follow");
  gtk_tooltips_set_tip(tooltips, button, "Follow the Test Log file as it grows", NULL);
  gtk_signal_connect(GTK_OBJECT(button), "clicked",
                     GTK_SIGNAL_FUNC(button_follow_clicked), viewer);

  button = viewer_button(hbox, "Close");
  gtk_tooltips_set_tip(tooltips, button, "Quit the TestFarm Log Viewer", NULL);
  gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
                            GTK_SIGNAL_FUNC(gtk_widget_destroy), (gpointer) viewer->window);

  viewer_vsep(hbox);

  /* The selection buttons */
  button = viewer_button(hbox, "+Interfaces");
  gtk_tooltips_set_tip(tooltips, button, "Perform filtering on interfaces", NULL);
  gtk_signal_connect(GTK_OBJECT(button), "clicked",
                     GTK_SIGNAL_FUNC(button_periph_clicked), viewer);
  list_destroyed_periph(viewer->list, button_destroyed, button);

  button = viewer_button(hbox, "+Tags");
  gtk_tooltips_set_tip(tooltips, button, "Perform filtering on tags", NULL);
  gtk_signal_connect(GTK_OBJECT(button), "clicked",
                     GTK_SIGNAL_FUNC(button_tag_clicked), viewer);
  list_destroyed_tag(viewer->list, button_destroyed, button);

  button = viewer_button(hbox, "+Test cases");
  gtk_tooltips_set_tip(tooltips, button, "Perform filtering on Test Cases", NULL);
  gtk_signal_connect(GTK_OBJECT(button), "clicked",
                     GTK_SIGNAL_FUNC(button_case_clicked), viewer);
  list_destroyed_case(viewer->list, button_destroyed, button);

  viewer_vsep(hbox);

  button = viewer_button(hbox, "Clear selection");
  gtk_tooltips_set_tip(tooltips, button, "Clear all selected Log lines", NULL);
  gtk_signal_connect(GTK_OBJECT(button), "clicked",
                     GTK_SIGNAL_FUNC(button_clear_clicked), viewer);

  /* The search entry and buttons */
  hbox = gtk_hbox_new(FALSE, 10);
  gtk_widget_show(hbox);
  gtk_box_pack_start(GTK_BOX(viewer->button_box), hbox, FALSE, FALSE, 0);

  viewer->search_combo = gtk_combo_new();
  gtk_widget_show(viewer->search_combo);
  gtk_combo_disable_activate(GTK_COMBO(viewer->search_combo));
  gtk_combo_set_case_sensitive(GTK_COMBO(viewer->search_combo), 1);
  gtk_box_pack_start(GTK_BOX(hbox), viewer->search_combo, TRUE, TRUE, 0);
  gtk_signal_connect(GTK_OBJECT(GTK_COMBO(viewer->search_combo)->entry), "activate",
                     GTK_SIGNAL_FUNC(search_entry_validated), viewer);

  button = gtk_button_new_with_label("Find First");
  gtk_widget_show(button);
  gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
  gtk_signal_connect(GTK_OBJECT(button), "clicked",
                     GTK_SIGNAL_FUNC(search_button_clicked), viewer);

  button = gtk_button_new_with_label("Find Next");
  gtk_widget_show(button);
  gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
  gtk_signal_connect(GTK_OBJECT(button), "clicked",
                     GTK_SIGNAL_FUNC(search_entry_validated), viewer);

  viewer->search_info = gtk_check_button_new_with_label("Information only");
  gtk_widget_show(viewer->search_info);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(viewer->search_info), 1);
  gtk_box_pack_start(GTK_BOX(hbox), viewer->search_info, FALSE, FALSE, 0);

  viewer->search_case = gtk_check_button_new_with_label("Match case");
  gtk_widget_show(viewer->search_case);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(viewer->search_case), 0);
  gtk_box_pack_start(GTK_BOX(hbox), viewer->search_case, FALSE, FALSE, 0);

  viewer->search_history = NULL;
  viewer->search_list = NULL;
  search_history_load(viewer);

  /* Show this beautiful piece of art... */
  gtk_widget_show(viewer->window);

  /* Load result log file and fill the list with it */
  viewer->filew = NULL;
  viewer->filename = NULL;

  /* Clear destroyed signal handling */
  viewer->destroyed = NULL;
  viewer->destroyed_arg = NULL;

  /* The mouse cursors */
  viewer->cursor_watch = gdk_cursor_new(GDK_WATCH);

  /* Open the FAM connection */
  viewer_fam_open(viewer);

  return viewer;
}
Example #12
0
int video_mode(int f, int w, int h)
{
    int stereo  = config_get_d(CONFIG_STEREO)      ? 1 : 0;
    int stencil = config_get_d(CONFIG_REFLECTION)  ? 1 : 0;
    int buffers = config_get_d(CONFIG_MULTISAMPLE) ? 1 : 0;
    int samples = config_get_d(CONFIG_MULTISAMPLE);
    int vsync   = config_get_d(CONFIG_VSYNC)       ? 1 : 0;
    int hmd     = config_get_d(CONFIG_HMD)         ? 1 : 0;
    int highdpi = config_get_d(CONFIG_HIGHDPI)     ? 1 : 0;

    int dpy = config_get_d(CONFIG_DISPLAY);

    int X = SDL_WINDOWPOS_CENTERED_DISPLAY(dpy);
    int Y = SDL_WINDOWPOS_CENTERED_DISPLAY(dpy);

    hmd_free();

    if (window)
    {
        SDL_GL_DeleteContext(context);
        SDL_DestroyWindow(window);
    }

#if ENABLE_OPENGLES
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
#endif

    SDL_GL_SetAttribute(SDL_GL_STEREO,             stereo);
    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,       stencil);
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, buffers);
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, samples);

    /* Require 16-bit double buffer with 16-bit depth buffer. */

    SDL_GL_SetAttribute(SDL_GL_RED_SIZE,     5);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,   5);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,    5);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,  16);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    /* Try to set the currently specified mode. */

    log_printf("Creating a window (%dx%d, %s)\n",
               w, h, (f ? "fullscreen" : "windowed"));

    window = SDL_CreateWindow("", X, Y, w, h,
                              SDL_WINDOW_OPENGL |
                              (highdpi ? SDL_WINDOW_ALLOW_HIGHDPI : 0) |
                              (f ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0));

    if (window)
    {
        if ((context = SDL_GL_CreateContext(window)))
        {
            int buf, smp;

            SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &buf);
            SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &smp);

            /*
             * Work around SDL+WGL returning pixel formats below
             * minimum specifications instead of failing, thus
             * bypassing our fallback path. SDL tries to ensure that
             * WGL plays by the rules, but forgets about extended
             * context attributes such as multisample. See SDL
             * Bugzilla #77.
             */

            if (buf < buffers || smp < samples)
            {
                log_printf("GL context does not meet minimum specifications\n");
                SDL_GL_DeleteContext(context);
                context = NULL;
            }
        }
    }

    if (window && context)
    {
        set_window_title(TITLE);
        set_window_icon(ICON);

        /*
         * SDL_GetWindowSize can be unreliable when going fullscreen
         * on OSX (and possibly elsewhere). We should really be
         * waiting for a resize / size change event, but for now we're
         * doing this lazy thing instead.
         */

        if (f)
        {
            SDL_DisplayMode dm;

            if (SDL_GetDesktopDisplayMode(video_display(), &dm) == 0)
            {
                video.window_w = dm.w;
                video.window_h = dm.h;
            }
        }
        else
        {
            SDL_GetWindowSize(window, &video.window_w, &video.window_h);
        }

        if (highdpi)
        {
            SDL_GL_GetDrawableSize(window, &video.device_w, &video.device_h);
        }
        else
        {
            video.device_w = video.window_w;
            video.device_h = video.window_h;
        }

        video.device_scale = (float) video.device_h / (float) video.window_h;

        log_printf("Created a window (%u, %dx%d, %s)\n",
                   SDL_GetWindowID(window),
                   video.window_w, video.window_h,
                   (f ? "fullscreen" : "windowed"));

        config_set_d(CONFIG_DISPLAY,    video_display());
        config_set_d(CONFIG_FULLSCREEN, f);
        config_set_d(CONFIG_WIDTH,      video.window_w);
        config_set_d(CONFIG_HEIGHT,     video.window_h);

        SDL_GL_SetSwapInterval(vsync);

        if (!glext_init())
            return 0;

        glViewport(0, 0, video.device_w, video.device_h);
        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

        glEnable(GL_NORMALIZE);
        glEnable(GL_CULL_FACE);
        glEnable(GL_DEPTH_TEST);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_LIGHTING);
        glEnable(GL_BLEND);

#if !ENABLE_OPENGLES
        glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,
                      GL_SEPARATE_SPECULAR_COLOR);
#endif

        glPixelStorei(GL_PACK_ALIGNMENT, 1);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glDepthFunc(GL_LEQUAL);

        /* If GL supports multisample, and SDL got a multisample buffer... */

        if (glext_check("ARB_multisample"))
        {
            SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &buffers);
            if (buffers) glEnable(GL_MULTISAMPLE);
        }

        /* Set up HMD display if requested. */

        if (hmd)
            hmd_init();

        /* Initialize screen snapshotting. */

        snapshot_init();

        video_show_cursor();

        /* Grab input immediately in HMD mode. */

        if (hmd_stat())
            SDL_SetWindowGrab(window, SDL_TRUE);

        return 1;
    }

    /* If the mode failed, try it without stereo. */

    else if (stereo)
    {
        config_set_d(CONFIG_STEREO, 0);
        return video_mode(f, w, h);
    }

    /* If the mode failed, try decreasing the level of multisampling. */

    else if (buffers)
    {
        config_set_d(CONFIG_MULTISAMPLE, samples / 2);
        return video_mode(f, w, h);
    }

    /* If that mode failed, try it without reflections. */

    else if (stencil)
    {
        config_set_d(CONFIG_REFLECTION, 0);
        return video_mode(f, w, h);
    }

    /* If THAT mode failed, punt. */

    return 0;
}
Example #13
0
GtkWidget *gui_create_about_trans(void)
{
	GtkWidget *dialog_about_trans;
	GtkWidget *dialog_vbox;
	GtkWidget *vbox;
	GtkWidget *pixmap;
	GtkWidget *scrolledwindow;
	GtkWidget *label;
	GtkWidget *textview;
	GtkWidget *href;
	GtkWidget *dialog_action_area;
	GtkWidget *hbuttonbox;
	GtkWidget *button;
	gchar *about =
	    _("Do you like using Xiphos to study the Bible? "
	      "Would you like to see its user interface in your native language? "
	      "You could translate Xiphos! "
	      "\n\n"
	      "We are always looking for contributions of new "
	      "translations of Xiphos into other languages. "
	      "If you are able to translate for us, please see the link "
	      "below, contact us, and get involved with our efforts. Your help will "
	      "be much appreciated!");

	dialog_about_trans = gtk_dialog_new();
	g_object_set_data(G_OBJECT(dialog_about_trans),
			  "dialog_about_trans", dialog_about_trans);
	gtk_window_set_title(GTK_WINDOW(dialog_about_trans),
			     _("About Xiphos Translation"));
	set_window_icon(GTK_WINDOW(dialog_about_trans));
	gtk_window_set_resizable(GTK_WINDOW(dialog_about_trans), FALSE);

	dialog_vbox =
	    gtk_dialog_get_content_area(GTK_DIALOG(dialog_about_trans));
	g_object_set_data(G_OBJECT(dialog_about_trans), "dialog_vbox",
			  dialog_vbox);
	gtk_widget_show(dialog_vbox);

	UI_VBOX(vbox, FALSE, 0);
	gtk_widget_show(vbox);
	gtk_box_pack_start(GTK_BOX(dialog_vbox), vbox, TRUE, TRUE, 0);

	pixmap = pixmap_finder("logo.png");
	gtk_widget_show(pixmap);
	gtk_box_pack_start(GTK_BOX(vbox), pixmap, FALSE, FALSE, 4);

	scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
	gtk_widget_show(scrolledwindow);
	gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 4);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
				       GTK_POLICY_NEVER,
				       GTK_POLICY_AUTOMATIC);
	gtk_widget_set_size_request(scrolledwindow, 400, 150);
	gtk_container_set_border_width(GTK_CONTAINER(scrolledwindow), 4);
	gtk_scrolled_window_set_shadow_type((GtkScrolledWindow *)
					    scrolledwindow,
					    settings.shadow_type);

	textview = gtk_text_view_new();
	gtk_widget_show(textview);
	gtk_container_add(GTK_CONTAINER(scrolledwindow), textview);
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview),
				    GTK_WRAP_WORD);
	gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);
	gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)), about, -1);
	gtk_widget_set_sensitive(textview, FALSE);

	label = gtk_label_new(_("See TRANSLATION-HOWTO in Xiphos source"));
	gtk_widget_show(label);
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
	gtk_widget_set_size_request(label, -2, 24);

	href =
	    gtk_link_button_new_with_label("http://xiphos.org/development/", _("Xiphos development"));
	gtk_widget_show(href);
	gtk_box_pack_start(GTK_BOX(vbox), href, FALSE, FALSE, 0);

	dialog_action_area =
#ifdef HAVE_GTK_312
	    gtk_dialog_get_content_area(GTK_DIALOG(dialog_about_trans));
#else
	    gtk_dialog_get_action_area(GTK_DIALOG(dialog_about_trans));
#endif
	g_object_set_data(G_OBJECT(dialog_about_trans),
			  "dialog_action_area", dialog_action_area);
	gtk_widget_show(dialog_action_area);
	gtk_container_set_border_width(GTK_CONTAINER(dialog_action_area), 10);

#ifdef USE_GTK_3
	hbuttonbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
#else
	hbuttonbox = gtk_hbutton_box_new();
#endif
	gtk_widget_show(hbuttonbox);
	gtk_box_pack_start(GTK_BOX(dialog_action_area), hbuttonbox,
			   TRUE, TRUE, 0);
	gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox),
				  GTK_BUTTONBOX_END);
	button =
#ifdef HAVE_GTK_310
	    gtk_button_new_with_mnemonic(_("Close"));
#else
	    gtk_button_new_from_stock(GTK_STOCK_CLOSE);
#endif
	gtk_widget_show(button);
	gtk_container_add(GTK_CONTAINER(hbuttonbox), button);
#ifdef HAVE_GTK_218
	gtk_widget_set_can_default(button, TRUE);
#elif defined(USE_GTK_3)
	gtk_widget_set_can_default(button, 1);
#else
	GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
#endif
	g_signal_connect(G_OBJECT(button), "clicked",
			 G_CALLBACK(about_trans_ok), NULL);
	return dialog_about_trans;
}
Example #14
0
int video_mode(int f, int w, int h)
{
    int stereo  = config_get_d(CONFIG_STEREO)      ? 1 : 0;
    int stencil = config_get_d(CONFIG_REFLECTION)  ? 1 : 0;
    int buffers = config_get_d(CONFIG_MULTISAMPLE) ? 1 : 0;
    int samples = config_get_d(CONFIG_MULTISAMPLE);
    int vsync   = config_get_d(CONFIG_VSYNC)       ? 1 : 0;
    int hmd     = config_get_d(CONFIG_HMD)         ? 1 : 0;

    int dpy = config_get_d(CONFIG_DISPLAY);

    int X = SDL_WINDOWPOS_CENTERED_DISPLAY(dpy);
    int Y = SDL_WINDOWPOS_CENTERED_DISPLAY(dpy);

    hmd_free();

    if (window)
    {
        SDL_GL_DeleteContext(context);
        SDL_DestroyWindow(window);
    }

    SDL_GL_SetAttribute(SDL_GL_STEREO,             stereo);
    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,       stencil);
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, buffers);
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, samples);

    /* Require 16-bit double buffer with 16-bit depth buffer. */

    SDL_GL_SetAttribute(SDL_GL_RED_SIZE,     5);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,   5);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,    5);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,  16);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    /* Try to set the currently specified mode. */

    window = SDL_CreateWindow("", X, Y, w, h,
                              SDL_WINDOW_OPENGL |
                              (f ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0));

    if (window)
    {
        set_window_title(TITLE);
        set_window_icon(ICON);

        SDL_GetWindowSize(window, &w, &h);

        config_set_d(CONFIG_DISPLAY,    video_display());
        config_set_d(CONFIG_FULLSCREEN, f);
        config_set_d(CONFIG_WIDTH,      w);
        config_set_d(CONFIG_HEIGHT,     h);

        context = SDL_GL_CreateContext(window);

        SDL_GL_SetSwapInterval(vsync);

        if (!glext_init())
            return 0;

        glViewport(0, 0, w, h);
        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

        glEnable(GL_NORMALIZE);
        glEnable(GL_CULL_FACE);
        glEnable(GL_DEPTH_TEST);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_LIGHTING);
        glEnable(GL_BLEND);

#if !ENABLE_OPENGLES
        glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,
                      GL_SEPARATE_SPECULAR_COLOR);
#endif

        glPixelStorei(GL_PACK_ALIGNMENT, 1);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glDepthFunc(GL_LEQUAL);

        /* If GL supports multisample, and SDL got a multisample buffer... */

        if (glext_check("ARB_multisample"))
        {
            SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &buffers);
            if (buffers) glEnable(GL_MULTISAMPLE);
        }

        /* Set up HMD display if requested. */

        if (hmd)
            hmd_init();

        /* Initialize screen snapshotting. */

        snapshot_init();

        video_show_cursor();

        /* Grab input immediately in HMD mode. */

        if (hmd_stat())
            SDL_SetWindowGrab(window, SDL_TRUE);

        return 1;
    }

    /* If the mode failed, try it without stereo. */

    else if (stereo)
    {
        config_set_d(CONFIG_STEREO, 0);
        return video_mode(f, w, h);
    }

    /* If the mode failed, try decreasing the level of multisampling. */

    else if (buffers)
    {
        config_set_d(CONFIG_MULTISAMPLE, samples / 2);
        return video_mode(f, w, h);
    }

    /* If that mode failed, try it without reflections. */

    else if (stencil)
    {
        config_set_d(CONFIG_REFLECTION, 0);
        return video_mode(f, w, h);
    }

    /* If THAT mode failed, punt. */

    return 0;
}