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"
36 std::unique_ptr<Renderer>
37 VideoSystem::new_renderer()
39 switch(g_config->video)
44 log_info << "new GL renderer\n";
45 return std::unique_ptr<Renderer>(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 std::unique_ptr<Renderer>(new SDLRenderer());
54 log_info << "new GL renderer\n";
55 return std::unique_ptr<Renderer>(new GLRenderer());
58 log_info << "new SDL renderer\n";
59 return std::unique_ptr<Renderer>(new SDLRenderer());
61 assert(0 && "invalid video system in config");
63 log_info << "new GL renderer\n";
64 return std::unique_ptr<Renderer>(new GLRenderer());
66 log_warning << "new SDL renderer\n";
67 return std::unique_ptr<Renderer>(new SDLRenderer());
72 std::unique_ptr<Lightmap>
73 VideoSystem::new_lightmap()
75 switch(g_config->video)
79 return std::unique_ptr<Lightmap>(new GLLightmap());
81 return std::unique_ptr<Lightmap>(new SDLLightmap());
85 return std::unique_ptr<Lightmap>(new GLLightmap());
88 return std::unique_ptr<Lightmap>(new SDLLightmap());
90 assert(0 && "invalid video system in config");
92 return std::unique_ptr<Lightmap>(new GLLightmap());
94 return std::unique_ptr<Lightmap>(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)
156 if(surface_data == NULL)
163 VideoSystem::get_video_system(const std::string &video)
170 else if(video == "opengl")
175 else if(video == "sdl")
186 VideoSystem::get_video_string(VideoSystem::Enum video)
197 assert(0 && "invalid video system in config");