- SDL_Surface* image = IMG_Load_RW(get_physfs_SDLRWops(filename), 1);
- if(image == NULL) {
- std::ostringstream msg;
- msg << "Couldn't load image '" << filename << "' :" << SDL_GetError();
- throw std::runtime_error(msg.str());
- }
-
- int texture_w = next_power_of_two(image->w);
- int texture_h = next_power_of_two(image->h);
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- SDL_Surface* convert = SDL_CreateRGBSurface(SDL_SWSURFACE,
- texture_w, texture_h, 32,
- 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff);
-#else
- SDL_Surface* convert = SDL_CreateRGBSurface(SDL_SWSURFACE,
- texture_w, texture_h, 32,
- 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
-#endif
-
- if(convert == 0) {
- SDL_FreeSurface(image);
- throw std::runtime_error("Couldn't create texture: out of memory");
- }