diff --git a/LoadingScreen.cpp b/LoadingScreen.cpp index 07f5354..5a6521c 100644 --- a/LoadingScreen.cpp +++ b/LoadingScreen.cpp @@ -1,5 +1,7 @@ + +#include "stb_image.h" #include "LoadingScreen.h" -#include + #include "CrystalPoint.h" #include "Util.h" #include @@ -22,20 +24,26 @@ void LoadingScreen::draw() glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glDisable(GL_LIGHTING); + glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); - glDisable(GL_TEXTURE_2D); + glDisable(GL_COLOR_MATERIAL); + glEnable(GL_TEXTURE_2D); - glColor4f(0.0f, 0.0f, 0.0f, 1.0f); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glBindTexture(GL_TEXTURE_2D, textureId); glBegin(GL_QUADS); + glTexCoord2f(0, 1); glVertex2f(0, 0); + glTexCoord2f(0, 0); glVertex2f(0, CrystalPoint::height); + glTexCoord2f(1, 0); glVertex2f(CrystalPoint::width, CrystalPoint::height); - glVertex2f(CrystalPoint::width, 0); + glTexCoord2f(1, 1); + glVertex2f(CrystalPoint::width, 0); glEnd(); - glColor4f(1.0f, 1.0f, 0.0f, 1.0f); + /*glColor4f(1.0f, 1.0f, 0.0f, 1.0f); std::ostringstream oss; @@ -43,9 +51,9 @@ void LoadingScreen::draw() Util::glutBitmapString(oss.str(), CrystalPoint::width / 2 - Util::glutTextWidth(oss.str()), - CrystalPoint::height / 2 - 7); + CrystalPoint::height / 2 - 7);*/ - + glDisable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); glutSwapBuffers(); @@ -56,3 +64,8 @@ void LoadingScreen::rise() points++; draw(); } + +void LoadingScreen::setTexture(const std::string filename) +{ + textureId = Util::loadTexture(filename); +} \ No newline at end of file diff --git a/LoadingScreen.h b/LoadingScreen.h index 4c79718..f24d8c8 100644 --- a/LoadingScreen.h +++ b/LoadingScreen.h @@ -1,5 +1,6 @@ #pragma once #include +#include class LoadingScreen { @@ -11,7 +12,11 @@ public: void rise(); int points; + GLuint textureId; + void setTexture(const std::string fileName); + private: const std::string loading = "Loaded: "; + }; diff --git a/World.cpp b/World.cpp index 4caa231..dca8a1a 100644 --- a/World.cpp +++ b/World.cpp @@ -10,16 +10,18 @@ World::World(const std::string &fileName) { - ls.rise(); + //ls.rise(); + ls.setTexture("loadingScreen_picture.png"); + ls.draw(); nextworld = false; //Store player instance player = Player::getInstance(); - ls.rise(); + //ls.rise(); //Create the interface interface = new Interface(); - ls.rise(); + //ls.rise(); //Open world json file std::ifstream file(fileName); @@ -28,7 +30,7 @@ World::World(const std::string &fileName) json::Value v = json::readJson(file); file.close(); - ls.rise(); + //ls.rise(); //Check file if(v["world"].isNull() || v["world"]["heightmap"].isNull() || v["world"]["skybox"].isNull()) @@ -53,28 +55,28 @@ World::World(const std::string &fileName) cancollide = objt["collision"].asBool(); objecttemplates.push_back(std::pair>(objt["color"], std::pair(objt["file"], cancollide))); - ls.rise(); + //ls.rise(); } //Generate heightmap for this world heightmap = new HeightMap(v["world"]["heightmap"].asString(), this); - ls.rise(); + //ls.rise(); //Load skybox skybox = new Skybox(15000.0f, v["world"]["skybox"].asString()); skybox->init(); - ls.rise(); + //ls.rise(); //Map different texture to heightmap if available if(!v["world"]["texture"].isNull()) heightmap->SetTexture(v["world"]["texture"].asString()); - ls.rise(); + //ls.rise(); //Set player starting position player->position.x = v["player"]["startposition"][0].asFloat(); player->position.z = v["player"]["startposition"][2].asFloat(); player->position.y = heightmap->GetHeight(player->position.x, player->position.z); - ls.rise(); + //ls.rise(); //Load and place objects into world for (auto object : v["objects"]) @@ -107,7 +109,7 @@ World::World(const std::string &fileName) position.y = getHeight(position.x, position.z); entities.push_back(new LevelObject(object["file"].asString(), position, rotation, scale, hasCollision)); - ls.rise(); + //ls.rise(); } maxEnemies = 0; @@ -150,7 +152,7 @@ World::World(const std::string &fileName) maxEnemies++; enemies.push_back(new Enemy(e["file"].asString(), e["music"].asString(), e["damage"].asFloat(), e["health"].asFloat(), position, rotation, scale)); - ls.rise(); + //ls.rise(); } maxCrystals = 0; if (!v["crystal"].isNull()) @@ -194,7 +196,7 @@ World::World(const std::string &fileName) Crystal *c = new Crystal(filled, empty, position, rotation, scale); entities.push_back(c); - ls.rise(); + //ls.rise(); } interface->maxCrystals = maxCrystals; } @@ -204,7 +206,7 @@ World::World(const std::string &fileName) { sound_id = CrystalPoint::GetSoundSystem().LoadSound(v["world"]["music"].asString().c_str(), true); music = CrystalPoint::GetSoundSystem().GetSound(sound_id); - ls.rise(); + //ls.rise(); } if (!v["portal"].isNull()) @@ -230,7 +232,7 @@ World::World(const std::string &fileName) portal = new Portal(v["portal"]["file"], pos, rot, scale); entities.push_back(portal); portal->maxCrystals = maxCrystals; - ls.rise(); + //ls.rise(); } } diff --git a/loadingScreen_picture.png b/loadingScreen_picture.png new file mode 100644 index 0000000..1088762 Binary files /dev/null and b/loadingScreen_picture.png differ