X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fvideo%2Fvideo_systems.cpp;h=27fd417608ad7b12aebde6a2c386ea71115d132a;hb=08bddcf4d4fbe2edf9a0078dc6f3c3275ef05302;hp=261285729b91eec6d04a1856ad9a7a7993121f9d;hpb=60301a8f1268695058e2241473e1aaa7c28cd9d9;p=supertux.git diff --git a/src/video/video_systems.cpp b/src/video/video_systems.cpp index 261285729..27fd41760 100644 --- a/src/video/video_systems.cpp +++ b/src/video/video_systems.cpp @@ -1,12 +1,10 @@ -// $Id: video_systems.cpp 5063 2007-05-27 11:32:00Z matzeb $ -// // SuperTux // Copyright (C) 2006 Matthias Braun // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,140 +12,152 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// along with this program. If not, see . + #include -#include "video_systems.hpp" -#include "gameconfig.hpp" -#include "renderer.hpp" -#include "gl_renderer.hpp" -#include "sdl_renderer.hpp" -#include "lightmap.hpp" -#include "gl_lightmap.hpp" -#include "sdl_lightmap.hpp" -#include "texture.hpp" -#include "gl_texture.hpp" -#include "sdl_texture.hpp" -#include "gl_surface_data.hpp" -#include "sdl_surface_data.hpp" +#include "supertux/gameconfig.hpp" +#include "video/lightmap.hpp" +#include "video/renderer.hpp" +#include "video/sdl/sdl_lightmap.hpp" +#include "video/sdl/sdl_renderer.hpp" +#include "video/sdl/sdl_surface_data.hpp" +#include "video/sdl/sdl_texture.hpp" +#include "video/texture.hpp" +#include "video/video_systems.hpp" + +#ifdef HAVE_OPENGL +#include "video/gl/gl_lightmap.hpp" +#include "video/gl/gl_renderer.hpp" +#include "video/gl/gl_surface_data.hpp" +#include "video/gl/gl_texture.hpp" +#endif -Renderer *new_renderer() +Renderer* +VideoSystem::new_renderer() { - switch(config->video) + switch(g_config->video) { case AUTO_VIDEO: #ifdef HAVE_OPENGL - log_info << "new GL renderer\n"; - return new GL::Renderer(); -#else - log_warning << "new SDL renderer\n"; - return new SDL::Renderer(); + try { + log_info << "new GL renderer\n"; + return new GLRenderer(); + } catch(std::runtime_error& e) { + log_warning << "Error creating GL renderer: " << e.what() << std::endl; #endif + log_warning << "new SDL renderer\n"; + return new SDLRenderer(); #ifdef HAVE_OPENGL + } case OPENGL: log_info << "new GL renderer\n"; - return new GL::Renderer(); + return new GLRenderer(); #endif case PURE_SDL: - log_warning << "new SDL renderer\n"; - return new SDL::Renderer(); + log_info << "new SDL renderer\n"; + return new SDLRenderer(); default: assert(0 && "invalid video system in config"); #ifdef HAVE_OPENGL log_info << "new GL renderer\n"; - return new GL::Renderer(); + return new GLRenderer(); #else log_warning << "new SDL renderer\n"; - return new SDL::Renderer(); + return new SDLRenderer(); #endif } } -Lightmap *new_lightmap() +Lightmap* +VideoSystem::new_lightmap() { - switch(config->video) + switch(g_config->video) { case AUTO_VIDEO: #ifdef HAVE_OPENGL - return new GL::Lightmap(); + return new GLLightmap(); #else - return new SDL::Lightmap(); + return new SDLLightmap(); #endif #ifdef HAVE_OPENGL case OPENGL: - return new GL::Lightmap(); + return new GLLightmap(); #endif case PURE_SDL: - return new SDL::Lightmap(); + return new SDLLightmap(); default: assert(0 && "invalid video system in config"); #ifdef HAVE_OPENGL - return new GL::Lightmap(); + return new GLLightmap(); #else - return new SDL::Lightmap(); + return new SDLLightmap(); #endif } } -Texture *new_texture(SDL_Surface *image) +TexturePtr +VideoSystem::new_texture(SDL_Surface *image) { - switch(config->video) + switch(g_config->video) { case AUTO_VIDEO: #ifdef HAVE_OPENGL - return new GL::Texture(image); + return TexturePtr(new GLTexture(image)); #else - return new SDL::Texture(image); + return TexturePtr(new SDLTexture(image)); #endif #ifdef HAVE_OPENGL case OPENGL: - return new GL::Texture(image); + return TexturePtr(new GLTexture(image)); #endif case PURE_SDL: - return new SDL::Texture(image); + return TexturePtr(new SDLTexture(image)); default: assert(0 && "invalid video system in config"); #ifdef HAVE_OPENGL - return new GL::Texture(image); + return TexturePtr(new GLTexture(image)); #else - return new SDL::Texture(image); + return TexturePtr(new SDLTexture(image)); #endif } } -void *new_surface_data(const Surface &surface) +SurfaceData* +VideoSystem::new_surface_data(const Surface &surface) { - switch(config->video) + switch(g_config->video) { case AUTO_VIDEO: #ifdef HAVE_OPENGL - return new GL::SurfaceData(surface); + return new GLSurfaceData(surface); #else - return new SDL::SurfaceData(surface); + return new SDLSurfaceData(surface); #endif #ifdef HAVE_OPENGL case OPENGL: - return new GL::SurfaceData(surface); + return new GLSurfaceData(surface); #endif case PURE_SDL: - return new SDL::SurfaceData(surface); + return new SDLSurfaceData(surface); default: assert(0 && "invalid video system in config"); #ifdef HAVE_OPENGL - return new GL::SurfaceData(surface); + return new GLSurfaceData(surface); #else - return new SDL::SurfaceData(surface); + return new SDLSurfaceData(surface); #endif } } -void free_surface_data(void *surface_data) +void +VideoSystem::free_surface_data(SurfaceData* surface_data) { - delete reinterpret_cast(surface_data); + delete surface_data; } -VideoSystem get_video_system(const std::string &video) +VideoSystem::Enum +VideoSystem::get_video_system(const std::string &video) { if(video == "auto") { @@ -169,7 +179,8 @@ VideoSystem get_video_system(const std::string &video) } } -std::string get_video_string(VideoSystem video) +std::string +VideoSystem::get_video_string(VideoSystem::Enum video) { switch(video) { @@ -184,3 +195,5 @@ std::string get_video_string(VideoSystem video) return "auto"; } } + +/* EOF */