texture in loadings screen
This commit is contained in:
+21
-8
@@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
|
#include "stb_image.h"
|
||||||
#include "LoadingScreen.h"
|
#include "LoadingScreen.h"
|
||||||
#include <GL\freeglut.h>
|
|
||||||
#include "CrystalPoint.h"
|
#include "CrystalPoint.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
@@ -22,20 +24,26 @@ void LoadingScreen::draw()
|
|||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
glDisable(GL_DEPTH_TEST);
|
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);
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f(0, 1);
|
||||||
glVertex2f(0, 0);
|
glVertex2f(0, 0);
|
||||||
|
glTexCoord2f(0, 0);
|
||||||
glVertex2f(0, CrystalPoint::height);
|
glVertex2f(0, CrystalPoint::height);
|
||||||
|
glTexCoord2f(1, 0);
|
||||||
glVertex2f(CrystalPoint::width, CrystalPoint::height);
|
glVertex2f(CrystalPoint::width, CrystalPoint::height);
|
||||||
glVertex2f(CrystalPoint::width, 0);
|
glTexCoord2f(1, 1);
|
||||||
|
glVertex2f(CrystalPoint::width, 0);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
|
/*glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
|
|
||||||
@@ -43,9 +51,9 @@ void LoadingScreen::draw()
|
|||||||
|
|
||||||
Util::glutBitmapString(oss.str(),
|
Util::glutBitmapString(oss.str(),
|
||||||
CrystalPoint::width / 2 - Util::glutTextWidth(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_LIGHTING);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
@@ -56,3 +64,8 @@ void LoadingScreen::rise()
|
|||||||
points++;
|
points++;
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LoadingScreen::setTexture(const std::string filename)
|
||||||
|
{
|
||||||
|
textureId = Util::loadTexture(filename);
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <GL\freeglut.h>
|
||||||
|
|
||||||
class LoadingScreen
|
class LoadingScreen
|
||||||
{
|
{
|
||||||
@@ -11,7 +12,11 @@ public:
|
|||||||
void rise();
|
void rise();
|
||||||
int points;
|
int points;
|
||||||
|
|
||||||
|
GLuint textureId;
|
||||||
|
void setTexture(const std::string fileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string loading = "Loaded: ";
|
const std::string loading = "Loaded: ";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,16 +10,18 @@
|
|||||||
|
|
||||||
World::World(const std::string &fileName)
|
World::World(const std::string &fileName)
|
||||||
{
|
{
|
||||||
ls.rise();
|
//ls.rise();
|
||||||
|
ls.setTexture("loadingScreen_picture.png");
|
||||||
|
ls.draw();
|
||||||
nextworld = false;
|
nextworld = false;
|
||||||
|
|
||||||
//Store player instance
|
//Store player instance
|
||||||
player = Player::getInstance();
|
player = Player::getInstance();
|
||||||
ls.rise();
|
//ls.rise();
|
||||||
|
|
||||||
//Create the interface
|
//Create the interface
|
||||||
interface = new Interface();
|
interface = new Interface();
|
||||||
ls.rise();
|
//ls.rise();
|
||||||
|
|
||||||
//Open world json file
|
//Open world json file
|
||||||
std::ifstream file(fileName);
|
std::ifstream file(fileName);
|
||||||
@@ -28,7 +30,7 @@ World::World(const std::string &fileName)
|
|||||||
|
|
||||||
json::Value v = json::readJson(file);
|
json::Value v = json::readJson(file);
|
||||||
file.close();
|
file.close();
|
||||||
ls.rise();
|
//ls.rise();
|
||||||
|
|
||||||
//Check file
|
//Check file
|
||||||
if(v["world"].isNull() || v["world"]["heightmap"].isNull() || v["world"]["skybox"].isNull())
|
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();
|
cancollide = objt["collision"].asBool();
|
||||||
|
|
||||||
objecttemplates.push_back(std::pair<int, std::pair<std::string, bool>>(objt["color"], std::pair<std::string, bool>(objt["file"], cancollide)));
|
objecttemplates.push_back(std::pair<int, std::pair<std::string, bool>>(objt["color"], std::pair<std::string, bool>(objt["file"], cancollide)));
|
||||||
ls.rise();
|
//ls.rise();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Generate heightmap for this world
|
//Generate heightmap for this world
|
||||||
heightmap = new HeightMap(v["world"]["heightmap"].asString(), this);
|
heightmap = new HeightMap(v["world"]["heightmap"].asString(), this);
|
||||||
ls.rise();
|
//ls.rise();
|
||||||
|
|
||||||
//Load skybox
|
//Load skybox
|
||||||
skybox = new Skybox(15000.0f, v["world"]["skybox"].asString());
|
skybox = new Skybox(15000.0f, v["world"]["skybox"].asString());
|
||||||
skybox->init();
|
skybox->init();
|
||||||
ls.rise();
|
//ls.rise();
|
||||||
|
|
||||||
//Map different texture to heightmap if available
|
//Map different texture to heightmap if available
|
||||||
if(!v["world"]["texture"].isNull())
|
if(!v["world"]["texture"].isNull())
|
||||||
heightmap->SetTexture(v["world"]["texture"].asString());
|
heightmap->SetTexture(v["world"]["texture"].asString());
|
||||||
ls.rise();
|
//ls.rise();
|
||||||
|
|
||||||
//Set player starting position
|
//Set player starting position
|
||||||
player->position.x = v["player"]["startposition"][0].asFloat();
|
player->position.x = v["player"]["startposition"][0].asFloat();
|
||||||
player->position.z = v["player"]["startposition"][2].asFloat();
|
player->position.z = v["player"]["startposition"][2].asFloat();
|
||||||
player->position.y = heightmap->GetHeight(player->position.x, player->position.z);
|
player->position.y = heightmap->GetHeight(player->position.x, player->position.z);
|
||||||
ls.rise();
|
//ls.rise();
|
||||||
|
|
||||||
//Load and place objects into world
|
//Load and place objects into world
|
||||||
for (auto object : v["objects"])
|
for (auto object : v["objects"])
|
||||||
@@ -107,7 +109,7 @@ World::World(const std::string &fileName)
|
|||||||
position.y = getHeight(position.x, position.z);
|
position.y = getHeight(position.x, position.z);
|
||||||
|
|
||||||
entities.push_back(new LevelObject(object["file"].asString(), position, rotation, scale, hasCollision));
|
entities.push_back(new LevelObject(object["file"].asString(), position, rotation, scale, hasCollision));
|
||||||
ls.rise();
|
//ls.rise();
|
||||||
}
|
}
|
||||||
|
|
||||||
maxEnemies = 0;
|
maxEnemies = 0;
|
||||||
@@ -150,7 +152,7 @@ World::World(const std::string &fileName)
|
|||||||
|
|
||||||
maxEnemies++;
|
maxEnemies++;
|
||||||
enemies.push_back(new Enemy(e["file"].asString(), e["music"].asString(), e["damage"].asFloat(), e["health"].asFloat(), position, rotation, scale));
|
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;
|
maxCrystals = 0;
|
||||||
if (!v["crystal"].isNull())
|
if (!v["crystal"].isNull())
|
||||||
@@ -194,7 +196,7 @@ World::World(const std::string &fileName)
|
|||||||
Crystal *c = new Crystal(filled, empty, position, rotation, scale);
|
Crystal *c = new Crystal(filled, empty, position, rotation, scale);
|
||||||
|
|
||||||
entities.push_back(c);
|
entities.push_back(c);
|
||||||
ls.rise();
|
//ls.rise();
|
||||||
}
|
}
|
||||||
interface->maxCrystals = maxCrystals;
|
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);
|
sound_id = CrystalPoint::GetSoundSystem().LoadSound(v["world"]["music"].asString().c_str(), true);
|
||||||
music = CrystalPoint::GetSoundSystem().GetSound(sound_id);
|
music = CrystalPoint::GetSoundSystem().GetSound(sound_id);
|
||||||
ls.rise();
|
//ls.rise();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!v["portal"].isNull())
|
if (!v["portal"].isNull())
|
||||||
@@ -230,7 +232,7 @@ World::World(const std::string &fileName)
|
|||||||
portal = new Portal(v["portal"]["file"], pos, rot, scale);
|
portal = new Portal(v["portal"]["file"], pos, rot, scale);
|
||||||
entities.push_back(portal);
|
entities.push_back(portal);
|
||||||
portal->maxCrystals = maxCrystals;
|
portal->maxCrystals = maxCrystals;
|
||||||
ls.rise();
|
//ls.rise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 752 KiB |
Reference in New Issue
Block a user