#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"
void HeadlessApplication::Loop(int dt) {
env.counter.EnterFrame();
+ HandleEvents();
+ if (!HasState()) return;
Update(dt);
CommitStates();
if (!HasState()) return;
type.collision = in.GetBool();
} else if (name == "collide_block") {
type.collide_block = in.GetBool();
+ } else if (name == "generate") {
+ type.generate = in.GetBool();
+ } else if (name == "min_solidity") {
+ type.min_solidity = in.GetFloat();
+ } else if (name == "mid_solidity") {
+ type.mid_solidity = in.GetFloat();
+ } else if (name == "max_solidity") {
+ type.max_solidity = in.GetFloat();
+ } else if (name == "min_humidity") {
+ type.min_humidity = in.GetFloat();
+ } else if (name == "mid_humidity") {
+ type.mid_humidity = in.GetFloat();
+ } else if (name == "max_humidity") {
+ type.max_humidity = in.GetFloat();
+ } else if (name == "min_temperature") {
+ type.min_temperature = in.GetFloat();
+ } else if (name == "mid_temperature") {
+ type.mid_temperature = in.GetFloat();
+ } else if (name == "max_temperature") {
+ type.max_temperature = in.GetFloat();
+ } else if (name == "min_richness") {
+ type.min_richness = in.GetFloat();
+ } else if (name == "mid_richness") {
+ type.mid_richness = in.GetFloat();
+ } else if (name == "max_richness") {
+ type.max_richness = in.GetFloat();
+ } else if (name == "commonness") {
+ type.commonness = in.GetFloat();
} else if (name == "shape") {
in.ReadIdentifier(shape_name);
if (shape_name == "block") {
}
}
+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;
+ cm.Bind();
+ SDL_Surface *srf;
+
+ if (!(srf = IMG_Load(right.c_str()))) throw SDLError("IMG_Load");
+ try {
+ cm.Data(CubeMap::RIGHT, *srf);
+ } catch (...) {
+ SDL_FreeSurface(srf);
+ throw;
+ }
+ SDL_FreeSurface(srf);
+
+ if (!(srf = IMG_Load(left.c_str()))) throw SDLError("IMG_Load");
+ try {
+ cm.Data(CubeMap::LEFT, *srf);
+ } catch (...) {
+ SDL_FreeSurface(srf);
+ throw;
+ }
+ SDL_FreeSurface(srf);
+
+ if (!(srf = IMG_Load(top.c_str()))) throw SDLError("IMG_Load");
+ try {
+ cm.Data(CubeMap::TOP, *srf);
+ } catch (...) {
+ SDL_FreeSurface(srf);
+ throw;
+ }
+ SDL_FreeSurface(srf);
+
+ if (!(srf = IMG_Load(bottom.c_str()))) throw SDLError("IMG_Load");
+ try {
+ cm.Data(CubeMap::BOTTOM, *srf);
+ } catch (...) {
+ SDL_FreeSurface(srf);
+ throw;
+ }
+ SDL_FreeSurface(srf);
+
+ if (!(srf = IMG_Load(back.c_str()))) throw SDLError("IMG_Load");
+ try {
+ cm.Data(CubeMap::BACK, *srf);
+ } catch (...) {
+ SDL_FreeSurface(srf);
+ throw;
+ }
+ SDL_FreeSurface(srf);
+
+ if (!(srf = IMG_Load(front.c_str()))) throw SDLError("IMG_Load");
+ try {
+ cm.Data(CubeMap::FRONT, *srf);
+ } catch (...) {
+ SDL_FreeSurface(srf);
+ throw;
+ }
+ SDL_FreeSurface(srf);
+
+ cm.FilterNearest();
+ cm.WrapEdge();
+
+ return cm;
+}
+
Font AssetLoader::LoadFont(const string &name, int size) const {
string full = fonts + name + ".ttf";
return Font(full.c_str(), size);