Result fontLoad(void) { fontGB = sfil_load_PNG_file(ROMFS_FOLDER "font_gb.png", SF2D_PLACE_RAM); fontJPGB = sfil_load_PNG_file(ROMFS_FOLDER "font_gb_jp.png", SF2D_PLACE_RAM); return (fontGB && fontJPGB ? 0 : -5); }
const char *imageInit(love_image *self, const char *filename) { int type = getType(filename); if (!loadNoGameGraphics(self, filename)) { if (!fileExists(filename)) { luaError(L, "Could not open image, does not exist"); return NULL; } if (type == 0) { // PNG self->texture = sfil_load_PNG_file(filename, SF2D_PLACE_RAM); } else if (type == 1) { // JPG self->texture = sfil_load_JPEG_file(filename, SF2D_PLACE_RAM); } else if (type == 2) { // BMP self->texture = sfil_load_BMP_file(filename, SF2D_PLACE_RAM); } else if (type == 4) { luaError(L, "Unknown image type"); } } return NULL; }
bool TextureManager::loadTextures() { this->pkmIcons = sfil_load_PNG_file(ROMFS "pokemon_icons_spritesheet.png", SF2D_PLACE_RAM); printf("Loading pkmIcons: @%p\n", this->pkmIcons); if (!this->pkmIcons) return false; this->pkmShinyIcons = sfil_load_PNG_file(ROMFS "pokemon_shiny_icons_spritesheet.png", SF2D_PLACE_RAM); printf("Loading pkmShinyIcons: @%p\n", this->pkmShinyIcons); if (!this->pkmShinyIcons) return false; this->pkmFormIcons = sfil_load_PNG_file(ROMFS "pokemon_form_icons_spritesheet.png", SF2D_PLACE_RAM); printf("Loading pkmFormIcons: @%p\n", this->pkmFormIcons); if (!this->pkmFormIcons) return false; this->pkmShinyFormIcons = sfil_load_PNG_file(ROMFS "pokemon_shiny_form_icons_spritesheet.png", SF2D_PLACE_RAM); printf("Loading pkmShinyFormIcons: @%p\n", this->pkmShinyFormIcons); if (!this->pkmShinyFormIcons) return false; this->itemIcons = sfil_load_PNG_file(ROMFS "item_icons_spritesheet.png", SF2D_PLACE_RAM); printf("Loading itemIcons: @%p\n", this->itemIcons); if (!this->itemIcons) return false; this->ballIcons = sfil_load_PNG_file(ROMFS "ball_icons_spritesheet.png", SF2D_PLACE_RAM); printf("Loading ballIcons: @%p\n", this->ballIcons); if (!this->ballIcons) return false; this->types = sfil_load_PNG_file(ROMFS "types_lang.png", SF2D_PLACE_RAM); printf("Loading types: @%p\n", this->types); if (!this->types) return false; this->boxTiles = sfil_load_PNG_file(ROMFS "box_tiles.png", SF2D_PLACE_RAM); printf("Loading boxTiles: @%p\n", this->boxTiles); if (!this->boxTiles) return false; this->boxBackgrounds = sfil_load_PNG_file(ROMFS "box_backgrounds.png", SF2D_PLACE_RAM); printf("Loading boxBackgrounds: @%p\n", this->boxBackgrounds); if (!this->boxBackgrounds) return false; this->resumeBackground = sfil_load_PNG_file(ROMFS "resume_background.png", SF2D_PLACE_RAM); printf("Loading resumeBackground: @%p\n", this->resumeBackground); if (!this->resumeBackground) return false; return true; }
raw_texture* TextureManager::loadFromFile(const std::string path) { unsigned int extension = getExtension(path); if( extension ) { if( extension == JPEG ) return sfil_load_JPEG_file(path.c_str(), SF2D_PLACE_RAM); else if( extension == PNG ) return sfil_load_PNG_file(path.c_str(), SF2D_PLACE_RAM); else if( extension == BMP ) return sfil_load_BMP_file(path.c_str(), SF2D_PLACE_RAM); } return nullptr; }
/*** Load a texture from a file. Supported formats: PNG, JPEG, BMP, GIF, PSD, TGA, HDR, PIC, PNM. @function load @tparam string path path to the image file @tparam[opt=PLACE_RAM] number place where to put the loaded texture @tparam[opt=auto] number type type of the image. This is only used to force loading PNG, JPEG or BMP files with the sfil library; any value between 5 and 250 will force using the stbi library. Leave nil to autodetect the format. @treturn[1] texture the loaded texture object @treturn[2] nil in case of error @treturn[2] string error message */ static int texture_load(lua_State *L) { const char *path = luaL_checkstring(L, 1); u8 place = luaL_optinteger(L, 2, SF2D_PLACE_RAM); //place in ram by default u8 type = luaL_optinteger(L, 3, 3); //type 3 is "search at the end of the filename" texture_userdata *texture; texture = (texture_userdata *)lua_newuserdata(L, sizeof(*texture)); luaL_getmetatable(L, "LTexture"); lua_setmetatable(L, -2); if (type==3) type = getType(path); if (type==0) { //PNG texture->texture = sfil_load_PNG_file(path, place); } else if (type==1) { //JPEG texture->texture = sfil_load_JPEG_file(path, place); } else if (type==2) { //BMP texture->texture = sfil_load_BMP_file(path, place); //appears to be broken right now. } else { int w, h; char* data = (char*)stbi_load(path, &w, &h, NULL, 4); if (data == NULL) { lua_pushnil(L); lua_pushstring(L, "Can't open file"); return 2; } texture->texture = sf2d_create_texture_mem_RGBA8(data, w, h, TEXFMT_RGBA8, place); free(data); } if (texture->texture == NULL) { lua_pushnil(L); lua_pushstring(L, "No such file"); return 2; } texture->scaleX = 1.0f; texture->scaleY = 1.0f; texture->blendColor = 0xffffffff; return 1; }
const char *imageInit(love_image *self, const char *filename) { int type = getType(filename); if (type == 0) { // PNG self->texture = sfil_load_PNG_file(filename, SF2D_PLACE_RAM); } else if (type == 1) { // JPG self->texture = sfil_load_JPEG_file(filename, SF2D_PLACE_RAM); } else if (type == 2) { // BMP self->texture = sfil_load_BMP_file(filename, SF2D_PLACE_RAM); } return NULL; }
Result TextureManager::load(void) { printf("Loading ballLoadingScreen: @%p\n", (ballLoadingScreen = sfil_load_PNG_file(ROMFS "ball_loading_screen.png", SF2D_PLACE_RAM))); if (!ballLoadingScreen) return -5; drawStaticLoadingScreen(); // s32 prio = 0; // threadMainLoop = true; // svcGetThreadPriority(&prio, CUR_THREAD_HANDLE); // threadCreate(_loadingScreen, (void*) this, 4*1024, prio-1, -2, true); Result ret = (loadTextures() ? 0 : -5); if (R_FAILED(ret)) return ret; sf2d_texture_set_params(this->boxTiles, GPU_TEXTURE_MAG_FILTER(GPU_LINEAR) | GPU_TEXTURE_MIN_FILTER(GPU_LINEAR)); // threadMainLoop = false; return ret; }