Updating loading screen during loading.

This commit is contained in:
Faerbit 2015-04-25 22:29:37 +02:00
parent 96a8943cb7
commit 40dfbf33d9
5 changed files with 17 additions and 8 deletions

View File

@ -35,7 +35,7 @@ void Application::initLevel() {
level.load(); level.load();
Loader loader = Loader(); 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); graphics.init(&level);
// just in case: check for errors // just in case: check for errors

View File

@ -1,4 +1,5 @@
#include "loader.hh" #include "loader.hh"
#include "main.hh"
#include <ACGL/OpenGL/Objects/VertexArrayObject.hh> #include <ACGL/OpenGL/Objects/VertexArrayObject.hh>
using namespace tinyxml2; 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, 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; struct stat buf;
//Loading from xml: //Loading from xml:
XMLDocument* doc = new XMLDocument(); XMLDocument* doc = new XMLDocument();
@ -226,6 +227,13 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
int compositionType = queryInt(composition, "typeID"); int compositionType = queryInt(composition, "typeID");
//corect composition found //corect composition found
if(thisType == compositionType){ if(thisType == compositionType){
// update loading screen
glfwPollEvents();
graphics->render(0.0f);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glfwSwapBuffers(window);
typeExists = true; typeExists = true;
//iterate over all objects of the composition //iterate over all objects of the composition
XMLElement* xmlObject = composition->FirstChildElement("object"); XMLElement* xmlObject = composition->FirstChildElement("object");

View File

@ -12,7 +12,7 @@ class Loader {
void loadConfig(Application* application); void loadConfig(Application* application);
void load(std::string filePath, Level* level, std::string compositionsPath, void load(std::string filePath, Level* level, std::string compositionsPath,
std::string scriptPath, std::string geometryPath, std::string texturePath, 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); glm::vec3 reloadPlayerPosition(std::string filePath, Level* level);
private: private:
float queryFloat(XMLElement* element, const char* attribute); float queryFloat(XMLElement* element, const char* attribute);

View File

@ -4,6 +4,9 @@
#include <sstream> #include <sstream>
#include "keyboardState.hh" #include "keyboardState.hh"
Application app;
GLFWwindow* window;
static void resizeCallback(GLFWwindow* window, int newWidth, int newHeight) static void resizeCallback(GLFWwindow* window, int newWidth, int newHeight)
{ {
// store the new window size and adjust the viewport: // store the new window size and adjust the viewport:

View File

@ -1,8 +1,6 @@
#ifndef MAIN_HH_INCLUDED #pragma once
#define MAIN_HH_INCLUDED
#include "application.hh" #include "application.hh"
Application app; extern Application app;
GLFWwindow* window; extern GLFWwindow* window;
#endif