Added empty SurfaceData class so we don't have to pass around void* pointers and...
authorgrumbel <grumbel@837edb03-e0f3-0310-88ca-d4d4e8b29345>
Sun, 6 Dec 2009 09:41:00 +0000 (09:41 +0000)
committergrumbel <grumbel@837edb03-e0f3-0310-88ca-d4d4e8b29345>
Sun, 6 Dec 2009 09:41:00 +0000 (09:41 +0000)
git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6184 837edb03-e0f3-0310-88ca-d4d4e8b29345

src/video/gl/gl_surface_data.hpp
src/video/sdl/sdl_surface_data.hpp
src/video/surface.cpp
src/video/surface.hpp
src/video/surface_data.hpp [new file with mode: 0644]
src/video/video_systems.cpp
src/video/video_systems.hpp

index 0a4f46c..ca906f7 100644 (file)
@@ -18,8 +18,9 @@
 #define HEADER_SUPERTUX_VIDEO_GL_SURFACE_DATA_HPP
 
 #include "video/surface.hpp"
+#include "video/surface_data.hpp"
 
-class GLSurfaceData
+class GLSurfaceData : public SurfaceData
 {
 private:
   const Surface &surface;
index 47268ee..244f4b4 100644 (file)
 #include "supertux/gameconfig.hpp"
 #include "supertux/globals.hpp"
 #include "video/surface.hpp"
+#include "video/surface_data.hpp"
 #include "video/texture.hpp"
 
-class SDLSurfaceData
+class SDLSurfaceData : public SurfaceData
 {
 private:
   const Surface &surface;
index c996e51..5f1caf0 100644 (file)
@@ -100,7 +100,7 @@ Surface::get_texture() const
   return texture;
 }
 
-void
+SurfaceData
 Surface::get_surface_data() const
 {
   return surface_data;
index 9c84cf8..e5d5c97 100644 (file)
@@ -24,6 +24,7 @@
 #include "math/rect.hpp"
 
 class Texture;
+class SurfaceData;
 
 /**
  * A rectangular image.
@@ -38,7 +39,7 @@ public:
 
 private:
   Texture* texture;
-  void *surface_data;
+  SurfaceData* surface_data;
   Rect rect;
   bool flipx;
 
@@ -55,7 +56,7 @@ public:
   bool get_flipx() const;
 
   Texture *get_texture() const;
-  void *get_surface_data() const;
+  SurfaceData* get_surface_data() const;
   int get_x() const;
   int get_y() const;
   int get_width() const;
diff --git a/src/video/surface_data.hpp b/src/video/surface_data.hpp
new file mode 100644 (file)
index 0000000..8f1f4bc
--- /dev/null
@@ -0,0 +1,28 @@
+//  SuperTux
+//  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.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 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
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  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, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_VIDEO_SURFACE_DATA_HPP
+#define HEADER_SUPERTUX_VIDEO_SURFACE_DATA_HPP
+
+class SurfaceData
+{
+public:
+  virtual ~SurfaceData() {}
+};
+
+#endif
+
+/* EOF */
index c148990..ca86eb1 100644 (file)
@@ -117,7 +117,7 @@ VideoSystem::new_texture(SDL_Surface *image)
   }
 }
 
-void*
+SurfaceData*
 VideoSystem::new_surface_data(const Surface &surface)
 {
   switch(g_config->video)
@@ -145,10 +145,9 @@ VideoSystem::new_surface_data(const Surface &surface)
 }
 
 void
-VideoSystem::free_surface_data(void *surface_data)
+VideoSystem::free_surface_data(SurfaceData* surface_data)
 {
-  // FIXME: this won't call any destructors
-  delete reinterpret_cast<char *>(surface_data);
+  delete surface_data;
 }
 
 VideoSystem::Enum
index d15d067..a09cd76 100644 (file)
@@ -26,6 +26,7 @@ class Renderer;
 class Lightmap;
 class Texture;
 class Surface;
+class SurfaceData;
 
 class VideoSystem
 {
@@ -41,8 +42,8 @@ public:
   static Renderer* new_renderer();
   static Lightmap* new_lightmap();
   static Texture*  new_texture(SDL_Surface *image);
-  static void*     new_surface_data(const Surface &surface);
-  static void      free_surface_data(void *surface_data);
+  static SurfaceData* new_surface_data(const Surface &surface);
+  static void      free_surface_data(SurfaceData* surface_data);
 
   static Enum get_video_system(const std::string &video);
   static std::string get_video_string(Enum video);