void COpenGLShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& material, const video::SMaterial& lastMaterial, bool resetAllRenderstates, video::IMaterialRendererServices* services) { if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { #ifdef GL_ARB_vertex_program if (VertexShader) { // set new vertex shader Driver->extGlBindProgram(GL_VERTEX_PROGRAM_ARB, VertexShader); glEnable(GL_VERTEX_PROGRAM_ARB); } #endif // set new pixel shader #ifdef GL_ARB_fragment_program if (PixelShader) { Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader); glEnable(GL_FRAGMENT_PROGRAM_ARB); } #endif if (BaseMaterial) BaseMaterial->OnSetMaterial(material, material, true, services); } //let callback know used material if (CallBack) CallBack->OnSetMaterial(material); for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) Driver->setTexture(i, material.getTexture(i)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); }
void COpenGLShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& material, const video::SMaterial& lastMaterial, bool resetAllRenderstates, video::IMaterialRendererServices* services) { if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { #ifdef GL_ARB_vertex_program if (VertexShader) { // set new vertex shader Driver->extGlBindProgram(GL_VERTEX_PROGRAM_ARB, VertexShader); glEnable(GL_VERTEX_PROGRAM_ARB); } #endif // set new pixel shader #ifdef GL_ARB_fragment_program if (PixelShader[0]) { if (!material.FogEnable) { Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader[0]); } else { GLint curFogMode; glGetIntegerv(GL_FOG_MODE, &curFogMode); // if (Driver->LinearFog && PixelShader[1]) if (curFogMode==GL_LINEAR && PixelShader[1]) Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader[1]); // else if (!Driver->LinearFog && PixelShader[2]) else if (curFogMode==GL_EXP && PixelShader[2]) Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader[2]); else if (curFogMode==GL_EXP2 && PixelShader[3]) Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader[3]); else Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader[0]); } glEnable(GL_FRAGMENT_PROGRAM_ARB); } #endif if (BaseMaterial) BaseMaterial->OnSetMaterial(material, material, true, services); } //let callback know used material if (CallBack) CallBack->OnSetMaterial(material); for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) Driver->setActiveTexture(i, material.getTexture(i)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); }
void COpenGLSLMaterialRenderer::OnSetMaterial(const video::SMaterial& material, const video::SMaterial& lastMaterial, bool resetAllRenderstates, video::IMaterialRendererServices* services) { if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { if(Program) Driver->extGlUseProgramObject(Program); if (BaseMaterial) BaseMaterial->OnSetMaterial(material, material, true, this); } for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) Driver->setTexture(i, material.getTexture(i)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); }