From: Peter Schaefer Date: Tue, 21 Apr 2015 21:16:22 +0000 (+0200) Subject: glError moved to Graphix X-Git-Url: https://git.leopard-lacewing.eu/?a=commitdiff_plain;h=ce2e748bb969471377a9962dd042aebdcf2ca175;p=cgue_weave.git glError moved to Graphix added some commented Debugging Messages (info, getGlError) unsigned int bug (-1) fixed 2D and CUBE Textures can be loaded updated Skybox.dae updated Skybox ShaderFiles many securityChecks for bending Variables to Shader --- diff --git a/Weave/Game.cpp b/Weave/Game.cpp index 8269c86..2fab228 100644 --- a/Weave/Game.cpp +++ b/Weave/Game.cpp @@ -35,6 +35,8 @@ using std::string; typedef unsigned int uint; + + Game::Game() : playing(true) { srand((int)time(NULL)); @@ -42,12 +44,30 @@ Game::Game() : playing(true) Scene* tmp_Scene = new Scene(0, 0, Graphix::getWindowWidth(), Graphix::getWindowHeight(), 45, 0.1f, 15, vec3(0.0f, 0.0f, 0.f)); layer[0] = tmp_Scene; + + //SKYBOX! --------------------------- + // tmp_Scene->addObject(new SceneObject(shaderSky, glm::mat4(1.0f), "SkyBox.dae", "skybox.jpg")); + //Message::info("Error from before?"); + //Graphix::getGlError(); + //skybox = new Shader("skybox_VS.hlsl", "skybox_FS.hlsl"); + //Message::info("Creating SkyBox Shader"); + //Graphix::getGlError(); + //SkyBox = new SceneObject(skybox, mat4(1.f), "SkyBox.dae", "skybox_CUBE.jpg"); + //Message::info("Creating SkyBox SceneObject"); rotate((float)M_PI_2, vec3(1.f, 0.f, 0.f)) + //Graphix::getGlError(); + //Message::info("Done"); + + //tmp_Scene->addObject(new SceneObject(shader1, rotate((float)M_PI_2,vec3(1.f,0.f,0.f)), "SkyBox.dae", "skybox.jpg")); + + //tmp_Scene->addObject(SkyBox); + //SKYBOX! ---------------------------- + //Allg Shader Shader* shader1 = new Shader("basicTexture_VS.hlsl", "lightingTexture_FS.hlsl"); - Shader* shaderSky = new Shader("skybox_VS.hlsl", "skybox_FS.hlsl"); +// Shader* shaderSky = new Shader("skybox_VS.hlsl", "skybox_FS.hlsl"); //Player - SceneObject* tmp_playerObject = new SceneObject(shader1, translate(vec3(1.f, 0.f, 1.f)), "Player.dae", "model_player.png"); + SceneObject* tmp_playerObject = new SceneObject(shader1, translate(vec3(1.f, 0.f, 1.f)), "Player.dae", "model_player_2D.png"); //tmp_playerObject->setIntelligenz(new PlayerI(tmp_playerObject)); tmp_Scene->addObject(tmp_playerObject); @@ -83,7 +103,7 @@ Game::Game() : playing(true) // //cout << ((float)(rand() % (size*steps * 2)) / steps - size) << ((float)(rand() % (size*steps * 2)) / steps - size) << ((float)(rand() % (size*steps * 2)) / steps - size) << endl; //} //ein Gegner - tmp_Scene->addObject(new SceneObject(shader1, glm::mat4(1.0f), "Player.dae", "model_player.png")); + //tmp_Scene->addObject(new SceneObject(shader1, glm::mat4(1.0f), "Player.dae", "model_player.png")); //tmp_Scene->addObject(new SceneObject(shader1, translate(vec3(-1.f, 2.f, -2.f)), "../models/box/box.dae", "../Textures/sky_withstars.png")); //tmp_Scene->addObject(new SceneObject(shader1, translate(vec3(1.f, 3.f, -2.f)), "../models/cow/cow.dae", "../models/cow/texture.jpg")); @@ -92,7 +112,8 @@ Game::Game() : playing(true) //import("level_test.dae", tmp_Scene, shader1); - //tmp_Scene->addObject(new SceneObject(shaderSky, glm::mat4(1.0f), "SkyBox.dae", "model_skybox.png")); + + } @@ -130,29 +151,9 @@ void Game::play() Graphix::swap(); - GLenum error = glGetError(); - - if (error != GL_NO_ERROR) { - switch (error) { - case GL_INVALID_ENUM: - Message::error((string)"GL: enum argument out of range."); - break; - case GL_INVALID_VALUE: - Message::error((string)"GL: Numeric argument out of range."); - break; - case GL_INVALID_OPERATION: - Message::error((string)"GL: Operation illegal in current state."); - break; - case GL_INVALID_FRAMEBUFFER_OPERATION: - Message::error((string)"GL: Framebuffer object is not complete."); - break; - case GL_OUT_OF_MEMORY: - Message::error((string)"GL: Not enough memory left to execute command."); - break; - default: - Message::error((string)"GL: Unknown error."); - } - } + Graphix::getGlError(); + +// system("pause"); } } @@ -171,6 +172,10 @@ void Game::update(float deltaT) void Game::draw() const { if (playing){ + + //viewPort->bindView(*i, lookat->getPosition() + vec3(0.0f, 1.0f, 0.0f)); + //SkyBox->draw(); + for (auto i = layer.begin(); i != layer.end(); ++i){ (*i).second->draw(); } diff --git a/Weave/Game.h b/Weave/Game.h index ee6b8c5..ba641f0 100644 --- a/Weave/Game.h +++ b/Weave/Game.h @@ -37,5 +37,8 @@ private: void draw() const; //bool import(const string &path, Scene *scene, Shader* shader); + Shader* skybox; + SceneObject* SkyBox; + }; diff --git a/Weave/Graphix/Graphix.cpp b/Weave/Graphix/Graphix.cpp index b3b2d87..90046a4 100644 --- a/Weave/Graphix/Graphix.cpp +++ b/Weave/Graphix/Graphix.cpp @@ -63,6 +63,7 @@ void Graphix::init() //SDL_SetWindowGrab(sdl_window, SDL_TRUE); //SDL_ShowCursor(SDL_DISABLE); glEnable(GL_COLOR_MATERIAL); + glEnable(GL_TEXTURE_CUBE_MAP); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_CULL_FACE); @@ -100,6 +101,34 @@ void Graphix::cleanup() SDL_Quit(); } +unsigned int Graphix::getGlError() +{ + GLenum error = glGetError(); + + if (error != GL_NO_ERROR) { + switch (error) { + case GL_INVALID_ENUM: + Message::error((string)"GL: enum argument out of range."); + break; + case GL_INVALID_VALUE: + Message::error((string)"GL: Numeric argument out of range."); + break; + case GL_INVALID_OPERATION: + Message::error((string)"GL: Operation illegal in current state."); + break; + case GL_INVALID_FRAMEBUFFER_OPERATION: + Message::error((string)"GL: Framebuffer object is not complete."); + break; + case GL_OUT_OF_MEMORY: + Message::error((string)"GL: Not enough memory left to execute command."); + break; + default: + Message::error((string)"GL: Unknown error."); + } + } + return error; +} + unsigned int Graphix::width = 1024; unsigned int Graphix::height = 768; diff --git a/Weave/Graphix/Graphix.h b/Weave/Graphix/Graphix.h index a1cebb8..38f3e39 100644 --- a/Weave/Graphix/Graphix.h +++ b/Weave/Graphix/Graphix.h @@ -28,6 +28,8 @@ public: static void cleanup(); static void clear(); + static unsigned int getGlError(); + private: static unsigned int width; static unsigned int height; diff --git a/Weave/Graphix/Model.cpp b/Weave/Graphix/Model.cpp index b237e91..c810e59 100644 --- a/Weave/Graphix/Model.cpp +++ b/Weave/Graphix/Model.cpp @@ -9,6 +9,8 @@ #include "Texture.h" #include "../Message.h" +#include "Graphix.h" + typedef unsigned int uint; @@ -109,6 +111,7 @@ Model::~Model() void Model::useModel(Shader* _shader) const { + _shader->useShader(); uint vao = -1; auto i = shader_map.find(*_shader); if (i == shader_map.end()) @@ -117,7 +120,7 @@ void Model::useModel(Shader* _shader) const vao = i->second; glBindVertexArray(vao); - _shader->useShader(); + } @@ -125,24 +128,41 @@ void Model::useTexture(Texture* _texture, Shader* _shader) const { if (_texture != nullptr) { + auto tmp = _shader->getUniformLocation("uColorTexture"); + if (tmp < 0){ + return; + } int unit = 0; _texture->bind(unit); - glUniform1i(_shader->getUniformLocation("uColorTexture"), unit); + glUniform1i(tmp, unit); } } void Model::useMMatrix(const mat4& _model, Shader* _shader) const { - glUniformMatrix4fv(_shader->getUniformLocation("uModel"), 1, GL_FALSE, value_ptr(_model)); + int tmp = _shader->getUniformLocation("uModel"); + if (tmp >= 0) + glUniformMatrix4fv(tmp, 1, GL_FALSE, value_ptr(_model)); } void Model::drawModel(Shader* _shader, Texture* _texture, const mat4& _model) const { + //Message::info("Error from before?"); + //Graphix::getGlError(); useModel(_shader); + //Message::info("Model loading Coordinates"); + //Graphix::getGlError(); useTexture(_texture, _shader); + //Message::info("Model loading Texture"); + //Graphix::getGlError(); useMMatrix(_model, _shader); + //Message::info("Model loading MMatrix"); + //Graphix::getGlError(); glDrawElements(GL_TRIANGLES, numfaces * 3, GL_UNSIGNED_INT, 0); + //Message::info("Model drawing Elements"); + //Graphix::getGlError(); glBindVertexArray(0); + //system("pause"); } void Model::drawModel() const @@ -153,15 +173,29 @@ void Model::drawModel() const unsigned int Model::bindShader(Shader* _shader) { + //Message::info("bindShader"); + //Graphix::getGlError(); + //Message::info("Do Stuff"); uint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao); + //Message::info("bindVAO"); + //Graphix::getGlError(); + bindBuffer(vertexBuffer, _shader->getAttribLocation("aPosition")); + //Message::info("aPosition"); + //Graphix::getGlError(); bindBuffer(uvBuffer, _shader->getAttribLocation("aUV"), 2); + //Message::info("aUV"); + //Graphix::getGlError(); bindBuffer(normalBuffer, _shader->getAttribLocation("aNormal")); + //Message::info("aNormal"); + //Graphix::getGlError(); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); + //Message::info("bindIndexBuffer"); + //Graphix::getGlError(); glBindVertexArray(0); @@ -170,6 +204,10 @@ unsigned int Model::bindShader(Shader* _shader) shader_map[*_shader] = vao; + //Message::info("cleanUp"); + //Graphix::getGlError(); + //Message::info("Done"); + return vao; } @@ -183,6 +221,13 @@ void Model::genBuffer(uint &buffer, uint size, void* value) void Model::bindBuffer(const uint &buffer, const uint index, const uint dim) { + //Falls index nicht gefunden werden konnte + if (index == (uint)-1) + { + Message::info("Model: BindBuffer wird ausgelassen da index fehlerhaft ist."); + return; + } + glBindBuffer(GL_ARRAY_BUFFER, buffer); glEnableVertexAttribArray(index); glVertexAttribPointer(index, dim, GL_FLOAT, GL_FALSE, 0, 0); diff --git a/Weave/Graphix/Scene.cpp b/Weave/Graphix/Scene.cpp index b90e333..684301a 100644 --- a/Weave/Graphix/Scene.cpp +++ b/Weave/Graphix/Scene.cpp @@ -158,20 +158,22 @@ void Scene::draw() const for (auto i = ShaderSet->cbegin(); i != ShaderSet->cend(); ++i) { viewPort->bindView(*i,lookat->getPosition()+vec3(0.0f,1.0f,0.0f)); + + //don't know if this is really the right place to set the lighting + //add ambient light + GLfloat ambientcolor[] = { 0.5f, 0.5f, 0.5f, 1.0f }; + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientcolor); + + //add positioned light + GLfloat lightcolor0[] = { 1.5f, 1.5f, 1.5f, 1.0f }; + GLfloat lightposition0[] = { 1.0f, 1.0f, 1.0f, 1.0f }; + glLightfv(GL_LIGHT0, GL_DIFFUSE, lightcolor0); + glLightfv(GL_LIGHT0, GL_POSITION, lightposition0); } + - //don't know if this is really the right place to set the lighting - //add ambient light - GLfloat ambientcolor[] = { 0.5f, 0.5f, 0.5f, 1.0f }; - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientcolor); - - //add positioned light - GLfloat lightcolor0[] = { 1.5f, 1.5f, 1.5f, 1.0f }; - GLfloat lightposition0[] = { 1.0f, 1.0f, 1.0f, 1.0f }; - glLightfv(GL_LIGHT0, GL_DIFFUSE, lightcolor0); - glLightfv(GL_LIGHT0, GL_POSITION, lightposition0); diff --git a/Weave/Graphix/SceneObject.cpp b/Weave/Graphix/SceneObject.cpp index 43c499d..f14cf34 100644 --- a/Weave/Graphix/SceneObject.cpp +++ b/Weave/Graphix/SceneObject.cpp @@ -12,9 +12,7 @@ #include "Scene.h" #include "Texture.h" -#define MODEL_contractionspeed 8.f -#define MassSpeed_relation 3.f -#define BOX_size 6 +#include "Graphix.h" using std::string; @@ -29,12 +27,22 @@ mainScene(NULL), collision_ignore(false), texture(nullptr) { + //Message::info("Error from befor?"); + //Graphix::getGlError(); new MetaModel(_modelpath); - modelID = _shader->getUniformLocation("model"); + //Message::info("Creating Model"); + //Graphix::getGlError(); + //modelID = _shader->getUniformLocation("model"); if (texturepath!="") texture = new Texture(texturepath); - + //Message::info("Creating SkyBox Shader"); + //Graphix::getGlError(); + bindShader(shader); + //Message::info("Binding Shader"); + //Graphix::getGlError(); + //Message::info("Done"); + } //SceneObject::SceneObject(Shader* _shader, mat4& _model, Model* model_obj, string texturepath) : diff --git a/Weave/Graphix/SceneObject.h b/Weave/Graphix/SceneObject.h index 6f80285..439c0dd 100644 --- a/Weave/Graphix/SceneObject.h +++ b/Weave/Graphix/SceneObject.h @@ -59,8 +59,8 @@ protected: void setMatter(float); mat4 model; - __declspec(deprecated) - unsigned int modelID; + //__declspec(deprecated) + //unsigned int modelID; Shader* shader; diff --git a/Weave/Graphix/Shader.cpp b/Weave/Graphix/Shader.cpp index dff77f4..6caf789 100644 --- a/Weave/Graphix/Shader.cpp +++ b/Weave/Graphix/Shader.cpp @@ -32,7 +32,7 @@ void Shader::useShader() const GLuint Shader::getAttribLocation(const string& name) const { - GLuint ind = glGetAttribLocation(handle, name.c_str()); + int ind = glGetAttribLocation(handle, name.c_str()); if (ind < 0) Message::info("GL_GetAttLoc: Kann '" + name + "' nicht finden."); @@ -41,7 +41,7 @@ GLuint Shader::getAttribLocation(const string& name) const GLuint Shader::getUniformLocation(const string& name) const { - GLuint ind = glGetUniformLocation(handle, name.c_str()); + int ind = glGetUniformLocation(handle, name.c_str()); if (ind < 0) Message::info("GL_GetUniLoc: Kann '" + name + "' nicht finden."); @@ -64,6 +64,7 @@ GLuint Shader::loadShader(string& _shaderPath) GLuint handle=-1; auto type = _shaderPath.substr(_shaderPath.find_last_of('_') + 1); GLenum shaderType; + if (type == "VS.hlsl"){ shaderType = GL_VERTEX_SHADER; } diff --git a/Weave/Graphix/Texture.cpp b/Weave/Graphix/Texture.cpp index 69ba631..788de1f 100644 --- a/Weave/Graphix/Texture.cpp +++ b/Weave/Graphix/Texture.cpp @@ -3,14 +3,18 @@ #include "FreeImage.h" #include -using std::string; -using std::cout; -using std::endl; +#include "../Message.h" +#include "Graphix.h" +using std::string; -Texture::Texture(const string& _path) : path(_path), handle(-1) +Texture::Texture(const string& _path) : path(_path), handle(-1), TEXTURE_TYPE(-1) { + //Message::info("Error from before?"); + //Graphix::getGlError(); + //Message::info("Do some Stuff"); + auto i = texture_map.find(_path); if (i != texture_map.end()) { @@ -20,31 +24,40 @@ Texture::Texture(const string& _path) : path(_path), handle(-1) glGenTextures(1, &handle); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, handle); + auto path_type = path.substr(path.find_last_of("_")+1); + path_type = path_type.substr(0, path_type.find_first_of(".")); + + if (path_type == "CUBE") + { + TEXTURE_TYPE = GL_TEXTURE_CUBE_MAP; + } + else if (path_type == "2D") + { + TEXTURE_TYPE = GL_TEXTURE_2D; + } + else + { + Message::info("Texture : Undefined Type, was set to default (2D)"); + TEXTURE_TYPE = GL_TEXTURE_2D; + } + glBindTexture(TEXTURE_TYPE, handle); FREE_IMAGE_FORMAT format = FreeImage_GetFileType(("../textures/" + path).c_str());//Automatocally detects the format if (format == FIF_UNKNOWN) { - cout << "Couldn't detect texture file format." << endl; - system("pause"); - exit(-1); + Message::error("Texture: Couldn't detect texture file format."); } FIBITMAP* data = FreeImage_Load(format, ("../textures/" + path).c_str()); if (!data) { - cout << "Couldn't read texture file." << endl; - system("pause"); - exit(-1); + Message::error("Texture: Couldn't read texture file."); } //FIBITMAP* temp = data; data = FreeImage_ConvertTo32Bits(data); if (!data) { - cout << "Couldn't convert texture file to bit format." << endl; - system("pause"); - exit(-1); + Message::error("Texture: Couldn't convert texture file to bit format."); } //FreeImage_Unload(temp); @@ -54,14 +67,31 @@ Texture::Texture(const string& _path) : path(_path), handle(-1) //unsigned int width, height; //FIBITMAP *data = FreeImage_Load(FIF_PNG, path.c_str(), PNG_DEFAULT); + //Graphix::getGlError(); +// if (TEXTURE_TYPE == GL_TEXTURE_2D) + { + glTexImage2D(TEXTURE_TYPE, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)FreeImage_GetBits(data)); + //Message::info("TexImage"); + //Graphix::getGlError(); + //Message::info("Other Stuff"); + glGenerateMipmap(TEXTURE_TYPE); + } +// else if (TEXTURE_TYPE == GL_TEXTURE_CUBE_MAP) + - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)FreeImage_GetBits(data)); - glGenerateMipmap(GL_TEXTURE_2D); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(TEXTURE_TYPE, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(TEXTURE_TYPE, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + if (TEXTURE_TYPE == -1) + { + glTexParameteri(TEXTURE_TYPE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(TEXTURE_TYPE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(TEXTURE_TYPE, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + } texture_map[_path] = handle; + //Graphix::getGlError(); + //Message::info("Done"); + } Texture::~Texture() @@ -72,7 +102,7 @@ Texture::~Texture() void Texture::bind(int unit) { glActiveTexture(GL_TEXTURE0 + unit); - glBindTexture(GL_TEXTURE_2D, handle); + glBindTexture(TEXTURE_TYPE, handle); } Texture::operator string() const diff --git a/Weave/Graphix/Texture.h b/Weave/Graphix/Texture.h index 85043e4..36ec0a0 100644 --- a/Weave/Graphix/Texture.h +++ b/Weave/Graphix/Texture.h @@ -24,6 +24,7 @@ public: private: unsigned int handle; string path; + unsigned int TEXTURE_TYPE; static str2int_map texture_map; }; \ No newline at end of file diff --git a/Weave/Graphix/ViewPort.cpp b/Weave/Graphix/ViewPort.cpp index 418c1d8..4598411 100644 --- a/Weave/Graphix/ViewPort.cpp +++ b/Weave/Graphix/ViewPort.cpp @@ -41,8 +41,14 @@ void ViewPort::bindView(Shader* shader) const{ void ViewPort::bindView(Shader* shader, vec3 pos) const{ shader->useShader(); - glUniformMatrix4fv(shader->getUniformLocation("uProjection"), 1, false, value_ptr(projection)); - glUniformMatrix4fv(shader->getUniformLocation("uView"), 1, false, value_ptr(translate(view,-pos))); + int tmp = -1; + + tmp = shader->getUniformLocation("uProjection"); + if (tmp>=0) + glUniformMatrix4fv(tmp, 1, false, value_ptr(projection)); + tmp = shader->getUniformLocation("uView"); + if (tmp >= 0) + glUniformMatrix4fv(tmp, 1, false, value_ptr(translate(view,-pos))); } void ViewPort::rotateView(float angle_x, float angle_y){ diff --git a/Weave/Message.cpp b/Weave/Message.cpp index 1d1d020..dce4bd1 100644 --- a/Weave/Message.cpp +++ b/Weave/Message.cpp @@ -18,7 +18,7 @@ Message::~Message() void Message::error(string _msg) { cerr << currentDateTime() << " E " << _msg << endl; - system("pause"); +// system("pause"); // exit(-1); } diff --git a/models/SkyBox.blend b/models/SkyBox.blend index c549e10..3a63f80 100644 Binary files a/models/SkyBox.blend and b/models/SkyBox.blend differ diff --git a/models/SkyBox.blend1 b/models/SkyBox.blend1 index 55de0ed..c549e10 100644 Binary files a/models/SkyBox.blend1 and b/models/SkyBox.blend1 differ diff --git a/models/SkyBox.dae b/models/SkyBox.dae index a98e098..6b67929 100644 --- a/models/SkyBox.dae +++ b/models/SkyBox.dae @@ -5,8 +5,8 @@ Blender User Blender 2.73.0 commit date:2015-01-20, commit time:18:16, hash:bbf09d9 - 2015-04-16T10:05:45 - 2015-04-16T10:05:45 + 2015-04-21T11:48:56 + 2015-04-21T11:48:56 Z_UP @@ -60,7 +60,7 @@ - 2 0 0 0 0 2 0 0 0 0 2 0 0 0 0 1 + 2 0 0 0 0 -8.74228e-8 -2 0 0 2 -8.74228e-8 0 0 0 0 1 diff --git a/shader/skybox_FS.hlsl b/shader/skybox_FS.hlsl index 1e1c0cc..8198ee8 100644 --- a/shader/skybox_FS.hlsl +++ b/shader/skybox_FS.hlsl @@ -7,4 +7,5 @@ out vec4 FragmentColor; void main(){ FragmentColor = texture(uColorTexture, eyeDirection); + //FragmentColor = vec4(eyeDirection, 0.5); } diff --git a/shader/skybox_VS.hlsl b/shader/skybox_VS.hlsl index 9c2cf3c..a64443d 100644 --- a/shader/skybox_VS.hlsl +++ b/shader/skybox_VS.hlsl @@ -1,18 +1,21 @@ //Vertex Shader #version 330 -in vec3 position; -uniform mat4 projection; -uniform mat4 model; -uniform mat4 view; +in vec3 aPosition; + +uniform mat4 uProjection; +uniform mat4 uModel; +uniform mat4 uView; smooth out vec3 eyeDirection; void main() { - mat4 invProjection = inverse(projection); - mat3 invModelview = mat3(1);// transpose(mat3(model)); - vec3 unprojected = (invProjection * vec4(position, 1)).xyz; + mat4 invProjection = inverse(uProjection); + mat3 invModelview = transpose(mat3(uView)); + vec3 unprojected = (invProjection * vec4(aPosition, 1)).xyz; eyeDirection = invModelview * unprojected; + //eyeDirection = unprojected; + //eyeDirection = aPosition; - gl_Position = vec4(position,1); + gl_Position = vec4(aPosition,1); } \ No newline at end of file diff --git a/textures/model_player.png b/textures/model_player.png deleted file mode 100644 index 19601c1..0000000 Binary files a/textures/model_player.png and /dev/null differ diff --git a/textures/model_player_2D.png b/textures/model_player_2D.png new file mode 100644 index 0000000..19601c1 Binary files /dev/null and b/textures/model_player_2D.png differ diff --git a/textures/model_skybox.png b/textures/model_skybox.png deleted file mode 100644 index beb0696..0000000 Binary files a/textures/model_skybox.png and /dev/null differ diff --git a/textures/model_skybox_CUBE.png b/textures/model_skybox_CUBE.png new file mode 100644 index 0000000..beb0696 Binary files /dev/null and b/textures/model_skybox_CUBE.png differ diff --git a/textures/skybox_CUBE.jpg b/textures/skybox_CUBE.jpg new file mode 100644 index 0000000..dfbc845 Binary files /dev/null and b/textures/skybox_CUBE.jpg differ