Esempio n. 1
0
        virtual Image* load(const std::string& filename,
                            bool convertToDisplayFormat = true)
        {
            SDL_Surface *loadedSurface = loadSDLSurface(filename);

            if (loadedSurface == NULL)
            {
                throw GCN_EXCEPTION(
                        std::string("Unable to load image file: ") + filename);
            }

            SDL_Surface *surface = convertToStandardFormat(loadedSurface);
            SDL_FreeSurface(loadedSurface);

            if (surface == NULL)
            {
                throw GCN_EXCEPTION(
                        std::string("Not enough memory to load: ") + filename);
            }

            OpenGLImage *image = new OpenGLImage((unsigned int*)surface->pixels,
                                                 surface->w,
                                                 surface->h,
                                                 convertToDisplayFormat);
            SDL_FreeSurface(surface);

            return image;
        }
    Image* GLUTImageLoader::load(const std::string& filename,
                                bool convertToDisplayFormat)
    {
        SDLMOD_Surface *loadedSurface = loadSDLSurface(filename);

        if (loadedSurface == NULL)
        {
            throw GCN_EXCEPTION(
                    std::string("Unable to load image file: ") + filename);
        }

#if 0
        SDLMOD_Surface *surface = convertToStandardFormat(loadedSurface);
        SDLMOD_FreeSurface(loadedSurface);

        if (surface == NULL)
        {
            throw GCN_EXCEPTION(
                    std::string("Not enough memory to load: ") + filename);
        }
#else
		SDLMOD_Surface *surface = loadedSurface;
#endif

        Image *image = new GLUTImage(surface, true);

        if (convertToDisplayFormat)
        {
            image->convertToDisplayFormat();
        }

        return image;
    }
Esempio n. 3
0
void chargeSurface() {
  for (std::vector<std::string>::iterator it = notLoadedSurfVector.begin() ; it != notLoadedSurfVector.end(); ++it) {
    surfMap[(*it)] = loadSDLSurface((*it) + ".png");
    if (!surfMap[(*it)]) { 
      fprintf(stderr, "Couldn't load %s\n", SDL_GetError());
    }  
  }
  notLoadedSurfVector.clear();
}