2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "supertux/gameconfig.hpp"
20 #include "video/lightmap.hpp"
21 #include "video/renderer.hpp"
22 #include "video/sdl/sdl_lightmap.hpp"
23 #include "video/sdl/sdl_renderer.hpp"
24 #include "video/sdl/sdl_surface_data.hpp"
25 #include "video/sdl/sdl_texture.hpp"
26 #include "video/texture.hpp"
27 #include "video/video_systems.hpp"
30 #include "video/gl/gl_lightmap.hpp"
31 #include "video/gl/gl_renderer.hpp"
32 #include "video/gl/gl_surface_data.hpp"
33 #include "video/gl/gl_texture.hpp"
37 VideoSystem::new_renderer()
39 switch(g_config->video)
44 log_info << "new GL renderer\n";
45 return new GLRenderer();
46 } catch(std::runtime_error& e) {
47 log_warning << "Error creating GL renderer: " << e.what() << std::endl;
49 log_warning << "new SDL renderer\n";
50 return new SDLRenderer();
54 log_info << "new GL renderer\n";
55 return new GLRenderer();
58 log_info << "new SDL renderer\n";
59 return new SDLRenderer();
61 assert(0 && "invalid video system in config");
63 log_info << "new GL renderer\n";
64 return new GLRenderer();
66 log_warning << "new SDL renderer\n";
67 return new SDLRenderer();
73 VideoSystem::new_lightmap()
75 switch(g_config->video)
79 return new GLLightmap();
81 return new SDLLightmap();
85 return new GLLightmap();
88 return new SDLLightmap();
90 assert(0 && "invalid video system in config");
92 return new GLLightmap();
94 return new SDLLightmap();
100 VideoSystem::new_texture(SDL_Surface *image)
102 switch(g_config->video)
106 return TexturePtr(new GLTexture(image));
108 return TexturePtr(new SDLTexture(image));
112 return TexturePtr(new GLTexture(image));
115 return TexturePtr(new SDLTexture(image));
117 assert(0 && "invalid video system in config");
119 return TexturePtr(new GLTexture(image));
121 return TexturePtr(new SDLTexture(image));
127 VideoSystem::new_surface_data(const Surface &surface)
129 switch(g_config->video)
133 return new GLSurfaceData(surface);
135 return new SDLSurfaceData(surface);
139 return new GLSurfaceData(surface);
142 return new SDLSurfaceData(surface);
144 assert(0 && "invalid video system in config");
146 return new GLSurfaceData(surface);
148 return new SDLSurfaceData(surface);
154 VideoSystem::free_surface_data(SurfaceData* surface_data)
160 VideoSystem::get_video_system(const std::string &video)
167 else if(video == "opengl")
172 else if(video == "sdl")
183 VideoSystem::get_video_string(VideoSystem::Enum video)
194 assert(0 && "invalid video system in config");