X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2Fapp.cpp;h=6e7201a6f9b2239405255d2413aa0f06dca35007;hb=8ab4ea13545cccbacbd1ed610968d3f481c1b3c8;hp=48a59502ad974dac9d98eed82d49eaaeaa13487b;hpb=9ebe2c320fd9f94266ab93fa2f9d9908a0a284d3;p=blank.git diff --git a/src/app/app.cpp b/src/app/app.cpp index 48a5950..6e7201a 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -9,6 +9,7 @@ #include "init.hpp" #include "../audio/Sound.hpp" #include "../graphics/ArrayTexture.hpp" +#include "../graphics/CubeMap.hpp" #include "../graphics/Font.hpp" #include "../graphics/Texture.hpp" #include "../io/TokenStreamReader.hpp" @@ -270,6 +271,17 @@ void StateControl::Commit(HeadlessApplication &app) { app.PopState(); } break; + case POP_AFTER: + while (app.HasState() && &app.GetState() != m.state) { + app.PopState(); + } + break; + case POP_UNTIL: + while (app.HasState()) { + if (app.PopState() == m.state) { + break; + } + } } } } @@ -363,6 +375,45 @@ void AssetLoader::LoadBlockTypes(const std::string &set_name, BlockTypeRegistry } } +CubeMap AssetLoader::LoadCubeMap(const string &name) const { + string full = textures + name; + string right = full + "-right.png"; + string left = full + "-left.png"; + string top = full + "-top.png"; + string bottom = full + "-bottom.png"; + string back = full + "-back.png"; + string front = full + "-front.png"; + + CubeMap cm; + SDL_Surface *srf; + + if (!(srf = IMG_Load(right.c_str()))) throw SDLError("IMG_Load"); + cm.Data(CubeMap::RIGHT, *srf); + SDL_FreeSurface(srf); + + if (!(srf = IMG_Load(left.c_str()))) throw SDLError("IMG_Load"); + cm.Data(CubeMap::LEFT, *srf); + SDL_FreeSurface(srf); + + if (!(srf = IMG_Load(top.c_str()))) throw SDLError("IMG_Load"); + cm.Data(CubeMap::TOP, *srf); + SDL_FreeSurface(srf); + + if (!(srf = IMG_Load(bottom.c_str()))) throw SDLError("IMG_Load"); + cm.Data(CubeMap::BOTTOM, *srf); + SDL_FreeSurface(srf); + + if (!(srf = IMG_Load(back.c_str()))) throw SDLError("IMG_Load"); + cm.Data(CubeMap::BACK, *srf); + SDL_FreeSurface(srf); + + if (!(srf = IMG_Load(front.c_str()))) throw SDLError("IMG_Load"); + cm.Data(CubeMap::FRONT, *srf); + SDL_FreeSurface(srf); + + return cm; +} + Font AssetLoader::LoadFont(const string &name, int size) const { string full = fonts + name + ".ttf"; return Font(full.c_str(), size);