throw std::runtime_error(msg.str());
}
- m_surfaces[filename] = image;
+ SDL_PixelFormat* format = image->format;
+ if(format->Rmask == 0 && format->Gmask == 0 && format->Bmask == 0 && format->Amask == 0) {
+ log_warning << "Wrong surface format for image " << filename << ". Compensating." << std::endl;
+
+ SDL_Surface* converted_surf = SDL_ConvertSurfaceFormat(image, SDL_PIXELFORMAT_RGBA8888, 0);
+ m_surfaces[filename] = converted_surf;
+ }
+ else
+ {
+ m_surfaces[filename] = image;
+ }
}
SDLSurfacePtr subimage(SDL_CreateRGBSurfaceFrom(static_cast<uint8_t*>(image->pixels) +
SDLSurfacePtr image(SDL_CreateRGBSurface(0, 1024, 1024, 8, 0, 0, 0, 0));
if (!image)
{
- throw err;
+ throw;
}
else
{
void
TextureManager::save_textures()
{
-#ifdef GL_PACK_ROW_LENGTH
+#if defined(GL_PACK_ROW_LENGTH) || defined(USE_GLBINDING)
/* all this stuff is not support by OpenGL ES */
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
glPixelStorei(GL_PACK_IMAGE_HEIGHT, 0);
for(ImageTextures::iterator i = m_image_textures.begin();
i != m_image_textures.end(); ++i)
{
- save_texture(dynamic_cast<GLTexture*>(i->second.lock().get()));
+ GLTexture* texture = dynamic_cast<GLTexture*>(i->second.lock().get());
+ if(texture == NULL)
+ continue;
+
+ save_texture(texture);
}
}
void
TextureManager::reload_textures()
{
-#ifdef GL_UNPACK_ROW_LENGTH
+#if defined(GL_UNPACK_ROW_LENGTH) || defined(USE_GLBINDING)
/* OpenGL ES doesn't support these */
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
assert_gl("creating texture handle");
glBindTexture(GL_TEXTURE_2D, handle);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
+ glTexImage2D(GL_TEXTURE_2D, 0, static_cast<GLint>(GL_RGBA),
saved_texture.width, saved_texture.height,
saved_texture.border, GL_RGBA,
GL_UNSIGNED_BYTE, saved_texture.pixels);