Merge branch 'developer' into feature/Menu

# Conflicts:
#	CrystalPoint.vcxproj.filters
#	Main.cpp
#	Skybox.cpp
#	Skybox.h
This commit is contained in:
Remco
2016-06-20 15:23:55 +02:00
63 changed files with 31853 additions and 76 deletions
+49
View File
@@ -5,6 +5,7 @@
#include "stb_image.h"
#include "Skybox.h"
#include <string>
#include <iostream>
enum{SKY_LEFT=0,SKY_BACK,SKY_RIGHT,SKY_FRONT,SKY_TOP,SKY_BOTTOM};
GLuint skybox[6];
@@ -13,6 +14,9 @@ Skybox::Skybox(const float &size, const std::string &folder)
{
this->size = size;
this->folder = folder;
brightness = 80;
targetBrightness = 80;
}
Skybox::~Skybox()
@@ -32,6 +36,8 @@ void Skybox::init()
void Skybox::draw()
{
glColor4f(brightness/255, brightness/255, brightness/255, 1);
bool b1 = glIsEnabled(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
@@ -115,3 +121,46 @@ void Skybox::draw()
glDisable(GL_TEXTURE_2D);
}
void Skybox::update(float deltaTime, int curr, int max)
{
targetBrightness = 80 + ((255 - 80) / max) * curr;
if (targetBrightness > brightness + 2)
{
brightness += 20 * deltaTime;
}
if (targetBrightness < brightness - 2)
{
brightness -= 20 * deltaTime;
}
}
GLuint Skybox::loadTexture(const std::string & fileName) //load the filename named texture
{
int width, height, bpp;
stbi_set_flip_vertically_on_load(true);
unsigned char* imgData = stbi_load(fileName.c_str(), &width, &height, &bpp, 4);
GLuint num;
glGenTextures(1, &num);
glBindTexture(GL_TEXTURE_2D, num);
glTexImage2D(GL_TEXTURE_2D,
0, //level
GL_RGBA, //internal format
width, //width
height, //height
0, //border
GL_RGBA, //data format
GL_UNSIGNED_BYTE, //data type
imgData); //data
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
stbi_image_free(imgData);
return num;
}