fixed diffuse texture bug, added possibility to disable modules

This commit is contained in:
Anselme 2015-12-10 23:05:47 +01:00
parent 144daa8c3c
commit 89adbf2fc5
6 changed files with 27 additions and 16 deletions

View File

@ -67,9 +67,9 @@ void main(void) {
#endif
#ifdef DIFFUSE_TEXTURE
vec3 diffuse = texture(diffuseTexture, varTexCoord).rgb;
vec3 diffuse = texture(diffuseTexture, varTexCoord).rgb;
#else
vec3 diffuse = materialKd;
vec3 diffuse = materialKd;
#endif
#ifdef SPECULAR_TEXTURE
@ -79,9 +79,9 @@ void main(void) {
#endif
#ifdef AMBIENT_LIGHT
outColor = vec4(diffuse, 1);
outColor = vec4(0, 0, 0, 1);
#else
vec3 light = phongLighting(diffuse, specular, materialNs, lightColor, normal, lightDirInView, halfVecInView);
outColor = vec4(light, 1);
outColor = vec4(light, 1);
#endif
}

View File

@ -49,11 +49,11 @@ void main(void) {
#endif
#ifdef NORMAL_MAP
tangentSpace = transpose(mat3(normalize(normalMatrix*inTangent),
normalize(normalMatrix*inBinormal),
normalize(normalMatrix*inNormal)));
tangentSpace = transpose(mat3(normalize(normalMatrix*inTangent),
normalize(normalMatrix*inBinormal),
normalize(normalMatrix*inNormal)));
#else
varNormal = normalize(normalMatrix*inNormal);
varNormal = normalize(normalMatrix*inNormal);
#endif
varTexCoord = inTexCoord.xy;

View File

@ -9,10 +9,10 @@
const char* const ForwardModule::flagStr[] =
{
"NORMAL_MAP",
"AMBIENT_TEXTURE",
"DIFFUSE_TEXTURE",
"AMBIENT_TEXTURE",
"SPECULAR_TEXTURE",
"NORMAL_MAP",
"ALPHA_MASK"
};

View File

@ -13,10 +13,10 @@ enum {
enum {
// Geometry Flags
NORMAL_MAP_FLAG = 1 << NORMAL_MAP,
AMBIENT_TEXTURE_FLAG = 1 << AMBIENT_TEXTURE,
DIFFUSE_TEXTURE_FLAG = 1 << DIFFUSE_TEXTURE,
AMBIENT_TEXTURE_FLAG = 1 << AMBIENT_TEXTURE,
SPECULAR_TEXTURE_FLAG = 1 << SPECULAR_TEXTURE,
NORMAL_MAP_FLAG = 1 << NORMAL_MAP,
ALPHA_MASK_FLAG = 1 << ALPHA_MASK,
};

View File

@ -34,10 +34,10 @@ void SparrowRenderer::initGL(int width, int height, bool forceCrappy)
fprintf(stderr, "Warning: modern OpenGL not supported!\nEnabling fallback crappy rendering mode\n");
}
std::cout << "OpenGL version " << glGetString(GL_VERSION) << std::endl;
std::cout << "GLSL version " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
std::cout << "gl renderer " << glGetString(GL_RENDERER) << std::endl;
std::cout << "gl vendor " << glGetString(GL_VENDOR) << std::endl;
std::cout << "OpenGL " << glGetString(GL_VERSION) << std::endl;
std::cout << "GLSL " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
std::cout << "Renderer " << glGetString(GL_RENDERER) << std::endl;
std::cout << "Vendor " << glGetString(GL_VENDOR) << std::endl;
glAssert(glEnable(GL_DEPTH_TEST));
glAssert(glEnable(GL_CULL_FACE));
@ -110,6 +110,15 @@ int SparrowRenderer::getNbModules()
return modules.size();
}
void SparrowRenderer::setModuleEnabled(std::string module, bool isEnabled)
{
for(ModuleNode &node : modules)
{
if(node.name.compare(module) == 0)
node.isEnabled = isEnabled;
}
}
// camera methods
void SparrowRenderer::setCamera(Camera* myCamera)

View File

@ -34,6 +34,8 @@ public:
void addModule(Module* myModule, std::string name);
int getNbModules();
void setModuleEnabled(std::string module, bool isEnabled);
// camera methods
void setCamera(Camera* myCamera);
Camera* getCamera();