bool C4LandscapeRenderGL::LoadShaders(C4GroupSet *pGroups) { // First, clear out all existing shaders ClearShaders(); // Make uniform name map ZeroMem(UniformNames, sizeof(UniformNames)); UniformNames[C4LRU_ProjectionMatrix] = "projectionMatrix"; UniformNames[C4LRU_LandscapeTex] = "landscapeTex"; UniformNames[C4LRU_ScalerTex] = "scalerTex"; UniformNames[C4LRU_MaterialTex] = "materialTex"; UniformNames[C4LRU_LightTex] = "lightTex"; UniformNames[C4LRU_AmbientTex] = "ambientTex"; UniformNames[C4LRU_Gamma] = "gamma"; UniformNames[C4LRU_Resolution] = "resolution"; UniformNames[C4LRU_Center] = "center"; UniformNames[C4LRU_MatMapTex] = "matMapTex"; UniformNames[C4LRU_MaterialDepth] = "materialDepth"; UniformNames[C4LRU_MaterialSize] = "materialSize"; UniformNames[C4LRU_AmbientBrightness] = "ambientBrightness"; UniformNames[C4LRU_AmbientTransform] = "ambientTransform"; if(!LoadShader(pGroups, Shader, "landscape", 0)) return false; if(!LoadShader(pGroups, ShaderLight, "landscapeLight", C4SSC_LIGHT)) return false; return true; }
void C4LandscapeRenderGL::Clear() { ClearShaders(); // free textures int i; for (i = 0; i < C4LR_SurfaceCount; i++) { delete Surfaces[i]; Surfaces[i] = NULL; } if (hMaterialTexture) glDeleteTextures(1, &hMaterialTexture); hMaterialTexture = 0; if (matMapTexture) glDeleteTextures(1, &matMapTexture); matMapTexture = 0; if (hVBO != 0) { glDeleteBuffers(1, &hVBO); hVBO = 0; } if (hVAOIDLight != 0) { pGL->FreeVAOID(hVAOIDLight); hVAOIDLight = 0; } if (hVAOIDNoLight != 0) { pGL->FreeVAOID(hVAOIDNoLight); hVAOIDNoLight = 0; } }
void ShaderProgram::Link() { _graphics.LinkProgram(_handler); bool linkSucessfull = CheckShaderProgram(_handler); if (linkSucessfull) { _isLinked = true; ClearShaders(); } }
ShaderManagerVulkan::~ShaderManagerVulkan() { ClearShaders(); delete[] codeBuffer_; }
ShaderProgram::~ShaderProgram() { if (_handler != 0) _graphics.DeleteProgram(_handler); ClearShaders(); }