#include <SDL_image.h>
#include "gameconfig.h"
+#include "physfs/physfs_sdl.h"
#include "video/surface.h"
#include "video/screen.h"
-#include "app/globals.h"
-#include "app/setup.h"
-
-using namespace SuperTux;
Surface::Surfaces Surface::surfaces;
}
Surface::Surface(SDL_Surface* surf, bool use_alpha)
- : data(surf, use_alpha), w(0), h(0)
+ : impl(0), data(surf, use_alpha), w(0), h(0)
{
impl = data.create();
if (impl)
}
Surface::Surface(const std::string& file, bool use_alpha)
- : data(file, use_alpha), w(0), h(0)
+ : impl(0), data(file, use_alpha), w(0), h(0)
{
impl = data.create();
if (impl)
}
Surface::Surface(const std::string& file, int x, int y, int w_, int h_, bool use_alpha)
- : data(file, x, y, w_, h_, use_alpha), w(0), h(0)
+ : impl(0), data(file, x, y, w_, h_, use_alpha), w(0), h(0)
{
impl = data.create();
if (impl)
}
Surface::Surface(Color top_background, Color bottom_background, int w_, int h_)
- : data(top_background, bottom_background, w_, h_), w(0), h(0)
+ : impl(0), data(top_background, bottom_background, w_, h_), w(0), h(0)
{
impl = data.create();
if (impl)
SDL_Surface * temp;
SDL_Surface * conv;
- temp = IMG_Load(file.c_str());
-
- if (temp == NULL) {
+ temp = IMG_Load_RW(get_physfs_SDLRWops(file), true);
+ if (temp == 0) {
std::stringstream msg;
msg << "Couldn't load '" << file << "': " << SDL_GetError();
throw std::runtime_error(msg.str());
SDL_Surface* sdl_surface;
SDL_Surface* temp;
- temp = IMG_Load(file.c_str());
-
- if (temp == NULL) {
+ temp = IMG_Load_RW(get_physfs_SDLRWops(file), true);
+ if (temp == 0) {
std::stringstream msg;
msg << "Couldn't load file '" << file << "': " << SDL_GetError();
throw std::runtime_error(msg.str());
//---------------------------------------------------------------------------
SurfaceImpl::SurfaceImpl()
+ : sdl_surface(0)
{}
SurfaceImpl::~SurfaceImpl()
{
- SDL_FreeSurface(sdl_surface);
+ if(sdl_surface != 0)
+ SDL_FreeSurface(sdl_surface);
}
SDL_Surface* SurfaceImpl::get_sdl_surface() const
// is present store in RGB instead of RGBA, this saves a few bytes
// of memory, but much more importantly it makes the game look
// *much* better in 16bit color mode
- int internal_format = GL_RGB10_A2;
+ int internal_format = GL_RGBA;
bool has_alpha = false;
unsigned char* buf = static_cast<unsigned char*>(conv->pixels);