This commit is contained in:
Anselme 2016-03-07 13:07:09 +01:00
commit dbd8ba5dd0
8 changed files with 16 additions and 12 deletions

View File

@ -80,7 +80,7 @@ void ForwardModule::lightPass(Camera* myCamera, Scene* scene, Light* light)
if(light->isShadowCaster()) if(light->isShadowCaster())
{ {
light->getShadowMap()->bind(NB_FLAGS); // NB_FLAGS has the value of the first available slot after the phong material texture slots 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; break;
case Light::POINT: case Light::POINT:
@ -99,7 +99,7 @@ void ForwardModule::lightPass(Camera* myCamera, Scene* scene, Light* light)
geometryIt->isValid(); geometryIt->next()) geometryIt->isValid(); geometryIt->next())
{ {
GeometryNode* node = geometryIt->getItem(); GeometryNode* node = geometryIt->getItem();
shader->bindUnsignedInteger(shader->getLocation("objectId"), id); shader->bindUnsignedInteger(shader->getLocation("object_identifier"), id);
if(node->mesh->hasInstances()) if(node->mesh->hasInstances())
id += node->mesh->instances_offsets.size(); id += node->mesh->instances_offsets.size();
else else

View File

@ -1,6 +1,7 @@
#include "framebuffer.h" #include "framebuffer.h"
#include "texture.h" #include "texture.h"
#include "glassert.h" #include "glassert.h"
#include <iostream>
const FrameBuffer* FrameBuffer::screen = new FrameBuffer(0); const FrameBuffer* FrameBuffer::screen = new FrameBuffer(0);

View File

@ -5,7 +5,7 @@
* OpenGL error management class. * OpenGL error management class.
*/ */
#include <iostream> #include <cstdio>
#include <cassert> #include <cassert>
#ifdef RENDER_DEBUG #ifdef RENDER_DEBUG
@ -14,8 +14,8 @@
code; \ code; \
{\ {\
GLuint err = glGetError(); \ GLuint err = glGetError(); \
if (err != GL_NO_ERROR) { \ if(err != GL_NO_ERROR){ \
std::cerr<<"Erreur OpenGL ("<<__FILE__<<":"<<__LINE__<<", "<<STR(code)<<") : "<<(const char*)gluErrorString (err)<<"("<<err<<")"<<std::endl; \ fprintf(stderr, "OpenGL Error (%s : %d, %s) : %s (%d)\n", __FILE__, __LINE__, STR(code), gluErrorString(err), err);\
} \ } \
} }
#else #else

View File

@ -40,7 +40,7 @@ struct Image
float result = (sum + 1.0f)/ 2.0f; float result = (sum + 1.0f)/ 2.0f;
// Store in texture buffer // Store in texture buffer
data[((row * width + col) * 4) + oct] = data[((row * width + col) * (depth/8)) + oct] =
(unsigned char) ( result * 255.0f ); (unsigned char) ( result * 255.0f );
freq *= 2.0f; // Double the frequency freq *= 2.0f; // Double the frequency
scale *= amplitude; // Next power of b scale *= amplitude; // Next power of b

View File

@ -120,7 +120,7 @@ void Light::generateShadowMap(Scene* scene)
shaders[1]->bind(); shaders[1]->bind();
pmat->alpha_mask->bind(ALPHA_MASK); pmat->alpha_mask->bind(ALPHA_MASK);
shaders[1]->bindMat4(shaders[1]->getLocation("MVP"), lightMVP); 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); node->mesh->draw(shaders[1], false, true, false);
} }
else else

View File

@ -15,13 +15,13 @@ void PhongMaterial::bindAttributes(Shader* myShader)
if(normal_map != NULL) if(normal_map != NULL)
{ {
normal_map->bind(NORMAL_MAP); normal_map->bind(NORMAL_MAP);
myShader->bindUnsignedInteger(myShader->getLocation("normalMap"), NORMAL_MAP); myShader->bindInteger(myShader->getLocation("normalMap"), NORMAL_MAP);
} }
if(ambient_texture != NULL) if(ambient_texture != NULL)
{ {
ambient_texture->bind(AMBIENT_TEXTURE); ambient_texture->bind(AMBIENT_TEXTURE);
myShader->bindUnsignedInteger(myShader->getLocation("ambientTexture"), AMBIENT_TEXTURE); myShader->bindInteger(myShader->getLocation("ambientTexture"), AMBIENT_TEXTURE);
} }
else else
myShader->bindVec3(myShader->getLocation("materialKa"), ambient); myShader->bindVec3(myShader->getLocation("materialKa"), ambient);
@ -29,7 +29,7 @@ void PhongMaterial::bindAttributes(Shader* myShader)
if(diffuse_texture != NULL) if(diffuse_texture != NULL)
{ {
diffuse_texture->bind(DIFFUSE_TEXTURE); diffuse_texture->bind(DIFFUSE_TEXTURE);
myShader->bindUnsignedInteger(myShader->getLocation("diffuseTexture"), DIFFUSE_TEXTURE); myShader->bindInteger(myShader->getLocation("diffuseTexture"), DIFFUSE_TEXTURE);
} }
else else
myShader->bindVec3(myShader->getLocation("materialKd"), diffuse); myShader->bindVec3(myShader->getLocation("materialKd"), diffuse);
@ -37,7 +37,7 @@ void PhongMaterial::bindAttributes(Shader* myShader)
if(specular_texture != NULL) if(specular_texture != NULL)
{ {
specular_texture->bind(SPECULAR_TEXTURE); specular_texture->bind(SPECULAR_TEXTURE);
myShader->bindUnsignedInteger(myShader->getLocation("specularTexture"), SPECULAR_TEXTURE); myShader->bindInteger(myShader->getLocation("specularTexture"), SPECULAR_TEXTURE);
} }
else else
myShader->bindVec3(myShader->getLocation("materialKs"), specular); myShader->bindVec3(myShader->getLocation("materialKs"), specular);
@ -45,7 +45,7 @@ void PhongMaterial::bindAttributes(Shader* myShader)
if(alpha_mask != NULL) if(alpha_mask != NULL)
{ {
alpha_mask->bind(ALPHA_MASK); alpha_mask->bind(ALPHA_MASK);
myShader->bindUnsignedInteger(myShader->getLocation("alphaMask"), ALPHA_MASK); myShader->bindInteger(myShader->getLocation("alphaMask"), ALPHA_MASK);
} }
} }
else else

View File

@ -17,6 +17,8 @@ Shader::Shader(const std::string &vertexSource, const std::string &fragmentSourc
glAssert(glBindAttribLocation(program, 0, "inPosition")); glAssert(glBindAttribLocation(program, 0, "inPosition"));
glAssert(glBindAttribLocation(program, 1, "inNormal")); glAssert(glBindAttribLocation(program, 1, "inNormal"));
glAssert(glBindAttribLocation(program, 2, "inTexCoord")); glAssert(glBindAttribLocation(program, 2, "inTexCoord"));
glAssert(glBindAttribLocation(program, 3, "inTangent"));
glAssert(glBindAttribLocation(program, 4, "inBinormal"));
glAssert(glLinkProgram(program)); glAssert(glLinkProgram(program));

View File

@ -9,6 +9,7 @@
#include "module.h" #include "module.h"
#include <chrono> #include <chrono>
#include <string.h> #include <string.h>
#include <iostream>
// main methods // main methods
bool SparrowRenderer::modernOpenglAvailable = false; bool SparrowRenderer::modernOpenglAvailable = false;