From: grumbel Date: Sun, 6 Dec 2009 09:41:00 +0000 (+0000) Subject: Added empty SurfaceData class so we don't have to pass around void* pointers and... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=fb129d19958d9a5aa57d894cb0f63ca0e23a1885;p=supertux.git Added empty SurfaceData class so we don't have to pass around void* pointers and break destruction git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6184 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- diff --git a/src/video/gl/gl_surface_data.hpp b/src/video/gl/gl_surface_data.hpp index 0a4f46c53..ca906f710 100644 --- a/src/video/gl/gl_surface_data.hpp +++ b/src/video/gl/gl_surface_data.hpp @@ -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; diff --git a/src/video/sdl/sdl_surface_data.hpp b/src/video/sdl/sdl_surface_data.hpp index 47268ee49..244f4b4c8 100644 --- a/src/video/sdl/sdl_surface_data.hpp +++ b/src/video/sdl/sdl_surface_data.hpp @@ -22,9 +22,10 @@ #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; diff --git a/src/video/surface.cpp b/src/video/surface.cpp index c996e51bd..5f1caf00c 100644 --- a/src/video/surface.cpp +++ b/src/video/surface.cpp @@ -100,7 +100,7 @@ Surface::get_texture() const return texture; } -void* +SurfaceData* Surface::get_surface_data() const { return surface_data; diff --git a/src/video/surface.hpp b/src/video/surface.hpp index 9c84cf830..e5d5c9725 100644 --- a/src/video/surface.hpp +++ b/src/video/surface.hpp @@ -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 index 000000000..8f1f4bced --- /dev/null +++ b/src/video/surface_data.hpp @@ -0,0 +1,28 @@ +// SuperTux +// Copyright (C) 2009 Ingo Ruhnke +// +// 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 . + +#ifndef HEADER_SUPERTUX_VIDEO_SURFACE_DATA_HPP +#define HEADER_SUPERTUX_VIDEO_SURFACE_DATA_HPP + +class SurfaceData +{ +public: + virtual ~SurfaceData() {} +}; + +#endif + +/* EOF */ diff --git a/src/video/video_systems.cpp b/src/video/video_systems.cpp index c148990ae..ca86eb1e2 100644 --- a/src/video/video_systems.cpp +++ b/src/video/video_systems.cpp @@ -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(surface_data); + delete surface_data; } VideoSystem::Enum diff --git a/src/video/video_systems.hpp b/src/video/video_systems.hpp index d15d06710..a09cd765b 100644 --- a/src/video/video_systems.hpp +++ b/src/video/video_systems.hpp @@ -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);