void createPlayer(void){ player = Player(Point2<float>(20, 20), startingPosition); player.textures[0] = loadPNG("CharacterIdle.png"); player.textures[1] = loadPNG("CharacterLeft.png"); player.textures[2] = loadPNG("CharacterRight.png"); player.setTexture(player.textures[0]); }
my_image *load_image(boost::filesystem::path & aPath, int nbytes, bool for_bmp, bool inverse) { if (aPath.extension().compare(".bmp") == 0) return loadBMP( aPath, nbytes, inverse); if (aPath.extension().compare(".BMP") == 0) return loadBMP( aPath, nbytes, inverse); if (aPath.extension().compare(".jpg") == 0) return loadJPEG( aPath, nbytes, for_bmp, inverse); if (aPath.extension().compare(".JPG") == 0) return loadJPEG( aPath, nbytes, for_bmp, inverse); if (aPath.extension().compare(".thb") == 0) return loadJPEG( aPath, nbytes, for_bmp, inverse); if (aPath.extension().compare(".THB") == 0) return loadJPEG( aPath, nbytes, for_bmp, inverse); if (aPath.extension().compare(".png") == 0) return loadPNG( aPath, nbytes, for_bmp, inverse); if (aPath.extension().compare(".PNG") == 0) return loadPNG( aPath, nbytes, for_bmp, inverse); if (aPath.extension().compare(".tif") == 0) return loadTIFF( aPath, nbytes, for_bmp, inverse); if (aPath.extension().compare(".TIF") == 0) return loadTIFF( aPath, nbytes, for_bmp, inverse); return NULL; }
int load_pixels(const std::string& filename, unsigned char **pixel_buf, img_info_t *img_info) { memset(img_info, 0x0, sizeof(*img_info)); std::string ext = get_file_extension(filename); if (ext == ".jpg" || ext == ".jpeg") { if (!loadJPEG(filename, pixel_buf, img_info)) { fprintf(stderr, "[load_pixels]: fatal error: loading file %s failed.\n", filename.c_str()); return 0; } } else if (ext == ".png") { if(!loadPNG(filename, pixel_buf, img_info)) { fprintf(stderr, "[load_pixels]: fatal error: loading file %s failed.\n", filename.c_str()); return 0; } } else { fprintf(stderr, "[load_pixels]: fatal error: unsupported image file extension \"%s\" (only .png, .jpg, .jpeg are supported)\n", ext.c_str()); return 0; } return 1; }
Texture<GLubyte>::Texture(string const &filename, Filtering filter, bool keepBuffered, Wrapping wrap) : d_filename(filename) { // open file std::ifstream file(filename.c_str()); if(not file.is_open()) throw log(__FILE__, __LINE__, LogType::error, "Failed to open " + filename + " for reading"); // read header png_byte header[8]; file.read(reinterpret_cast<char*>(header), 8); vector<GLubyte> data; NormalizedFormat format = NormalizedFormat::R8; uint width = 0; uint height = 0; if(not png_sig_cmp(header, 0, 8)) data = loadPNG(file, format, width, height); else throw log(__FILE__, __LINE__, LogType::error, filename + " is not a valid .png file"); init(data.data(), filter, format, width, height, keepBuffered, wrap); }
void Texture<GLubyte>::reset() { if(d_filename == "") return; // open file std::ifstream file(d_filename.c_str()); if(not file.is_open()) throw log(__FILE__, __LINE__, LogType::error, "Failed to open " + d_filename + " for reading"); // read header char header[8]; file.read(header, 8); vector<GLubyte> data; NormalizedFormat format = NormalizedFormat::R8; uint width = 0; uint height = 0; if(png_sig_cmp(reinterpret_cast<png_bytep>(header), 0, 8)) data = loadPNG(file, format, width, height); else throw log(__FILE__, __LINE__, LogType::error, d_filename + " is not a valid .png file"); update(data.data()); }
bool Image::load(File* file) { initTable(); _width = 0; _height = 0; _bits = NULL; _flags = 0xFFFFFF; if (file) { bool loaded = false; file->seek(0, SEEK_SET); if (!loaded) loaded = loadGIF(file); file->seek(0, SEEK_SET); if (!loaded) loaded = loadPNG(file); file->seek(0, SEEK_SET); if (!loaded) loaded = loadTGA(file); file->seek(0, SEEK_SET); if (!loaded) loaded = loadBIN(file); file->seek(0, SEEK_SET); if (!loaded) loaded = loadBLP(file); file->seek(0, SEEK_SET); if (!loaded) loaded = loadBLP2(file); if (!loaded) { delete[] _bits; _bits = NULL; _width = 0; _height = 0; _flags = 0; } else updateAlpha(); return loaded; } return false; }
image::image(const vector<uint8_t>& buffer) { auto data = buffer.data(); auto size = buffer.size(); if(0); else if(data[0] == 'B' && data[1] == 'M') loadBMP(data, size); else if(data[1] == 'P' && data[2] == 'N' && data[3] == 'G') loadPNG(data, size); }
// Setup the cubes texture void Cube::setTexture(std::string file){ textureID = loadPNG(file); cords[0] = 0.0f; cords[1] = 0.0f; cords[2] = 0.0f; cords[3] = 1.0f; cords[4] = 1.0f; cords[5] = 1.0f; cords[6] = 1.0f; cords[7] = 0.0f; cords[8] = 0.0f; cords[9] = 0.0f; cords[10] = 0.0f; cords[11] = 1.0f; cords[12] = 1.0f; cords[13] = 1.0f; cords[14] = 1.0f; cords[15] = 0.0f; cords[16] = 0.0f; cords[17] = 0.0f; cords[18] = 0.0f; cords[19] = 1.0f; cords[20] = 1.0f; cords[21] = 1.0f; cords[22] = 1.0f; cords[23] = 0.0f; cords[24] = 0.0f; cords[25] = 0.0f; cords[26] = 0.0f; cords[27] = 1.0f; cords[28] = 1.0f; cords[29] = 1.0f; cords[30] = 1.0f; cords[31] = 0.0f; cords[32] = 0.0f; cords[33] = 0.0f; cords[34] = 0.0f; cords[35] = 1.0f; cords[36] = 1.0f; cords[37] = 1.0f; cords[38] = 1.0f; cords[39] = 0.0f; cords[40] = 0.0f; cords[41] = 0.0f; cords[42] = 0.0f; cords[43] = 1.0f; cords[44] = 1.0f; cords[45] = 1.0f; cords[46] = 1.0f; cords[47] = 0.0f; }
Handle<Value> GLESglTexImage2DFileCallback(const Arguments& args) { if (args.Length() != 1) return v8::Undefined(); //get arguments String::Utf8Value value(args[0]); char* filepath_str = *value; char* filename = V8GLUtils::getRealPath(filepath_str); //take care of relative/absolute paths. Image* img = loadPNG(filename); glTexImage2D(GL_TEXTURE_2D, // target 0, // level GL_RGB, // interal format img->width, img->height, // width, height 0, // border GL_RGB, // format GL_UNSIGNED_BYTE, // type (const void*)img->pixels); delete[] filename; return v8::Undefined(); }
/* Initialize states -- called before */ void init() { if (Testvisible == TRUE) { loadPNG("Test.png", imageWidth, imageHeight, 24); } if (image1visible == TRUE) { loadPNG("1.png", imageWidth, imageHeight, 24); } unsigned char *flippedImage; flippedImage = (unsigned char *)malloc(sizeof (unsigned char)* 3 * 375 * 500); flipImag(image, flippedImage); image = flippedImage; image1visible = FALSE; Testvisible = FALSE; circlevisible = FALSE; squarevisible = FALSE; /* set background clear color to white */ glClearColor(1.0, 1.0, 1.0, 0.0); /* identify the projection matrix that we would like to alter */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); /* the window will correspond to these world coorinates */ gluOrtho2D(-1.0, 1.0, -1.0, 1.0); /* identify the modeling and viewing matrix that can be modified from here on */ /* we leave the routine in this mode in case we want to move the object around */ /* or specify the camera */ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
void createLevel(){ //DEPENDS ON THE LEVEL I GUESS bgColor = WHITE; //FRAME float floorW = 200; float floorH = 20; dimensionsHorizontal = Point2<float>(floorW, floorH); dimensionsVertical = Point2<float>(floorH, floorW); groundTex = loadPNG("death.png"); //groundTex = characterTex; CollidableObject floor = CollidableObject(Point2f(400,20), Point2<float>(100, -100), CollidableObject::PLATFORM); floor.setColour(GREY); obstacles.push_back(floor); CollidableObject floorDEATH = CollidableObject(Point2f(400, 20), Point2<float>(100, -120), CollidableObject::DEADLYPLATFORM); floorDEATH.setColour(BLACK); floorDEATH.setTexture(groundTex); obstacles.push_back(floorDEATH); CollidableObject ceiling = CollidableObject(dimensionsHorizontal, Point2<float>(0, 100), CollidableObject::PLATFORM); ceiling.setColour(GREY); //obstacles.push_back(ceiling); CollidableObject wallLeft = CollidableObject(dimensionsVertical, Point2<float>(-100, 0), CollidableObject::PLATFORM); wallLeft.setColour(GREY); obstacles.push_back(wallLeft); CollidableObject wallRight = CollidableObject(dimensionsVertical, Point2<float>(100, 0), CollidableObject::PLATFORM); wallRight.setColour(GREY); //obstacles.push_back(wallRight); //PLATFORMS CollidableObject platform1 = CollidableObject(Point2f(60, 20), Point2<float>(0, -40), CollidableObject::PLATFORM); platform1.setColour(BLUE); obstacles.push_back(platform1); //PLATFORMS CollidableObject platform2 = CollidableObject(Point2f(60, 20), Point2<float>(100, -20), CollidableObject::PLATFORM); platform2.setColour(BLUE); obstacles.push_back(platform2); CollidableObject platform3 = CollidableObject(Point2f(60, 20), Point2<float>(220,10), CollidableObject::PLATFORM); platform3.setColour(BLUE); obstacles.push_back(platform3); CollidableObject platform4 = CollidableObject(Point2f(60, 20), Point2<float>(120, 70), CollidableObject::PLATFORM); platform4.setColour(GREY); obstacles.push_back(platform4); }
ref<ResourceDatabase> loadResource(VirtualFile* file) const { ref<ResourceDatabase> res_db = new ResourceDatabase; ref<Image> img = loadPNG(file); if (img) res_db->resources().push_back(img); return res_db; }
XL::Texture2D& XL::Texture2D::operator=(const XL::Texture2D copy) { fileName = copy.fileName; id = 0; loadPNG(copy.fileName); return *this; }
void loadPicture(std::string file, GLuint tex){ if(file.find(".png")!=string::npos){ loadPNG(file.c_str(),tex); cout<<"Loaded: "<<file<<endl; } if(file.find(".bmp")==string::npos) return; cout<<"Loading: "<<file<<endl; SDL_Surface *image; SDL_Surface *fixed; image = SDL_LoadBMP(file.c_str()); if(!image){ cerr<<"error loading:"<<file; return; //system("pause"); } fixed=SDL_ConvertSurfaceFormat(image,SDL_PIXELFORMAT_ABGR8888,0); //SDL_SetColorKey(fixed,SDL_TRUE,0xFF00FF); if(!fixed){ cerr<<"error loading:"<<file; return; //system("pause"); } //if(!(is2Pwr(image->w)&&is2Pwr(image->h))) // cerr<<"image is not power of 2 it may load incorrectly"<<endl; // handle error glBindTexture(GL_TEXTURE_2D,tex); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD); //if(alpha) //glTexImage2D( GL_TEXTURE_2D, 0, 4, image->w, image->h, 0,GL_BGRA, GL_UNSIGNED_BYTE, image->pixels ); //else glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, image->w, image->h, 0,GL_RGBA, GL_UNSIGNED_BYTE, fixed->pixels ); if ( image ) { SDL_FreeSurface( image ); } }
// Set up the stucture of this atlas void PlayerAtlas::load(){ // Load texture textureID = loadPNG( std::string("images/AtlasPlayer.png")); VertCordGenerator* vcg = new VertCordGenerator(512,512); // Add Player images to the buffers // Player Run frames vcg->addFrame(1,1,50,50); vcg->addFrame(53,1,50,50); vcg->addFrame(105,1,50,50); vcg->addFrame(157,1,50,50); vcg->addFrame(1,53,50,50); vcg->addFrame(53,53,50,50); vcg->addFrame(105,53,50,50); vcg->addFrame(157,53,50,50); vcg->addFrame(1,105,50,50); vcg->addFrame(53,105,50,50); vcg->addFrame(105,105,50,50); vcg->addFrame(157,105,50,50); // UFO vcg->addFrame(209.0f,1.0f,100.0f,50.0f); // UFO Bear vcg->addFrame(209.0f,52.0f, 100.0f, 50.0f); // Health bar vcg->addFrame(311.0f,1.0f,100.0f,10.0f); // Player arm vcg->addFrame(208.0f, 104.0f, 50.0f,50.0f); // Player Laser Gun vcg->addFrame(311.0f, 13.0f, 21.0f, 17.0f); // Player Laser Gun Muz vcg->addFrame(334.0f, 13.0f, 12.0f, 12.0f); // Player Shotgun vcg->addFrame(311.0f, 32.0f, 34.0f, 17.0f); // Player Shotgun flash vcg->addFrame(348.0f, 13.0f, 18.0f, 12.0f); // Player SMG vcg->addFrame(311.0f, 51.0f, 32.0f, 23.0f); // UFO Ray vcg->addFrame(1.0f, 474.0f,248.0f,37.0f); // UFO Rocket vcg->addFrame(347.0f, 27.0f, 43.0f, 17.0f); // UFO Machine Gun vcg->addFrame(347.0f, 46.0f, 42.0f, 11.0f); // UFO Cowtapult vcg->addFrame(347.0f, 59.0f, 90.0f, 32.0f); // Grab the arrays verts = vcg->getVertices(); cords = vcg->getCoords(); delete vcg; }
ASFont::ASFont(const std::string &fontImagePath) : characters(SFONTPLUS_CHARSET) { surface = loadPNG(fontImagePath); if (!surface) { return; } assert(surface->format->BytesPerPixel == 4); SDL_LockSurface(surface); // Determine character widths. Uint32 pink = SDL_MapRGB(surface->format, 255, 0, 255); Uint32 *topLine = static_cast<Uint32 *>(surface->pixels); const unsigned width = surface->w; unsigned x = 0; unsigned c = 0; while (c < characters.length()) { while (x < width && topLine[x] != pink) x++; unsigned startx = x; x++; while (x < width && topLine[x] == pink) x++; charpos.push_back(startx); charpos.push_back(x); if (c > 0 && utf8Code(characters[c - 1])) { // UTF8 character charpos.push_back(startx); charpos.push_back(x); c++; } c++; } // Scan height of "0" glyph. std::string::size_type pos = characters.find("0") * 2; SDL_Rect srcrect = { charpos[pos], 1, charpos[pos + 2] - charpos[pos], surface->h - 1 }; const unsigned alphaMask = surface->format->Amask; unsigned y = srcrect.h; bool nonTransparentFound = false; while (!nonTransparentFound && y-- > 0) { Uint32 *line = reinterpret_cast<Uint32 *>( reinterpret_cast<Uint8 *>(surface->pixels) + (srcrect.y + y) * surface->pitch ); for (unsigned x = 0; !nonTransparentFound && x < srcrect.w; x++) { nonTransparentFound = (line[srcrect.x + x] & alphaMask) != 0; } } lineHeight = y + 1; SDL_UnlockSurface(surface); }
void Texture::load(DataBuffer *dataBuffer) { char ext[ MAX_CHAR ] = {""}; Utils::getFileName(dataBuffer->getFilename(), this->name); Utils::getFileExtension(dataBuffer->getFilename(), ext, 1); if(!strcmp(ext, "PNG")) loadPNG(dataBuffer); else if(!strcmp(ext, "PVR")) loadPVR(dataBuffer); }
Texture::Texture(const std::string& _file, TextureOptions _options, bool _generateMipmaps) : Texture(0u, 0u, _options, _generateMipmaps) { unsigned int size; unsigned char* data; data = bytesFromFile(_file.c_str(), PathType::resource, &size); loadPNG(data, size); free(data); }
//using namespace lodepng; void RawImage::awake(void){ selfRectTransform = gameObject->rectTransform(); //loadPNG(IntVector2(214, 86), "assets/button_normal.png"); loadPNG(IntVector2(256, 256), "assets/test_blue.png"); drawId = G::instance()->renderer->registerSpriteObject(); RectTransform* rt = gameObject->rectTransform(); G::instance()->renderer->updateSpriteObject(drawId, rt->position, rt->widthHeight); }
GLuint loadCubeMap(const std::string &dirname) { GLuint cubemap; glGenTextures(1, &cubemap); glBindTexture(GL_TEXTURE_CUBE_MAP, cubemap); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); Image_t image_x_positive = loadPNG(std::string(dirname + "/posx.png")); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, // target, level of detail GL_RGBA8, // internal format image_x_positive.width, image_x_positive.height, 0, // width, height, border GL_RGBA, GL_UNSIGNED_BYTE, // external format, type &(image_x_positive.data[0])); // pixels Image_t image_x_negative = loadPNG(std::string(dirname + "/negx.png")); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, // target, level of detail GL_RGBA8, // internal format image_x_negative.width, image_x_negative.height, 0, // width, height, border GL_RGBA, GL_UNSIGNED_BYTE, // external format, type &(image_x_negative.data[0])); // pixels Image_t image_y_positive = loadPNG(std::string(dirname + "/posy.png")); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, // target, level of detail GL_RGBA8, // internal format image_y_positive.width, image_y_positive.height, 0, // width, height, border GL_RGBA, GL_UNSIGNED_BYTE, // external format, type &(image_y_positive.data[0])); // pixels Image_t image_y_negative = loadPNG(std::string(dirname + "/negy.png")); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, // target, level of detail GL_RGBA8, // internal format image_y_negative.width, image_y_negative.height, 0, // width, height, border GL_RGBA, GL_UNSIGNED_BYTE, // external format, type &(image_y_negative.data[0])); // pixels Image_t image_z_positive = loadPNG(std::string(dirname + "/posz.png")); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, // target, level of detail GL_RGBA8, // internal format image_z_positive.width, image_z_positive.height, 0, // width, height, border GL_RGBA, GL_UNSIGNED_BYTE, // external format, type &(image_z_positive.data[0])); // pixels Image_t image_z_negative = loadPNG(std::string(dirname + "/negz.png")); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, // target, level of detail GL_RGBA8, // internal format image_z_negative.width, image_z_negative.height, 0, // width, height, border GL_RGBA, GL_UNSIGNED_BYTE, // external format, type &(image_z_negative.data[0])); // pixels glGenerateMipmap(GL_TEXTURE_CUBE_MAP); glBindTexture(GL_TEXTURE_CUBE_MAP, 0); return cubemap; }
void FileManager::loadImage(const QString &fileName) { QString eName = getExtensionName(fileName); this->name = fileName; if(eName.toLower() == "bmp") { loadBMP(fileName); } else if(eName.toLower() == "png") { loadPNG(fileName); } }
ImagePtr Image::load(std::string file) { ImagePtr image; try { file = g_resources.guessFilePath(file, "png"); // load image file data image = loadPNG(file); } catch(stdext::exception& e) { g_logger.error(stdext::format("unable to load image '%s': %s", file, e.what())); } return image; }
Bitmap::Bitmap(EFileFormat format, Stream *stream) : m_data(NULL) { if (format == EPNG) loadPNG(stream); else if (format == EJPEG) loadJPEG(stream); else if (format == EEXR) loadEXR(stream); else if (format == ETGA) loadTGA(stream); else if (format == EBMP) loadBMP(stream); else Log(EError, "Bitmap: Invalid file format!"); }
Image::Image(const std::string& imagePath, bool flipX, bool flipY) : flipX_(flipX), flipY_(flipY) { std::cout << "Loading image from " << imagePath << " ..."; if (strHasEnding(imagePath, ".png")) loadPNG(imagePath); else if (strHasEnding(imagePath, ".bmp")) loadBMP(imagePath); else throw std::runtime_error("Unrecognized file extension for " + imagePath); std::cout << " done." << std::endl; }
void ePixmap::setPixmapFromFile(const char *filename) { loadPNG(m_pixmap, filename); if (!m_pixmap) { eDebug("ePixmap::setPixmapFromFile: loadPNG failed"); return; } // TODO: This only works for desktop 0 getDesktop(0)->makeCompatiblePixmap(*m_pixmap); event(evtChangedPixmap); }
bool Pixmap::load ( std::istream& stream ) { cleanupData (); // Check for the file type to load char header [ 8 ]; stream.read ( header, 8 ); if ( stream.gcount() != 8 ) return SetError("Invalid file"); if ( !png_sig_cmp ((png_byte*)header, 0, 8) ) return loadPNG ( stream ); else return SetError ( "Unsupported file type" ); }
void initGame(Game* g) { camX = 0; camY = 0; g->floorTex = loadPNG("metal_plates.png"); g->wallTex = loadPNG("wall.png"); g->shotTex = loadPNG("shot.png"); g->playerTex = loadPNG("player1.png"); g->enemyTex = loadPNG("enemy1.png"); g->doorTex = loadPNG("door.png"); g->stairTex = loadPNG("stairs.png"); g->keyTex = loadPNG("key.png"); g->curTileMap = g->tileMaps; getBlankTileMap(g); }
unsigned char* imageIO::openImage(char* filename) { std::string strFilename = std::string(filename); printf("%s", "Opening File: "); printf("%s \n", filename); if (strFilename.substr(strFilename.length() - 4) == ".bmp") { unsigned char* readData = readBMP(filename); return readData; } else if (strFilename.substr(strFilename.length() - 4) == ".png") { std::vector <unsigned char> buffer; loadPNG(filename, buffer); unsigned char* readData = new unsigned char[buffer.size()]; memcpy(readData, buffer.data(), buffer.size()); return readData; } }
RawImage::RawImage(const char *path) throw(ImageException) : _type(GL_RGB), _texId(0), _bytesPerPixel(0), _width(0), _height(0), _pixels(NULL) { const char *filename = basename(const_cast<char *>(path)); if (filename == NULL) throw ImageException("Invalid image filename: %s does not name a file.", filename); const char *ext = strrchr(filename, '.'); if (ext == NULL) throw ImageException("Unknown image format."); FILE *file = fopen(path, "rb"); if (file == NULL) throw ImageException("File not found: %s.", filename); try { if (strcasecmp(ext, ".bmp") == 0) { loadBMP(file); } else if (strcasecmp(ext, ".tga") == 0) { loadTGA(file); } else if (strcasecmp(ext, ".ppm") == 0) { loadPPM(file); } else if (strcasecmp(ext, ".jpg") == 0 || strcasecmp(ext, ".jpeg") == 0) { loadJPG(file); } else if (strcasecmp(ext, ".png") == 0) { loadPNG(file); } else if (strcasecmp(ext, ".tif") == 0 || strcasecmp(ext, ".tiff") == 0) { loadTIFF(path); } else { throw ImageException("Unknown image format: %s", ext); } fclose(file); } catch (ImageException& ex) { fclose(file); if (_pixels != NULL) delete _pixels; throw ex; } }
Texture TextureCache::getTexture(const std::string &filePath) { //lookup the texture if its in our texture map auto mit = _textureMap.find(filePath); //check if it is in the map if (mit == _textureMap.end()) { //fatalError("Texture not Found, loading Texture", ERROR_TYPE::INFO); Texture newTexture = loadPNG(filePath); _textureMap.insert(make_pair(filePath, newTexture)); return newTexture; } //fatalError("Texture found in Cache!", ERROR_TYPE::INFO); return mit->second; }