diff --git a/game/application.cc b/game/application.cc index f1c0884..1043081 100644 --- a/game/application.cc +++ b/game/application.cc @@ -35,7 +35,7 @@ void Application::initLevel() { level.load(); Loader loader = Loader(); - loader.load(levelXmlPath, &level, compositionsPath, scriptPath, geometryPath, texturePath, heightmapPath); + loader.load(levelXmlPath, &level, compositionsPath, scriptPath, geometryPath, texturePath, heightmapPath, &graphics); graphics.init(&level); // just in case: check for errors diff --git a/game/loader.cc b/game/loader.cc index 9b9d897..f18763c 100644 --- a/game/loader.cc +++ b/game/loader.cc @@ -1,4 +1,5 @@ #include "loader.hh" +#include "main.hh" #include using namespace tinyxml2; @@ -57,7 +58,7 @@ void Loader::loadConfig(Application* application) { } void Loader::load(std::string filePath, Level* level, std::string compositionsPath, std::string scriptPath, - std::string globalGeometryPath, std::string globalTexturePath, std::string heightmapPath) { + std::string globalGeometryPath, std::string globalTexturePath, std::string heightmapPath, Graphics* graphics) { struct stat buf; //Loading from xml: XMLDocument* doc = new XMLDocument(); @@ -226,6 +227,13 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa int compositionType = queryInt(composition, "typeID"); //corect composition found if(thisType == compositionType){ + + // update loading screen + glfwPollEvents(); + graphics->render(0.0f); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glfwSwapBuffers(window); + typeExists = true; //iterate over all objects of the composition XMLElement* xmlObject = composition->FirstChildElement("object"); diff --git a/game/loader.hh b/game/loader.hh index f7689e5..478bb06 100644 --- a/game/loader.hh +++ b/game/loader.hh @@ -12,7 +12,7 @@ class Loader { void loadConfig(Application* application); void load(std::string filePath, Level* level, std::string compositionsPath, std::string scriptPath, std::string geometryPath, std::string texturePath, - std::string heightmapPath); + std::string heightmapPath, Graphics* graphics); glm::vec3 reloadPlayerPosition(std::string filePath, Level* level); private: float queryFloat(XMLElement* element, const char* attribute); diff --git a/game/main.cc b/game/main.cc index fa2283a..f472194 100644 --- a/game/main.cc +++ b/game/main.cc @@ -4,6 +4,9 @@ #include #include "keyboardState.hh" +Application app; +GLFWwindow* window; + static void resizeCallback(GLFWwindow* window, int newWidth, int newHeight) { // store the new window size and adjust the viewport: diff --git a/game/main.hh b/game/main.hh index d8ce768..60a8b16 100644 --- a/game/main.hh +++ b/game/main.hh @@ -1,8 +1,6 @@ -#ifndef MAIN_HH_INCLUDED -#define MAIN_HH_INCLUDED +#pragma once #include "application.hh" -Application app; -GLFWwindow* window; -#endif +extern Application app; +extern GLFWwindow* window;