aspect_size(0, 0), // auto detect
magnification(1.0f),
use_fullscreen(false),
- video(AUTO_VIDEO),
+ video(VideoSystem::AUTO_VIDEO),
try_vsync(true),
show_fps(false),
sound_enabled(true),
config_video_lisp->get("fullscreen", use_fullscreen);
std::string video_string;
config_video_lisp->get("video", video_string);
- video = get_video_system(video_string);
+ video = VideoSystem::get_video_system(video_string);
config_video_lisp->get("vsync", try_vsync);
config_video_lisp->get("fullscreen_width", fullscreen_size.width);
writer.start_list("video");
writer.write("fullscreen", use_fullscreen);
- writer.write("video", get_video_string(video));
+ writer.write("video", VideoSystem::get_video_string(video));
writer.write("vsync", try_vsync);
writer.write("fullscreen_width", fullscreen_size.width);
float magnification;
bool use_fullscreen;
- VideoSystem video;
+ VideoSystem::Enum video;
bool try_vsync;
bool show_fps;
bool sound_enabled;
}
else
{
- g_config->video = get_video_system(argv[i]);
+ g_config->video = VideoSystem::get_video_system(argv[i]);
}
} else if(arg == "--show-fps") {
g_config->show_fps = true;
delete renderer;
delete lightmap;
- renderer = new_renderer();
- lightmap = new_lightmap();
+ renderer = VideoSystem::new_renderer();
+ lightmap = VideoSystem::new_lightmap();
}
void
flipx(false)
{
texture->ref();
- surface_data = new_surface_data(*this);
+ surface_data = VideoSystem::new_surface_data(*this);
}
Surface::Surface(const std::string& file, const Rect& rect_) :
flipx(false)
{
texture->ref();
- surface_data = new_surface_data(*this);
+ surface_data = VideoSystem::new_surface_data(*this);
}
Surface::Surface(const Surface& rhs) :
flipx(false)
{
texture->ref();
- surface_data = new_surface_data(*this);
+ surface_data = VideoSystem::new_surface_data(*this);
}
const Surface&
Surface::~Surface()
{
- free_surface_data(surface_data);
+ VideoSystem::free_surface_data(surface_data);
texture->unref();
}
Texture* result = 0;
try {
- result = new_texture(image);
+ result = VideoSystem::new_texture(image);
result->set_filename(filename);
} catch(...) {
delete result;
Texture* result = 0;
try {
- result = new_texture(image);
+ result = VideoSystem::new_texture(image);
result->set_filename("-dummy-texture-.png");
} catch(...) {
delete result;
#include "video/texture.hpp"
#include "video/video_systems.hpp"
-Renderer *new_renderer()
+Renderer*
+VideoSystem::new_renderer()
{
switch(g_config->video)
{
}
}
-Lightmap *new_lightmap()
+Lightmap*
+VideoSystem::new_lightmap()
{
switch(g_config->video)
{
}
}
-Texture *new_texture(SDL_Surface *image)
+Texture*
+VideoSystem::new_texture(SDL_Surface *image)
{
switch(g_config->video)
{
}
}
-void *new_surface_data(const Surface &surface)
+void*
+VideoSystem::new_surface_data(const Surface &surface)
{
switch(g_config->video)
{
}
}
-void free_surface_data(void *surface_data)
+void
+VideoSystem::free_surface_data(void *surface_data)
{
+ // FIXME: this won't call any destructors
delete reinterpret_cast<char *>(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)
{
class Texture;
class Surface;
-enum VideoSystem {
- AUTO_VIDEO,
- OPENGL,
- PURE_SDL,
- NUM_SYSTEMS
+class VideoSystem
+{
+public:
+ enum Enum {
+ AUTO_VIDEO,
+ OPENGL,
+ PURE_SDL,
+ NUM_SYSTEMS
+ };
+
+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 Enum get_video_system(const std::string &video);
+ static std::string get_video_string(Enum video);
+
+private:
+ VideoSystem();
+ VideoSystem(const VideoSystem&);
+ VideoSystem& operator=(const VideoSystem&);
};
-Renderer* new_renderer();
-Lightmap* new_lightmap();
-Texture* new_texture(SDL_Surface *image);
-void* new_surface_data(const Surface &surface);
-void free_surface_data(void *surface_data);
-VideoSystem get_video_system(const std::string &video);
-std::string get_video_string(VideoSystem video);
-
#endif
/* EOF */