From c5b3f312b3e3b4cdf8d904d105b3f10b41ffa578 Mon Sep 17 00:00:00 2001 From: Anselme Date: Fri, 4 Mar 2016 23:24:17 +0100 Subject: [PATCH] a few fixes --- src/forwardmodule.cpp | 4 ++-- src/framebuffer.cpp | 1 + src/glassert.h | 6 +++--- src/image.h | 2 +- src/light.cpp | 2 +- src/phongmaterial.cpp | 10 +++++----- src/shader.cpp | 2 ++ src/shadersource.cpp | 2 +- src/sparrowrenderer.cpp | 1 + 9 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/forwardmodule.cpp b/src/forwardmodule.cpp index 0cb4c02..54b679d 100644 --- a/src/forwardmodule.cpp +++ b/src/forwardmodule.cpp @@ -80,7 +80,7 @@ void ForwardModule::lightPass(Camera* myCamera, Scene* scene, Light* light) if(light->isShadowCaster()) { light->getShadowMap()->bind(NB_FLAGS); // NB_FLAGS has the value of the first available slot after the phong material texture slots - shader->bindUnsignedInteger(shader->getLocation("shadowMap"), NB_FLAGS); + shader->bindInteger(shader->getLocation("shadowMap"), NB_FLAGS); } break; case Light::POINT: @@ -99,7 +99,7 @@ void ForwardModule::lightPass(Camera* myCamera, Scene* scene, Light* light) geometryIt->isValid(); geometryIt->next()) { GeometryNode* node = geometryIt->getItem(); - shader->bindUnsignedInteger(shader->getLocation("objectId"), id); + shader->bindUnsignedInteger(shader->getLocation("object_identifier"), id); if(node->mesh->hasInstances()) id += node->mesh->instances_offsets.size(); else diff --git a/src/framebuffer.cpp b/src/framebuffer.cpp index 4a2eeb1..a69129f 100644 --- a/src/framebuffer.cpp +++ b/src/framebuffer.cpp @@ -1,6 +1,7 @@ #include "framebuffer.h" #include "texture.h" #include "glassert.h" +#include const FrameBuffer* FrameBuffer::screen = new FrameBuffer(0); diff --git a/src/glassert.h b/src/glassert.h index 442f5dc..acc3181 100644 --- a/src/glassert.h +++ b/src/glassert.h @@ -5,7 +5,7 @@ * OpenGL error management class. */ -#include +#include #include #ifdef RENDER_DEBUG @@ -14,8 +14,8 @@ code; \ {\ GLuint err = glGetError(); \ - if (err != GL_NO_ERROR) { \ - std::cerr<<"Erreur OpenGL ("<<__FILE__<<":"<<__LINE__<<", "<bind(); pmat->alpha_mask->bind(ALPHA_MASK); shaders[1]->bindMat4(shaders[1]->getLocation("MVP"), lightMVP); - shaders[1]->bindUnsignedInteger(shaders[1]->getLocation("alphaMask"), ALPHA_MASK); + shaders[1]->bindInteger(shaders[1]->getLocation("alphaMask"), ALPHA_MASK); node->mesh->draw(shaders[1], false, true, false); } else diff --git a/src/phongmaterial.cpp b/src/phongmaterial.cpp index 90435ad..7b40051 100644 --- a/src/phongmaterial.cpp +++ b/src/phongmaterial.cpp @@ -15,13 +15,13 @@ void PhongMaterial::bindAttributes(Shader* myShader) if(normal_map != NULL) { normal_map->bind(NORMAL_MAP); - myShader->bindUnsignedInteger(myShader->getLocation("normalMap"), NORMAL_MAP); + myShader->bindInteger(myShader->getLocation("normalMap"), NORMAL_MAP); } if(ambient_texture != NULL) { ambient_texture->bind(AMBIENT_TEXTURE); - myShader->bindUnsignedInteger(myShader->getLocation("ambientTexture"), AMBIENT_TEXTURE); + myShader->bindInteger(myShader->getLocation("ambientTexture"), AMBIENT_TEXTURE); } else myShader->bindVec3(myShader->getLocation("materialKa"), ambient); @@ -29,7 +29,7 @@ void PhongMaterial::bindAttributes(Shader* myShader) if(diffuse_texture != NULL) { diffuse_texture->bind(DIFFUSE_TEXTURE); - myShader->bindUnsignedInteger(myShader->getLocation("diffuseTexture"), DIFFUSE_TEXTURE); + myShader->bindInteger(myShader->getLocation("diffuseTexture"), DIFFUSE_TEXTURE); } else myShader->bindVec3(myShader->getLocation("materialKd"), diffuse); @@ -37,7 +37,7 @@ void PhongMaterial::bindAttributes(Shader* myShader) if(specular_texture != NULL) { specular_texture->bind(SPECULAR_TEXTURE); - myShader->bindUnsignedInteger(myShader->getLocation("specularTexture"), SPECULAR_TEXTURE); + myShader->bindInteger(myShader->getLocation("specularTexture"), SPECULAR_TEXTURE); } else myShader->bindVec3(myShader->getLocation("materialKs"), specular); @@ -45,7 +45,7 @@ void PhongMaterial::bindAttributes(Shader* myShader) if(alpha_mask != NULL) { alpha_mask->bind(ALPHA_MASK); - myShader->bindUnsignedInteger(myShader->getLocation("alphaMask"), ALPHA_MASK); + myShader->bindInteger(myShader->getLocation("alphaMask"), ALPHA_MASK); } } else diff --git a/src/shader.cpp b/src/shader.cpp index 197d720..0d2aa2e 100644 --- a/src/shader.cpp +++ b/src/shader.cpp @@ -17,6 +17,8 @@ Shader::Shader(const std::string &vertexSource, const std::string &fragmentSourc glAssert(glBindAttribLocation(program, 0, "inPosition")); glAssert(glBindAttribLocation(program, 1, "inNormal")); glAssert(glBindAttribLocation(program, 2, "inTexCoord")); + glAssert(glBindAttribLocation(program, 3, "inTangent")); + glAssert(glBindAttribLocation(program, 4, "inBinormal")); glAssert(glLinkProgram(program)); diff --git a/src/shadersource.cpp b/src/shadersource.cpp index d4b054f..a60793a 100644 --- a/src/shadersource.cpp +++ b/src/shadersource.cpp @@ -58,7 +58,7 @@ std::string ShaderSource::preprocess(std::string source, int nbDefines, const ch { std::string header = "#version "+std::string(version); for(int i=0; i #include +#include // main methods bool SparrowRenderer::modernOpenglAvailable = false;