-// $Id: video_systems.cpp 5063 2007-05-27 11:32:00Z matzeb $
-//
// SuperTux
// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
//
-// 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
// 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 <http://www.gnu.org/licenses/>.
+
#include <config.h>
-#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"
-Renderer *new_renderer()
+#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*
+VideoSystem::new_renderer()
{
- switch(config->video)
+ switch(g_config->video)
{
case AUTO_VIDEO:
#ifdef HAVE_OPENGL
- return new GL::Renderer();
-#else
- 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:
- return new GL::Renderer();
+ log_info << "new GL renderer\n";
+ return new GLRenderer();
#endif
case PURE_SDL:
- return new SDL::Renderer();
+ log_info << "new SDL renderer\n";
+ return new SDLRenderer();
default:
assert(0 && "invalid video system in config");
#ifdef HAVE_OPENGL
- return new GL::Renderer();
+ log_info << "new GL renderer\n";
+ return new GLRenderer();
#else
- return new SDL::Renderer();
+ log_warning << "new SDL renderer\n";
+ 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<char *>(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")
{
}
}
-std::string get_video_string(VideoSystem video)
+std::string
+VideoSystem::get_video_string(VideoSystem::Enum video)
{
switch(video)
{
return "auto";
}
}
+
+/* EOF */