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())
{
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

View File

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

View File

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

View File

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

View File

@ -120,7 +120,7 @@ void Light::generateShadowMap(Scene* scene)
shaders[1]->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

View File

@ -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

View File

@ -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));

View File

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