little fix

This commit is contained in:
Anselme 2015-10-13 17:38:49 +02:00
parent fc2e3c5791
commit 124ef6ec2e
2 changed files with 26 additions and 22 deletions

View File

@ -114,7 +114,7 @@ void PhongEntity::crappyInit()
for(int i=0; i<mesh->indiceGroups.size(); ++i) for(int i=0; i<mesh->indiceGroups.size(); ++i)
{ {
PhongMaterial* mat = (PhongMaterial*)(mesh->indiceGroups[i].material); PhongMaterial* mat = (PhongMaterial*)(mesh->indiceGroups[i].material);
mat->crappyBindAttributes(); mat->bindAttributes();
glAssert(glBegin(GL_TRIANGLES)); glAssert(glBegin(GL_TRIANGLES));
for(int j=0; j<mesh->indiceGroups[i].indices.size(); ++j) for(int j=0; j<mesh->indiceGroups[i].indices.size(); ++j)
{ {

View File

@ -1,6 +1,8 @@
#include "phongmaterial.h" #include "phongmaterial.h"
#include "texture.h" #include "texture.h"
#include "phongmodule.h" #include "phongmodule.h"
#include "sparrowrenderer.h"
#include "glassert.h"
#include <glm/ext.hpp> #include <glm/ext.hpp>
#define TEX_ID 0 #define TEX_ID 0
@ -12,6 +14,8 @@ void PhongMaterial::updateShader()
void PhongMaterial::bindAttributes() void PhongMaterial::bindAttributes()
{ {
if(SparrowRenderer::isModernOpenGLAvailable())
{
shader->bind(); shader->bind();
shader->bindVec3(shader->getLocation("materialAmbient"), emission); shader->bindVec3(shader->getLocation("materialAmbient"), emission);
shader->bindVec3(shader->getLocation("materialKd"), diffuse); shader->bindVec3(shader->getLocation("materialKd"), diffuse);
@ -22,21 +26,21 @@ void PhongMaterial::bindAttributes()
diffuse_texture->bind(TEX_ID); diffuse_texture->bind(TEX_ID);
shader->bindInteger(shader->getLocation("baseTexture"), TEX_ID); shader->bindInteger(shader->getLocation("baseTexture"), TEX_ID);
} }
} }
else
void PhongMaterial::crappyBindAttributes() {
{ glAssert(glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, glm::value_ptr(glm::vec4(emission, 1))));
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, glm::value_ptr(glm::vec4(emission, 1))); glAssert(glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, glm::value_ptr(glm::vec4(diffuse, 1))));
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, glm::value_ptr(glm::vec4(diffuse, 1))); glAssert(glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, glm::value_ptr(glm::vec4(specular, 1))));
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, glm::value_ptr(glm::vec4(specular, 1))); glAssert(glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess));
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
if(diffuse_texture != NULL) if(diffuse_texture != NULL)
diffuse_texture->bind(TEX_ID); diffuse_texture->bind(TEX_ID);
else else
{ {
GLenum texSlot = GL_TEXTURE0+TEX_ID; GLenum texSlot = GL_TEXTURE0+TEX_ID;
glActiveTexture(texSlot); glAssert(glActiveTexture(texSlot));
glBindTexture(GL_TEXTURE_2D, 0); glAssert(glBindTexture(GL_TEXTURE_2D, 0));
}
} }
} }