2 * Copyright (c) 2007-2013, Czirkos Zoltan http://code.google.com/p/gdash/
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
19 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 #include "gtk/gtkmainwindow.hpp"
27 #include "sdl/sdlmainwindow.hpp"
28 #include "misc/logger.hpp"
29 #include "misc/printf.hpp"
30 #include "mainwindow.hpp"
31 #include "settings.hpp"
33 /* The should be in the same order as the enum. */
34 const char *gd_graphics_engine_names
[] = {
45 void main_window_run_title_screen(CaveSet
*caveset
, NextAction
&na
) {
46 /* if some unknown engine, switch to default */
47 if (gd_graphics_engine
>= GRAPHICS_ENGINE_MAX
)
48 gd_graphics_engine
= GraphicsEngine(0);
51 switch (GraphicsEngine(gd_graphics_engine
)) {
53 case GRAPHICS_ENGINE_GTK
:
54 gd_main_window_gtk_run(caveset
, na
);
58 case GRAPHICS_ENGINE_SDL
:
59 gd_main_window_sdl_run(caveset
, na
, false);
61 case GRAPHICS_ENGINE_OPENGL
:
62 gd_main_window_sdl_run(caveset
, na
, true);
65 case GRAPHICS_ENGINE_MAX
:
66 g_assert_not_reached();
69 } catch (ScreenConfigureException
const & ex
) {
70 gd_warning(CPrintf("Screen error: %s. Switching to default graphics engine.") % ex
.what());
71 gd_graphics_engine
= 0;
75 void main_window_run_a_game(GameControl
*game
) {
76 /* if some unknown engine, switch to default */
77 if (gd_graphics_engine
>= GRAPHICS_ENGINE_MAX
)
78 gd_graphics_engine
= GraphicsEngine(0);
81 switch (GraphicsEngine(gd_graphics_engine
)) {
83 case GRAPHICS_ENGINE_GTK
:
84 gd_main_window_gtk_run_a_game(game
);
88 case GRAPHICS_ENGINE_SDL
:
89 gd_main_window_sdl_run_a_game(game
, false);
91 case GRAPHICS_ENGINE_OPENGL
:
92 gd_main_window_sdl_run_a_game(game
, true);
95 case GRAPHICS_ENGINE_MAX
:
96 g_assert_not_reached();
99 } catch (ScreenConfigureException
const & ex
) {
100 gd_warning(CPrintf("Screen error: %s. Switching to default graphics engine.") % ex
.what());
101 gd_graphics_engine
= 0;