From 7edbcd4d4d9cdfa5e5150041236f6e4839bab53d Mon Sep 17 00:00:00 2001 From: Remco Date: Tue, 21 Jun 2016 23:28:44 +0200 Subject: [PATCH] loadingscreen has been draw when loading a world --- CrystalPoint.vcxproj | 2 ++ CrystalPoint.vcxproj.filters | 6 +++++ LoadingScreen.cpp | 46 ++++++++++++++++++++++++++++++++++++ LoadingScreen.h | 15 ++++++++++++ World.cpp | 1 + World.h | 3 +++ 6 files changed, 73 insertions(+) create mode 100644 LoadingScreen.cpp create mode 100644 LoadingScreen.h diff --git a/CrystalPoint.vcxproj b/CrystalPoint.vcxproj index 7868161..db9c4b3 100644 --- a/CrystalPoint.vcxproj +++ b/CrystalPoint.vcxproj @@ -170,6 +170,7 @@ + @@ -203,6 +204,7 @@ + diff --git a/CrystalPoint.vcxproj.filters b/CrystalPoint.vcxproj.filters index cc3baac..8775746 100644 --- a/CrystalPoint.vcxproj.filters +++ b/CrystalPoint.vcxproj.filters @@ -123,6 +123,9 @@ Source Files + + Source Files + @@ -221,6 +224,9 @@ Header Files + + Header Files + diff --git a/LoadingScreen.cpp b/LoadingScreen.cpp new file mode 100644 index 0000000..eedbb66 --- /dev/null +++ b/LoadingScreen.cpp @@ -0,0 +1,46 @@ +#include "LoadingScreen.h" +#include +#include "CrystalPoint.h" +#include "Util.h" + +LoadingScreen::LoadingScreen() +{ +} + + +LoadingScreen::~LoadingScreen() +{ +} + +void LoadingScreen::draw() +{ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, CrystalPoint::width, CrystalPoint::height, 0, -10, 10); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glDisable(GL_LIGHTING); + glDisable(GL_DEPTH_TEST); + glDisable(GL_TEXTURE_2D); + + + glColor4f(0.0f, 0.0f, 0.0f, 1.0f); + glBegin(GL_QUADS); + glVertex2f(0, 0); + glVertex2f(0, CrystalPoint::height); + glVertex2f(CrystalPoint::width, CrystalPoint::height); + glVertex2f(CrystalPoint::width, 0); + glEnd(); + + glColor4f(1.0f, 1.0f, 0.0f, 1.0f); + + Util::glutBitmapString(loading, + CrystalPoint::width / 2 - Util::glutTextWidth(loading), + CrystalPoint::height / 2 - 7); + + + glEnable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); + glutSwapBuffers(); +} diff --git a/LoadingScreen.h b/LoadingScreen.h new file mode 100644 index 0000000..1bc47cc --- /dev/null +++ b/LoadingScreen.h @@ -0,0 +1,15 @@ +#pragma once +#include + +class LoadingScreen +{ +public: + LoadingScreen(); + ~LoadingScreen(); + + void draw(); + +private: + const std::string loading = "Loading..."; +}; + diff --git a/World.cpp b/World.cpp index 63d8b77..1b0feba 100644 --- a/World.cpp +++ b/World.cpp @@ -10,6 +10,7 @@ World::World(const std::string &fileName) { + ls.draw(); nextworld = false; //Store player instance diff --git a/World.h b/World.h index 9dbebcf..9ec6893 100644 --- a/World.h +++ b/World.h @@ -10,6 +10,7 @@ #include "Skybox.h" #include "CrystalPoint.h" #include "Portal.h" +#include "LoadingScreen.h" class Entity; @@ -32,6 +33,8 @@ private: std::vector entities; std::vector enemies; //std::vector crystals; + + LoadingScreen ls; public: World(const std::string &fileName); ~World();