bool LoadTextures(SDL_Renderer * renderer) { bool res = true; int i; std::string str; for (i = 0; i < TEXTURES_MAX; i++){ #ifdef WIN32 str = "Textures\\"; #else str = "Textures/"; #endif str+= (const char*)TEXTURES_FILE_NAMES[i]; SDL_Surface * surf = openTexture(str.data()); if (surf == 0){ printf("Loading texture surface %s failed. Error: %s\n", str.data(), SDL_GetError()); SDL_ClearError(); res = false; continue; } if ((textures[i] = SDL_CreateTextureFromSurface(renderer, surf)) == 0){ printf("Creating texture nr. %n from surface failed. Error: %s\n", i, SDL_GetError()); SDL_ClearError(); res = false; continue; } } return res; }
quint8 FieldModelFilePC::load(const QString &hrc, const QString &a, bool animate) { if (hrc.isEmpty() || a.isEmpty()) { return 2; } CharArchive *charLgp = CharArchive::instance(); if (!charLgp->isOpen()) { return 2; } _charLgp = charLgp; QString hrcFilename, aFilename; int index; index = hrc.lastIndexOf('.'); hrcFilename = index > -1 ? hrc.left(index) : hrc; index = a.lastIndexOf('.'); aFilename = index > -1 ? a.left(index) : a; clear(); QMultiMap<int, QStringList> rsdFiles; if (openSkeleton(hrcFilename % ".hrc", rsdFiles)) { QStringList textureFiles; if (openMesh(rsdFiles, textureFiles)) { if (openAnimation(aFilename % ".a", animate)) { // Open all loaded tex int texID = 0; foreach(const QString &texName, textureFiles) { QImage tex = openTexture(texName % ".tex"); if (!tex.isNull()) { _loadedTex.insert(texID, tex); } ++texID; } return true; }