void OpenGLRenderer::applyMaterial(Material *material, ShaderBinding *localOptions,unsigned int shaderIndex) { if(!material->getShader(shaderIndex) || !shadersEnabled) { setTexture(NULL); return; } FixedShaderBinding *fBinding; switch(material->getShader(shaderIndex)->getType()) { case Shader::FIXED_SHADER: // FixedShader *fShader = (FixedShader*)material->getShader(); fBinding = (FixedShaderBinding*)material->getShaderBinding(shaderIndex); setTexture(fBinding->getDiffuseTexture()); // setTexture(fShader->getDiffuseTexture()); break; case Shader::MODULE_SHADER: currentMaterial = material; if(material->shaderModule == NULL) { for(int m=0; m < shaderModules.size(); m++) { PolycodeShaderModule *shaderModule = shaderModules[m]; if(shaderModule->hasShader(material->getShader(shaderIndex))) { material->shaderModule = (void*)shaderModule; } } } else { PolycodeShaderModule *shaderModule = (PolycodeShaderModule*)material->shaderModule; shaderModule->applyShaderMaterial(this, material, localOptions, shaderIndex); currentShaderModule = shaderModule; } break; } setBlendingMode(material->blendingMode); }
void OpenGLRenderer::applyMaterial(Material *material, ShaderBinding *localOptions,unsigned int shaderIndex) { if(!material->getShader(shaderIndex) || !shadersEnabled) { setTexture(NULL); return; } GLfloat data4[] = {material->diffuseColor.r, material->diffuseColor.g, material->diffuseColor.b, material->diffuseColor.a}; glMaterialfv(GL_FRONT, GL_DIFFUSE, data4); data4[0] = material->specularColor.r; data4[1] = material->specularColor.g; data4[2] = material->specularColor.b; data4[3] = material->specularStrength; glMaterialfv(GL_FRONT, GL_SPECULAR, data4); glMaterialf(GL_FRONT, GL_SHININESS, material->specularValue); data4[0] = ambientColor.r; data4[1] = ambientColor.g; data4[2] = ambientColor.b; data4[3] = 1.0; glMaterialfv(GL_FRONT, GL_AMBIENT, data4); FixedShaderBinding *fBinding; switch(material->getShader(shaderIndex)->getType()) { case Shader::FIXED_SHADER: // FixedShader *fShader = (FixedShader*)material->getShader(); fBinding = (FixedShaderBinding*)material->getShaderBinding(shaderIndex); setTexture(fBinding->getDiffuseTexture()); // setTexture(fShader->getDiffuseTexture()); break; case Shader::MODULE_SHADER: currentMaterial = material; if(material->shaderModule == NULL) { for(int m=0; m < shaderModules.size(); m++) { PolycodeShaderModule *shaderModule = shaderModules[m]; if(shaderModule->hasShader(material->getShader(shaderIndex))) { material->shaderModule = (void*)shaderModule; } } } else { PolycodeShaderModule *shaderModule = (PolycodeShaderModule*)material->shaderModule; shaderModule->applyShaderMaterial(this, material, localOptions, shaderIndex); currentShaderModule = shaderModule; } break; } }
void Renderer::applyMaterial(Material *material, ShaderBinding *localOptions,unsigned int shaderIndex, bool forceMaterial) { if(overrideMaterial) { if(!forceMaterial) { material = overrideMaterial; } } if(!material->getShader(shaderIndex) || !shadersEnabled) { setTexture(NULL); return; } FixedShaderBinding *fBinding; Shader *shader = material->getShader(shaderIndex); if(shader->numPointLights + shader->numSpotLights > 0) { sortLights(); } switch(material->getShader(shaderIndex)->getType()) { case Shader::FIXED_SHADER: fBinding = (FixedShaderBinding*)material->getShaderBinding(shaderIndex); setTexture(fBinding->getDiffuseTexture()); break; case Shader::MODULE_SHADER: currentMaterial = material; if(material->shaderModule == NULL) { for(int m=0; m < shaderModules.size(); m++) { PolycodeShaderModule *shaderModule = shaderModules[m]; if(shaderModule->hasShader(material->getShader(shaderIndex))) { material->shaderModule = (void*)shaderModule; } } } else { PolycodeShaderModule *shaderModule = (PolycodeShaderModule*)material->shaderModule; shaderModule->applyShaderMaterial(this, material, localOptions, shaderIndex); currentShaderModule = shaderModule; } break; } setBlendingMode(material->blendingMode); setWireframePolygonMode(material->wireframe); }