[colobot] 289/377: Added rendering modes and shaders to OpenGL 3.3 engine and fixed problem with detecting extensions in core profile

Didier Raboud odyx at moszumanska.debian.org
Wed Mar 30 13:34:28 UTC 2016


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit 0eaf3a9ac4c7dbddcb18df965ef956359a22a9e3
Author: Tomasz Kapuściński <tomaszkax86 at gmail.com>
Date:   Thu Feb 18 00:57:37 2016 +0100

    Added rendering modes and shaders to OpenGL 3.3 engine and fixed problem with detecting extensions in core profile
---
 src/graphics/opengl/gl21device.cpp                 |   9 +-
 src/graphics/opengl/gl21device.h                   |  70 ----
 src/graphics/opengl/gl33device.cpp                 | 397 +++++++++++++++------
 src/graphics/opengl/gl33device.h                   |  89 +----
 src/graphics/opengl/gldevice.cpp                   |   6 +-
 src/graphics/opengl/glutil.cpp                     |  72 +++-
 src/graphics/opengl/glutil.h                       |  72 ++++
 .../shaders/fragment_shader_33_interface.glsl      |  45 +++
 .../shaders/fragment_shader_33_pervertex.glsl      |   2 +-
 .../opengl/shaders/fragment_shader_33_shadow.glsl  |  53 +++
 .../opengl/shaders/vertex_shader_33_interface.glsl |  45 +++
 .../opengl/shaders/vertex_shader_33_pervertex.glsl |   2 +-
 .../opengl/shaders/vertex_shader_33_shadow.glsl    |  43 +++
 13 files changed, 646 insertions(+), 259 deletions(-)

diff --git a/src/graphics/opengl/gl21device.cpp b/src/graphics/opengl/gl21device.cpp
index f68d698..0601678 100644
--- a/src/graphics/opengl/gl21device.cpp
+++ b/src/graphics/opengl/gl21device.cpp
@@ -187,7 +187,11 @@ bool CGL21Device::Create()
         return false;
     }
 
-    GetLogger()->Info("OpenGL %d.%d\n", glMajor, glMinor);
+    const char* version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
+    const char* renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
+
+    GetLogger()->Info("OpenGL %s\n", version);
+    GetLogger()->Info("%s\n", renderer);
 
     // Detect support of anisotropic filtering
     m_anisotropyAvailable = glewIsSupported("GL_EXT_texture_filter_anisotropic");
@@ -273,6 +277,7 @@ bool CGL21Device::Create()
     if (shaders[0] == 0)
     {
         m_errorMessage = GetLastShaderError();
+        GetLogger()->Error("Count not create vertex shader from file '%s'\n", filename);
         return false;
     }
 
@@ -281,7 +286,7 @@ bool CGL21Device::Create()
     if (shaders[1] == 0)
     {
         m_errorMessage = GetLastShaderError();
-        GetLogger()->Error("Count not create vertex shader from file '%s'\n", filename);
+        GetLogger()->Error("Count not create fragment shader from file '%s'\n", filename);
         return false;
     }
 
diff --git a/src/graphics/opengl/gl21device.h b/src/graphics/opengl/gl21device.h
index c436254..d4a0059 100644
--- a/src/graphics/opengl/gl21device.h
+++ b/src/graphics/opengl/gl21device.h
@@ -42,76 +42,6 @@
 namespace Gfx
 {
 
-struct LightLocations
-{
-    //! true enables light
-    GLint enabled = -1;
-    //! Light type
-    GLint type = -1;
-    //! Position or direction vector
-    GLint position = -1;
-    //! Ambient color
-    GLint ambient = -1;
-    //! Diffuse color
-    GLint diffuse = -1;
-    //! Specular color
-    GLint specular = -1;
-    //! Attenuation
-    GLint attenuation = -1;
-};
-
-struct UniformLocations
-{
-    // Uniforms
-    //! Projection matrix
-    GLint projectionMatrix = -1;
-    //! View matrix
-    GLint viewMatrix = -1;
-    //! Model matrix
-    GLint modelMatrix = -1;
-    //! Shadow matrix
-    GLint shadowMatrix = -1;
-    //! Normal matrix
-    GLint normalMatrix = -1;
-
-    //! Primary texture sampler
-    GLint primaryTexture = -1;
-    //! Secondary texture sampler
-    GLint secondaryTexture = -1;
-    //! Shadow texture sampler
-    GLint shadowTexture = -1;
-
-    //! true enables texture
-    GLint textureEnabled[3] = {};
-
-    // Alpha test parameters
-    //! true enables alpha test
-    GLint alphaTestEnabled = -1;
-    //! Alpha test reference value
-    GLint alphaReference = -1;
-
-    //! true enables fog
-    GLint fogEnabled = -1;
-    //! Fog range
-    GLint fogRange = -1;
-    //! Fog color
-    GLint fogColor = -1;
-
-    //! Shadow color
-    GLint shadowColor = -1;
-
-    //! true enables lighting
-    GLint lightingEnabled = -1;
-    //! Ambient color
-    GLint ambientColor = -1;
-    //! Diffuse color
-    GLint diffuseColor = -1;
-    //! Specular color
-    GLint specularColor = -1;
-
-    LightLocations lights[8] = {};
-};
-
 /**
   \class CGL21Device
   \brief Implementation of CDevice interface in OpenGL
diff --git a/src/graphics/opengl/gl33device.cpp b/src/graphics/opengl/gl33device.cpp
index 8d948d0..ed4fe08 100644
--- a/src/graphics/opengl/gl33device.cpp
+++ b/src/graphics/opengl/gl33device.cpp
@@ -194,12 +194,16 @@ bool CGL33Device::Create()
     }
     else
     {
-        GetLogger()->Info("OpenGL %d.%d\n", glMajor, glMinor);
+        const char* version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
+        const char* renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
+
+        GetLogger()->Info("OpenGL %s\n", version);
+        GetLogger()->Info("%s\n", renderer);
     }
 
     // Detect support of anisotropic filtering
-    m_anisotropyAvailable = glewIsSupported("GL_EXT_texture_filter_anisotropic");
-    if(m_anisotropyAvailable)
+    m_anisotropyAvailable = AreExtensionsSupported("GL_EXT_texture_filter_anisotropic");
+    if (m_anisotropyAvailable)
     {
         // Obtain maximum anisotropy level available
         float level;
@@ -242,139 +246,274 @@ bool CGL33Device::Create()
         m_perPixelLighting = value > 0;
     }
 
+    char shading[16];
+
     if (m_perPixelLighting)
+    {
+        strcpy(shading, "perpixel");
         CLogger::GetInstance().Info("Using per-pixel lighting\n");
+    }
     else
+    {
+        strcpy(shading, "pervertex");
         CLogger::GetInstance().Info("Using per-vertex lighting\n");
+    }
 
-    // Create shader program
+    // Create shader program for normal rendering
     GLint shaders[2];
     char filename[64];
 
-    if (m_perPixelLighting)
-        sprintf(filename, "shaders/vertex_shader_33_perpixel.glsl");
-    else
-        sprintf(filename, "shaders/vertex_shader_33_pervertex.glsl");
-
+    sprintf(filename, "shaders/vertex_shader_33_%s.glsl", shading);
     shaders[0] = LoadShader(GL_VERTEX_SHADER, filename);
     if (shaders[0] == 0)
     {
         m_errorMessage = GetLastShaderError();
+        GetLogger()->Error("Count not create vertex shader from file '%s'\n", filename);
         return false;
     }
 
-    if (m_perPixelLighting)
-        sprintf(filename, "shaders/fragment_shader_33_perpixel.glsl");
-    else
-        sprintf(filename, "shaders/fragment_shader_33_pervertex.glsl");
+    sprintf(filename, "shaders/fragment_shader_33_%s.glsl", shading);
+    shaders[1] = LoadShader(GL_FRAGMENT_SHADER, filename);
+    if (shaders[1] == 0)
+    {
+        m_errorMessage = GetLastShaderError();
+        GetLogger()->Error("Count not create fragment shader from file '%s'\n", filename);
+        return false;
+    }
+
+    m_normalProgram = LinkProgram(2, shaders);
+    if (m_normalProgram == 0)
+    {
+        m_errorMessage = GetLastShaderError();
+        GetLogger()->Error("Count not link shader program for normal rendering\n");
+        return false;
+    }
 
+    glDeleteShader(shaders[0]);
+    glDeleteShader(shaders[1]);
+
+    // Create program for interface rendering
+    strcpy(filename, "shaders/vertex_shader_33_interface.glsl");
+    shaders[0] = LoadShader(GL_VERTEX_SHADER, filename);
+    if (shaders[0] == 0)
+    {
+        m_errorMessage = GetLastShaderError();
+        GetLogger()->Error("Count not create vertex shader from file '%s'\n", filename);
+        return false;
+    }
+
+    strcpy(filename, "shaders/fragment_shader_33_interface.glsl");
     shaders[1] = LoadShader(GL_FRAGMENT_SHADER, filename);
     if (shaders[1] == 0)
     {
         m_errorMessage = GetLastShaderError();
+        GetLogger()->Error("Count not create fragment shader from file '%s'\n", filename);
         return false;
     }
 
-    m_shaderProgram = LinkProgram(2, shaders);
-    if (m_shaderProgram == 0)
+    m_interfaceProgram = LinkProgram(2, shaders);
+    if (m_interfaceProgram == 0)
     {
         m_errorMessage = GetLastShaderError();
+        GetLogger()->Error("Count not link shader program for interface rendering\n");
         return false;
     }
 
     glDeleteShader(shaders[0]);
     glDeleteShader(shaders[1]);
 
-    glUseProgram(m_shaderProgram);
+    // Create program for shadow rendering
+    strcpy(filename, "shaders/vertex_shader_33_shadow.glsl");
+    shaders[0] = LoadShader(GL_VERTEX_SHADER, filename);
+    if (shaders[0] == 0)
+    {
+        m_errorMessage = GetLastShaderError();
+        GetLogger()->Error("Count not create vertex shader from file '%s'\n", filename);
+        return false;
+    }
+
+    strcpy(filename, "shaders/fragment_shader_33_shadow.glsl");
+    shaders[1] = LoadShader(GL_FRAGMENT_SHADER, filename);
+    if (shaders[1] == 0)
+    {
+        m_errorMessage = GetLastShaderError();
+        GetLogger()->Error("Count not create fragment shader from file '%s'\n", filename);
+        return false;
+    }
+
+    m_shadowProgram = LinkProgram(2, shaders);
+    if (m_shadowProgram == 0)
+    {
+        m_errorMessage = GetLastShaderError();
+        GetLogger()->Error("Count not link shader program for shadow rendering\n");
+        return false;
+    }
+
+    glDeleteShader(shaders[0]);
+    glDeleteShader(shaders[1]);
 
     // Obtain uniform locations
-    uni_ProjectionMatrix = glGetUniformLocation(m_shaderProgram, "uni_ProjectionMatrix");
-    uni_ViewMatrix = glGetUniformLocation(m_shaderProgram, "uni_ViewMatrix");
-    uni_ModelMatrix = glGetUniformLocation(m_shaderProgram, "uni_ModelMatrix");
-    uni_NormalMatrix = glGetUniformLocation(m_shaderProgram, "uni_NormalMatrix");
-    uni_ShadowMatrix = glGetUniformLocation(m_shaderProgram, "uni_ShadowMatrix");
+    // Obtain uniform locations for normal program
+    glUseProgram(m_normalProgram);
+
+    {
+        UniformLocations &uni = m_uniforms[0];
+
+        uni.projectionMatrix = glGetUniformLocation(m_normalProgram, "uni_ProjectionMatrix");
+        uni.viewMatrix = glGetUniformLocation(m_normalProgram, "uni_ViewMatrix");
+        uni.modelMatrix = glGetUniformLocation(m_normalProgram, "uni_ModelMatrix");
+        uni.normalMatrix = glGetUniformLocation(m_normalProgram, "uni_NormalMatrix");
+        uni.shadowMatrix = glGetUniformLocation(m_normalProgram, "uni_ShadowMatrix");
+
+        uni.primaryTexture = glGetUniformLocation(m_normalProgram, "uni_PrimaryTexture");
+        uni.secondaryTexture = glGetUniformLocation(m_normalProgram, "uni_SecondaryTexture");
+        uni.shadowTexture = glGetUniformLocation(m_normalProgram, "uni_ShadowTexture");
+
+        uni.textureEnabled[0] = glGetUniformLocation(m_normalProgram, "uni_PrimaryTextureEnabled");
+        uni.textureEnabled[1] = glGetUniformLocation(m_normalProgram, "uni_SecondaryTextureEnabled");
+        uni.textureEnabled[2] = glGetUniformLocation(m_normalProgram, "uni_ShadowTextureEnabled");
+
+        uni.fogEnabled = glGetUniformLocation(m_normalProgram, "uni_FogEnabled");
+        uni.fogRange = glGetUniformLocation(m_normalProgram, "uni_FogRange");
+        uni.fogColor = glGetUniformLocation(m_normalProgram, "uni_FogColor");
+
+        uni.alphaTestEnabled = glGetUniformLocation(m_normalProgram, "uni_AlphaTestEnabled");
+        uni.alphaReference = glGetUniformLocation(m_normalProgram, "uni_AlphaReference");
+
+        uni.shadowColor = glGetUniformLocation(m_normalProgram, "uni_ShadowColor");
+
+        uni.lightingEnabled = glGetUniformLocation(m_normalProgram, "uni_LightingEnabled");
+
+        uni.ambientColor = glGetUniformLocation(m_normalProgram, "uni_AmbientColor");
+        uni.diffuseColor = glGetUniformLocation(m_normalProgram, "uni_DiffuseColor");
+        uni.specularColor = glGetUniformLocation(m_normalProgram, "uni_SpecularColor");
+
+        GLchar name[64];
+        for (int i = 0; i < 8; i++)
+        {
+            LightLocations &light = uni.lights[i];
+
+            sprintf(name, "uni_Light[%d].Enabled", i);
+            light.enabled = glGetUniformLocation(m_normalProgram, name);
+
+            sprintf(name, "uni_Light[%d].Position", i);
+            light.position = glGetUniformLocation(m_normalProgram, name);
+
+            sprintf(name, "uni_Light[%d].Ambient", i);
+            light.ambient = glGetUniformLocation(m_normalProgram, name);
+
+            sprintf(name, "uni_Light[%d].Diffuse", i);
+            light.diffuse = glGetUniformLocation(m_normalProgram, name);
+
+            sprintf(name, "uni_Light[%d].Specular", i);
+            light.specular = glGetUniformLocation(m_normalProgram, name);
+
+            sprintf(name, "uni_Light[%d].Attenuation", i);
+            light.attenuation = glGetUniformLocation(m_normalProgram, name);
+        }
+
+        // Set default uniform values
+        Math::Matrix matrix;
+        matrix.LoadIdentity();
 
-    uni_PrimaryTexture = glGetUniformLocation(m_shaderProgram, "uni_PrimaryTexture");
-    uni_SecondaryTexture = glGetUniformLocation(m_shaderProgram, "uni_SecondaryTexture");
-    uni_ShadowTexture = glGetUniformLocation(m_shaderProgram, "uni_ShadowTexture");
+        glUniformMatrix4fv(uni.projectionMatrix, 1, GL_FALSE, matrix.Array());
+        glUniformMatrix4fv(uni.viewMatrix, 1, GL_FALSE, matrix.Array());
+        glUniformMatrix4fv(uni.modelMatrix, 1, GL_FALSE, matrix.Array());
+        glUniformMatrix4fv(uni.normalMatrix, 1, GL_FALSE, matrix.Array());
+        glUniformMatrix4fv(uni.shadowMatrix, 1, GL_FALSE, matrix.Array());
 
-    uni_PrimaryTextureEnabled = glGetUniformLocation(m_shaderProgram, "uni_PrimaryTextureEnabled");
-    uni_SecondaryTextureEnabled = glGetUniformLocation(m_shaderProgram, "uni_SecondaryTextureEnabled");
-    uni_ShadowTextureEnabled = glGetUniformLocation(m_shaderProgram, "uni_ShadowTextureEnabled");
+        glUniform1i(uni.primaryTexture, 0);
+        glUniform1i(uni.secondaryTexture, 1);
+        glUniform1i(uni.shadowTexture, 2);
 
-    uni_FogEnabled = glGetUniformLocation(m_shaderProgram, "uni_FogEnabled");
-    uni_FogRange = glGetUniformLocation(m_shaderProgram, "uni_FogRange");
-    uni_FogColor = glGetUniformLocation(m_shaderProgram, "uni_FogColor");
+        glUniform1i(uni.textureEnabled[0], 0);
+        glUniform1i(uni.textureEnabled[1], 0);
+        glUniform1i(uni.textureEnabled[2], 0);
 
-    uni_AlphaTestEnabled = glGetUniformLocation(m_shaderProgram, "uni_AlphaTestEnabled");
-    uni_AlphaReference = glGetUniformLocation(m_shaderProgram, "uni_AlphaReference");
+        glUniform4f(uni.ambientColor, 0.4f, 0.4f, 0.4f, 1.0f);
+        glUniform4f(uni.diffuseColor, 0.8f, 0.8f, 0.8f, 1.0f);
+        glUniform4f(uni.specularColor, 0.3f, 0.3f, 0.3f, 1.0f);
 
-    uni_ShadowColor = glGetUniformLocation(m_shaderProgram, "uni_ShadowColor");
+        glUniform1i(uni.fogEnabled, 0);
+        glUniform2f(uni.fogRange, 100.0f, 200.0f);
+        glUniform4f(uni.fogColor, 0.8f, 0.8f, 0.8f, 1.0f);
 
-    uni_SmoothShading = glGetUniformLocation(m_shaderProgram, "uni_SmoothShading");
-    uni_LightingEnabled = glGetUniformLocation(m_shaderProgram, "uni_LightingEnabled");
+        glUniform1f(uni.shadowColor, 0.5f);
 
-    uni_AmbientColor = glGetUniformLocation(m_shaderProgram, "uni_AmbientColor");
-    uni_DiffuseColor = glGetUniformLocation(m_shaderProgram, "uni_DiffuseColor");
-    uni_SpecularColor = glGetUniformLocation(m_shaderProgram, "uni_SpecularColor");
+        glUniform1i(uni.alphaTestEnabled, 0);
+        glUniform1f(uni.alphaReference, 1.0f);
+
+        glUniform1i(uni.lightingEnabled, 0);
+
+        for (int i = 0; i < 8; i++)
+            glUniform1i(uni.lights[i].enabled, 0);
+    }
+
+    // Obtain uniform locations for interface program
+    glUseProgram(m_interfaceProgram);
 
-    GLchar name[64];
-    for (int i = 0; i < 8; i++)
     {
-        sprintf(name, "uni_Light[%d].Enabled", i);
-        uni_Light[i].Enabled = glGetUniformLocation(m_shaderProgram, name);
+        UniformLocations &uni = m_uniforms[1];
+
+        uni.projectionMatrix = glGetUniformLocation(m_interfaceProgram, "uni_ProjectionMatrix");
+        uni.viewMatrix = glGetUniformLocation(m_interfaceProgram, "uni_ViewMatrix");
+        uni.modelMatrix = glGetUniformLocation(m_interfaceProgram, "uni_ModelMatrix");
+
+        uni.primaryTexture = glGetUniformLocation(m_interfaceProgram, "uni_Texture");
 
-        sprintf(name, "uni_Light[%d].Position", i);
-        uni_Light[i].Position = glGetUniformLocation(m_shaderProgram, name);
+        uni.textureEnabled[0] = glGetUniformLocation(m_interfaceProgram, "uni_TextureEnabled");
+        uni.textureEnabled[1] = -1;
+        uni.textureEnabled[2] = -1;
 
-        sprintf(name, "uni_Light[%d].Ambient", i);
-        uni_Light[i].Ambient = glGetUniformLocation(m_shaderProgram, name);
+        // Set default uniform values
+        Math::Matrix matrix;
+        matrix.LoadIdentity();
 
-        sprintf(name, "uni_Light[%d].Diffuse", i);
-        uni_Light[i].Diffuse = glGetUniformLocation(m_shaderProgram, name);
+        glUniformMatrix4fv(uni.projectionMatrix, 1, GL_FALSE, matrix.Array());
+        glUniformMatrix4fv(uni.viewMatrix, 1, GL_FALSE, matrix.Array());
+        glUniformMatrix4fv(uni.modelMatrix, 1, GL_FALSE, matrix.Array());
 
-        sprintf(name, "uni_Light[%d].Specular", i);
-        uni_Light[i].Specular = glGetUniformLocation(m_shaderProgram, name);
+        glUniform1i(uni.primaryTexture, 0);
 
-        sprintf(name, "uni_Light[%d].Attenuation", i);
-        uni_Light[i].Attenuation = glGetUniformLocation(m_shaderProgram, name);
+        glUniform1i(uni.textureEnabled[0], 0);
     }
 
-    // Set default uniform values
-    Math::Matrix matrix;
-    matrix.LoadIdentity();
+    // Obtain uniform locations for shadow program
+    glUseProgram(m_shadowProgram);
 
-    glUniformMatrix4fv(uni_ProjectionMatrix, 1, GL_FALSE, matrix.Array());
-    glUniformMatrix4fv(uni_ViewMatrix, 1, GL_FALSE, matrix.Array());
-    glUniformMatrix4fv(uni_ModelMatrix, 1, GL_FALSE, matrix.Array());
-    glUniformMatrix4fv(uni_NormalMatrix, 1, GL_FALSE, matrix.Array());
-    glUniformMatrix4fv(uni_ShadowMatrix, 1, GL_FALSE, matrix.Array());
+    {
+        UniformLocations &uni = m_uniforms[2];
+
+        uni.projectionMatrix = glGetUniformLocation(m_shadowProgram, "uni_ProjectionMatrix");
+        uni.viewMatrix = glGetUniformLocation(m_shadowProgram, "uni_ViewMatrix");
+        uni.modelMatrix = glGetUniformLocation(m_shadowProgram, "uni_ModelMatrix");
+
+        uni.primaryTexture = glGetUniformLocation(m_shadowProgram, "uni_Texture");
 
-    glUniform1i(uni_PrimaryTexture, 0);
-    glUniform1i(uni_SecondaryTexture, 1);
-    glUniform1i(uni_ShadowTexture, 2);
+        uni.textureEnabled[0] = glGetUniformLocation(m_shadowProgram, "uni_TextureEnabled");
+        uni.textureEnabled[1] = -1;
+        uni.textureEnabled[2] = -1;
 
-    glUniform1i(uni_PrimaryTextureEnabled, 0);
-    glUniform1i(uni_SecondaryTextureEnabled, 0);
-    glUniform1i(uni_ShadowTextureEnabled, 0);
+        uni.alphaTestEnabled = glGetUniformLocation(m_shadowProgram, "uni_AlphaTestEnabled");
+        uni.alphaReference = glGetUniformLocation(m_shadowProgram, "uni_AlphaReference");
 
-    glUniform4f(uni_AmbientColor, 0.4f, 0.4f, 0.4f, 1.0f);
-    glUniform4f(uni_DiffuseColor, 0.8f, 0.8f, 0.8f, 1.0f);
-    glUniform4f(uni_SpecularColor, 0.3f, 0.3f, 0.3f, 1.0f);
+        // Set default uniform values
+        Math::Matrix matrix;
+        matrix.LoadIdentity();
 
-    glUniform1i(uni_FogEnabled, 0);
-    glUniform2f(uni_FogRange, 100.0f, 200.0f);
-    glUniform4f(uni_FogColor, 0.8f, 0.8f, 0.8f, 1.0f);
+        glUniformMatrix4fv(uni.projectionMatrix, 1, GL_FALSE, matrix.Array());
+        glUniformMatrix4fv(uni.viewMatrix, 1, GL_FALSE, matrix.Array());
+        glUniformMatrix4fv(uni.modelMatrix, 1, GL_FALSE, matrix.Array());
 
-    glUniform1f(uni_ShadowColor, 0.5f);
+        glUniform1i(uni.primaryTexture, 0);
 
-    glUniform1i(uni_AlphaTestEnabled, 0);
-    glUniform1f(uni_AlphaReference, 1.0f);
+        glUniform1i(uni.textureEnabled[0], 0);
 
-    glUniform1i(uni_LightingEnabled, 0);
+        glUniform1i(uni.alphaTestEnabled, 0);
+        glUniform1f(uni.alphaReference, 1.0f);
+    }
 
-    for (int i = 0; i < 8; i++)
-        glUniform1i(uni_Light[i].Enabled, 0);
+    SetRenderMode(RENDER_MODE_NORMAL);
 
     // create default framebuffer object
     FramebufferParams framebufferParams;
@@ -395,6 +534,8 @@ bool CGL33Device::Create()
     glBufferData(GL_ARRAY_BUFFER, m_bufferSize, nullptr, GL_STREAM_DRAW);
     glBindBuffer(GL_ARRAY_BUFFER, 0);
 
+    m_vboMemory += m_bufferSize;
+
     GetLogger()->Info("CDevice created successfully\n");
 
     return true;
@@ -404,7 +545,9 @@ void CGL33Device::Destroy()
 {
     // delete shader program
     glUseProgram(0);
-    glDeleteProgram(m_shaderProgram);
+    glDeleteProgram(m_normalProgram);
+    glDeleteProgram(m_interfaceProgram);
+    glDeleteProgram(m_shadowProgram);
 
     // delete framebuffers
     for (auto& framebuffer : m_framebuffers)
@@ -420,6 +563,8 @@ void CGL33Device::Destroy()
     glDeleteVertexArrays(1, &m_auxiliaryVAO);
     glDeleteBuffers(1, &m_buffer);
 
+    m_vboMemory -= m_bufferSize;
+
     m_lights.clear();
     m_lightsEnabled.clear();
 
@@ -451,9 +596,9 @@ void CGL33Device::BeginScene()
 {
     Clear();
 
-    glUniformMatrix4fv(uni_ProjectionMatrix, 1, GL_FALSE, m_projectionMat.Array());
-    glUniformMatrix4fv(uni_ViewMatrix, 1, GL_FALSE, m_viewMat.Array());
-    glUniformMatrix4fv(uni_ModelMatrix, 1, GL_FALSE, m_worldMat.Array());
+    glUniformMatrix4fv(m_uni->projectionMatrix, 1, GL_FALSE, m_projectionMat.Array());
+    glUniformMatrix4fv(m_uni->viewMatrix, 1, GL_FALSE, m_viewMat.Array());
+    glUniformMatrix4fv(m_uni->modelMatrix, 1, GL_FALSE, m_worldMat.Array());
 }
 
 void CGL33Device::EndScene()
@@ -468,7 +613,28 @@ void CGL33Device::Clear()
 
 void CGL33Device::SetRenderMode(RenderMode mode)
 {
-    // TODO: implement
+    switch (mode)
+    {
+    case RENDER_MODE_NORMAL:
+        glUseProgram(m_normalProgram);
+        m_mode = 0;
+        break;
+    case RENDER_MODE_INTERFACE:
+        glUseProgram(m_interfaceProgram);
+        m_mode = 1;
+        break;
+    case RENDER_MODE_SHADOW:
+        glUseProgram(m_shadowProgram);
+        m_mode = 2;
+        break;
+    default:
+        assert(false);
+        return;
+    }
+
+    m_uni = &m_uniforms[m_mode];
+
+    UpdateRenderingMode();
 }
 
 void CGL33Device::SetTransform(TransformType type, const Math::Matrix &matrix)
@@ -476,7 +642,7 @@ void CGL33Device::SetTransform(TransformType type, const Math::Matrix &matrix)
     if      (type == TRANSFORM_WORLD)
     {
         m_worldMat = matrix;
-        glUniformMatrix4fv(uni_ModelMatrix, 1, GL_FALSE, m_worldMat.Array());
+        glUniformMatrix4fv(m_uni->modelMatrix, 1, GL_FALSE, m_worldMat.Array());
 
         m_modelviewMat = Math::MultiplyMatrices(m_viewMat, m_worldMat);
         m_combinedMatrix = Math::MultiplyMatrices(m_projectionMat, m_modelviewMat);
@@ -487,7 +653,7 @@ void CGL33Device::SetTransform(TransformType type, const Math::Matrix &matrix)
         if (fabs(normalMat.Det()) > 1e-6)
             normalMat = normalMat.Inverse();
 
-        glUniformMatrix4fv(uni_NormalMatrix, 1, GL_TRUE, normalMat.Array());
+        glUniformMatrix4fv(m_uni->normalMatrix, 1, GL_TRUE, normalMat.Array());
     }
     else if (type == TRANSFORM_VIEW)
     {
@@ -498,7 +664,7 @@ void CGL33Device::SetTransform(TransformType type, const Math::Matrix &matrix)
         m_modelviewMat = Math::MultiplyMatrices(m_viewMat, m_worldMat);
         m_combinedMatrix = Math::MultiplyMatrices(m_projectionMat, m_modelviewMat);
 
-        glUniformMatrix4fv(uni_ViewMatrix, 1, GL_FALSE, m_viewMat.Array());
+        glUniformMatrix4fv(m_uni->viewMatrix, 1, GL_FALSE, m_viewMat.Array());
     }
     else if (type == TRANSFORM_PROJECTION)
     {
@@ -506,12 +672,12 @@ void CGL33Device::SetTransform(TransformType type, const Math::Matrix &matrix)
 
         m_combinedMatrix = Math::MultiplyMatrices(m_projectionMat, m_modelviewMat);
 
-        glUniformMatrix4fv(uni_ProjectionMatrix, 1, GL_FALSE, m_projectionMat.Array());
+        glUniformMatrix4fv(m_uni->projectionMatrix, 1, GL_FALSE, m_projectionMat.Array());
     }
     else if (type == TRANSFORM_SHADOW)
     {
         Math::Matrix temp = matrix;
-        glUniformMatrix4fv(uni_ShadowMatrix, 1, GL_FALSE, temp.Array());
+        glUniformMatrix4fv(m_uni->shadowMatrix, 1, GL_FALSE, temp.Array());
     }
     else
     {
@@ -523,9 +689,9 @@ void CGL33Device::SetMaterial(const Material &material)
 {
     m_material = material;
 
-    glUniform4fv(uni_AmbientColor, 1, m_material.ambient.Array());
-    glUniform4fv(uni_DiffuseColor, 1, m_material.diffuse.Array());
-    glUniform4fv(uni_SpecularColor, 1, m_material.specular.Array());
+    glUniform4fv(m_uni->ambientColor, 1, m_material.ambient.Array());
+    glUniform4fv(m_uni->diffuseColor, 1, m_material.diffuse.Array());
+    glUniform4fv(m_uni->specularColor, 1, m_material.specular.Array());
 }
 
 int CGL33Device::GetMaxLightCount()
@@ -540,18 +706,20 @@ void CGL33Device::SetLight(int index, const Light &light)
 
     m_lights[index] = light;
 
-    glUniform4fv(uni_Light[index].Ambient, 1, light.ambient.Array());
-    glUniform4fv(uni_Light[index].Diffuse, 1, light.diffuse.Array());
-    glUniform4fv(uni_Light[index].Specular, 1, light.specular.Array());
-    glUniform3f(uni_Light[index].Attenuation, light.attenuation0, light.attenuation1, light.attenuation2);
+    LightLocations &uni = m_uni->lights[index];
+
+    glUniform4fv(uni.ambient, 1, light.ambient.Array());
+    glUniform4fv(uni.diffuse, 1, light.diffuse.Array());
+    glUniform4fv(uni.specular, 1, light.specular.Array());
+    glUniform3f(uni.attenuation, light.attenuation0, light.attenuation1, light.attenuation2);
 
     if (light.type == LIGHT_DIRECTIONAL)
     {
-        glUniform4f(uni_Light[index].Position, -light.direction.x, -light.direction.y, -light.direction.z, 0.0f);
+        glUniform4f(uni.position, -light.direction.x, -light.direction.y, -light.direction.z, 0.0f);
     }
     else
     {
-        glUniform4f(uni_Light[index].Position, light.position.x, light.position.y, light.position.z, 1.0f);
+        glUniform4f(uni.position, light.position.x, light.position.y, light.position.z, 1.0f);
     }
 
     // TODO: add spotlight params
@@ -608,7 +776,7 @@ void CGL33Device::SetLightEnabled(int index, bool enabled)
 
     m_lightsEnabled[index] = enabled;
 
-    glUniform1i(uni_Light[index].Enabled, enabled ? 1 : 0);
+    glUniform1i(m_uni->lights[index].enabled, enabled ? 1 : 0);
 }
 
 /** If image is invalid, returns invalid texture.
@@ -1486,6 +1654,7 @@ unsigned int CGL33Device::CreateStaticBuffer(PrimitiveType primitiveType, const
     BindVBO(info.vbo);
 
     glBufferData(GL_ARRAY_BUFFER, info.size, vertices, GL_STATIC_DRAW);
+    m_vboMemory += info.size;
 
     // Vertex coordinate
     glEnableVertexAttribArray(0);
@@ -1531,6 +1700,7 @@ unsigned int CGL33Device::CreateStaticBuffer(PrimitiveType primitiveType, const
     BindVBO(info.vbo);
 
     glBufferData(GL_ARRAY_BUFFER, info.size, vertices, GL_STATIC_DRAW);
+    m_vboMemory += info.size;
 
     // Vertex coordinate
     glEnableVertexAttribArray(0);
@@ -1574,6 +1744,7 @@ unsigned int CGL33Device::CreateStaticBuffer(PrimitiveType primitiveType, const
     BindVBO(info.vbo);
 
     glBufferData(GL_ARRAY_BUFFER, info.size, vertices, GL_STATIC_DRAW);
+    m_vboMemory += info.size;
 
     // Vertex coordinate
     glEnableVertexAttribArray(0);
@@ -1624,7 +1795,9 @@ void CGL33Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primit
     {
         CLogger::GetInstance().Debug("Resizing static buffer: %d->%d\n", info.size, size);
         glBufferData(GL_ARRAY_BUFFER, size, vertices, GL_STATIC_DRAW);
+        m_vboMemory -= info.size;
         info.size = size;
+        m_vboMemory += info.size;
     }
     else
     {
@@ -1681,7 +1854,9 @@ void CGL33Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primit
     {
         CLogger::GetInstance().Debug("Resizing static buffer: %d->%d\n", info.size, size);
         glBufferData(GL_ARRAY_BUFFER, size, vertices, GL_STATIC_DRAW);
+        m_vboMemory -= info.size;
         info.size = size;
+        m_vboMemory += info.size;
     }
     else
     {
@@ -1738,7 +1913,9 @@ void CGL33Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primit
     {
         CLogger::GetInstance().Debug("Resizing static buffer: %d->%d\n", info.size, size);
         glBufferData(GL_ARRAY_BUFFER, size, vertices, GL_STATIC_DRAW);
+        m_vboMemory -= info.size;
         info.size = size;
+        m_vboMemory += info.size;
     }
     else
     {
@@ -1800,6 +1977,8 @@ void CGL33Device::DestroyStaticBuffer(unsigned int bufferId)
     if (m_currentVBO == info.vbo)
         BindVBO(0);
 
+    m_vboMemory -= info.size;
+
     glDeleteBuffers(1, &info.vbo);
     glDeleteVertexArrays(1, &info.vao);
 
@@ -1900,19 +2079,19 @@ void CGL33Device::SetRenderState(RenderState state, bool enabled)
     {
         m_lighting = enabled;
 
-        glUniform1i(uni_LightingEnabled, enabled ? 1 : 0);
+        glUniform1i(m_uni->lightingEnabled, enabled ? 1 : 0);
 
         return;
     }
     else if (state == RENDER_STATE_FOG)
     {
-        glUniform1i(uni_FogEnabled, enabled ? 1 : 0);
+        glUniform1i(m_uni->fogEnabled, enabled ? 1 : 0);
 
         return;
     }
     else if (state == RENDER_STATE_ALPHA_TEST)
     {
-        glUniform1i(uni_AlphaTestEnabled, enabled ? 1 : 0);
+        glUniform1i(m_uni->alphaTestEnabled, enabled ? 1 : 0);
 
         return;
     }
@@ -1951,7 +2130,7 @@ void CGL33Device::SetDepthBias(float factor, float units)
 
 void CGL33Device::SetAlphaTestFunc(CompFunc func, float refValue)
 {
-    glUniform1f(uni_AlphaReference, refValue);
+    glUniform1f(m_uni->alphaReference, refValue);
 }
 
 void CGL33Device::SetBlendFunc(BlendFunc srcBlend, BlendFunc dstBlend)
@@ -1973,8 +2152,8 @@ void CGL33Device::SetFogParams(FogMode mode, const Color &color, float start, fl
 {
     // TODO: reimplement
 
-    glUniform2f(uni_FogRange, start, end);
-    glUniform4f(uni_FogColor, color.r, color.g, color.b, color.a);
+    glUniform2f(m_uni->fogRange, start, end);
+    glUniform4f(m_uni->fogColor, color.r, color.g, color.b, color.a);
 
     /*
     if      (mode == FOG_LINEAR) glFogi(GL_FOG_MODE, GL_LINEAR);
@@ -2000,12 +2179,12 @@ void CGL33Device::SetCullMode(CullMode mode)
 
 void CGL33Device::SetShadeModel(ShadeModel model)
 {
-    glUniform1i(uni_SmoothShading, (model == SHADE_SMOOTH ? 1 : 0));
+    //glUniform1i(uni_SmoothShading, (model == SHADE_SMOOTH ? 1 : 0));
 }
 
 void CGL33Device::SetShadowColor(float value)
 {
-    glUniform1f(uni_ShadowColor, value);
+    glUniform1f(m_uni->shadowColor, value);
 }
 
 void CGL33Device::SetFillMode(FillMode mode)
@@ -2075,13 +2254,13 @@ void CGL33Device::DeleteFramebuffer(std::string name)
 void CGL33Device::UpdateRenderingMode()
 {
     bool enabled = m_texturesEnabled[0] && m_currentTextures[0].id != 0;
-    glUniform1i(uni_PrimaryTextureEnabled, enabled ? 1 : 0);
+    glUniform1i(m_uni->textureEnabled[0], enabled ? 1 : 0);
 
     enabled = m_texturesEnabled[1] && m_currentTextures[1].id != 0;
-    glUniform1i(uni_SecondaryTextureEnabled, enabled ? 1 : 0);
+    glUniform1i(m_uni->textureEnabled[1], enabled ? 1 : 0);
 
     enabled = m_texturesEnabled[2] && m_currentTextures[2].id != 0;
-    glUniform1i(uni_ShadowTextureEnabled, enabled ? 1 : 0);
+    glUniform1i(m_uni->textureEnabled[2], enabled ? 1 : 0);
 }
 
 inline void CGL33Device::BindVBO(GLuint vbo)
diff --git a/src/graphics/opengl/gl33device.h b/src/graphics/opengl/gl33device.h
index 5bcdbec..051f7a4 100644
--- a/src/graphics/opengl/gl33device.h
+++ b/src/graphics/opengl/gl33device.h
@@ -261,11 +261,20 @@ private:
     //! Currently bound VAO
     GLuint m_currentVAO = 0;
 
+    //! Total memory allocated in textures
+    unsigned long m_textureMemory = 0;
+    //! Total memory allocated in VBOs
+    unsigned long m_vboMemory = 0;
+
     //! Map of framebuffers
     std::map<std::string, std::unique_ptr<CFramebuffer>> m_framebuffers;
 
-    //! Shader program
-    GLuint m_shaderProgram = 0;
+    //! Shader program for normal rendering
+    GLuint m_normalProgram = 0;
+    //! Shader program for interface rendering
+    GLuint m_interfaceProgram = 0;
+    //! Shader program for shadow rendering
+    GLuint m_shadowProgram = 0;
     //! true enables per-pixel lighting
     bool m_perPixelLighting = false;
 
@@ -278,76 +287,12 @@ private:
     //! Dynamic buffer offset
     unsigned int m_bufferOffset = 0;
 
-    // Uniforms
-    //! Projection matrix
-    GLint uni_ProjectionMatrix = 0;
-    //! View matrix
-    GLint uni_ViewMatrix = 0;
-    //! Model matrix
-    GLint uni_ModelMatrix = 0;
-    //! Shadow matrix
-    GLint uni_ShadowMatrix = 0;
-    //! Normal matrix
-    GLint uni_NormalMatrix = 0;
-
-    //! Primary texture sampler
-    GLint uni_PrimaryTexture = 0;
-    //! Secondary texture sampler
-    GLint uni_SecondaryTexture = 0;
-    //! Shadow texture sampler
-    GLint uni_ShadowTexture = 0;
-
-    GLint uni_PrimaryTextureEnabled = 0;
-    GLint uni_SecondaryTextureEnabled = 0;
-    GLint uni_ShadowTextureEnabled = 0;
-
-    // Fog parameters
-    //! true enables fog
-    GLint uni_FogEnabled = 0;
-    //! Fog range
-    GLint uni_FogRange = 0;
-    //! Fog color
-    GLint uni_FogColor = 0;
-
-    // Alpha test parameters
-    //! true enables alpha test
-    GLint uni_AlphaTestEnabled = 0;
-    //! Alpha test reference value
-    GLint uni_AlphaReference = 0;
-
-    //! Shadow color
-    GLint uni_ShadowColor = 0;
-
-    // Lighting parameters
-    GLint uni_SmoothShading = 0;
-    //! true enables lighting
-    GLint uni_LightingEnabled = 0;
-    //! Ambient color
-    GLint uni_AmbientColor = 0;
-    //! Diffuse color
-    GLint uni_DiffuseColor = 0;
-    //! Specular color
-    GLint uni_SpecularColor = 0;
-
-    struct LightUniforms
-    {
-        //! true enables light
-        GLint Enabled = 0;
-        //! Light type
-        GLint Type = 0;
-        //! Position or direction vector
-        GLint Position = 0;
-        //! Ambient color
-        GLint Ambient = 0;
-        //! Diffuse color
-        GLint Diffuse = 0;
-        //! Specular color
-        GLint Specular = 0;
-        //! Attenuation
-        GLint Attenuation = 0;
-    };
-
-    LightUniforms uni_Light[8];
+    //! Current mode
+    unsigned int m_mode = 0;
+    //! Uniform locations for all modes
+    UniformLocations m_uniforms[3];
+    //! Uniform locations for current mode
+    UniformLocations* m_uni = nullptr;
 };
 
 } // namespace Gfx
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index 67a6ed0..481f921 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -182,7 +182,11 @@ bool CGLDevice::Create()
         return false;
     }
 
-    GetLogger()->Info("OpenGL %d.%d\n", glMajor, glMinor);
+    const char* version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
+    const char* renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
+
+    GetLogger()->Info("OpenGL %s\n", version);
+    GetLogger()->Info("%s\n", renderer);
 
     // Detect multitexture support
     m_multitextureAvailable = glewIsSupported("GL_ARB_multitexture GL_ARB_texture_env_combine");
diff --git a/src/graphics/opengl/glutil.cpp b/src/graphics/opengl/glutil.cpp
index cd80134..b8aa712 100644
--- a/src/graphics/opengl/glutil.cpp
+++ b/src/graphics/opengl/glutil.cpp
@@ -28,7 +28,9 @@
 
 #include <physfs.h>
 #include <cstring>
+#include <vector>
 #include <sstream>
+#include <algorithm>
 
 // Graphics module namespace
 namespace Gfx
@@ -93,13 +95,77 @@ int GetOpenGLVersion()
 
 int GetOpenGLVersion(int &major, int &minor)
 {
-    const char *version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
-
-    sscanf(version, "%d.%d", &major, &minor);
+    glGetIntegerv(GL_MAJOR_VERSION, &major);
+    glGetIntegerv(GL_MINOR_VERSION, &minor);
 
     return 10 * major + minor;
 }
 
+bool AreExtensionsSupported(std::string list)
+{
+    // Extract extensions to find
+    std::vector<std::string> extensions;
+    std::stringstream stream(list);
+
+    std::string value;
+
+    while (true)
+    {
+        stream >> value;
+
+        if (stream.eof())
+            break;
+
+        extensions.push_back(value);
+    }
+
+    int version = GetOpenGLVersion();
+
+    // Use glGetString
+    if (version < 30)
+    {
+        const char* text = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
+
+        stream = std::stringstream(text);
+
+        while (!extensions.empty())
+        {
+            stream >> value;
+
+            if (stream.eof())
+                break;
+
+            auto result = std::remove(extensions.begin(), extensions.end(), value);
+
+            if (result != extensions.end())
+                extensions.erase(result);
+        }
+    }
+    // Use glGetStringi
+    else
+    {
+        int n;
+        glGetIntegerv(GL_NUM_EXTENSIONS, &n);
+
+        for (int i = 0; i < n; i++)
+        {
+            const char* name = reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, i));
+            value = std::string(name);
+
+            auto result = std::remove(extensions.begin(), extensions.end(), value);
+
+            if (result != extensions.end())
+                extensions.erase(result);
+
+            if (extensions.empty())
+                break;
+        }
+    }
+
+    // Return true if found all required extensions
+    return extensions.empty();
+}
+
 std::string GetHardwareInfo(bool full)
 {
     int glversion = GetOpenGLVersion();
diff --git a/src/graphics/opengl/glutil.h b/src/graphics/opengl/glutil.h
index 6ee9de8..8f96d8d 100644
--- a/src/graphics/opengl/glutil.h
+++ b/src/graphics/opengl/glutil.h
@@ -60,6 +60,8 @@ int GetOpenGLVersion();
 // \return First digit is major part, second digit is minor part.
 int GetOpenGLVersion(int &major, int &minor);
 
+bool AreExtensionsSupported(std::string extensions);
+
 //! Returns information about graphics card
 std::string GetHardwareInfo(bool full = false);
 
@@ -104,4 +106,74 @@ private:
 
 std::unique_ptr<CGLFrameBufferPixels> GetGLFrameBufferPixels(Math::IntPoint size);
 
+struct LightLocations
+{
+    //! true enables light
+    GLint enabled = -1;
+    //! Light type
+    GLint type = -1;
+    //! Position or direction vector
+    GLint position = -1;
+    //! Ambient color
+    GLint ambient = -1;
+    //! Diffuse color
+    GLint diffuse = -1;
+    //! Specular color
+    GLint specular = -1;
+    //! Attenuation
+    GLint attenuation = -1;
+};
+
+struct UniformLocations
+{
+    // Uniforms
+    //! Projection matrix
+    GLint projectionMatrix = -1;
+    //! View matrix
+    GLint viewMatrix = -1;
+    //! Model matrix
+    GLint modelMatrix = -1;
+    //! Shadow matrix
+    GLint shadowMatrix = -1;
+    //! Normal matrix
+    GLint normalMatrix = -1;
+
+    //! Primary texture sampler
+    GLint primaryTexture = -1;
+    //! Secondary texture sampler
+    GLint secondaryTexture = -1;
+    //! Shadow texture sampler
+    GLint shadowTexture = -1;
+
+    //! true enables texture
+    GLint textureEnabled[3] = {};
+
+    // Alpha test parameters
+    //! true enables alpha test
+    GLint alphaTestEnabled = -1;
+    //! Alpha test reference value
+    GLint alphaReference = -1;
+
+    //! true enables fog
+    GLint fogEnabled = -1;
+    //! Fog range
+    GLint fogRange = -1;
+    //! Fog color
+    GLint fogColor = -1;
+
+    //! Shadow color
+    GLint shadowColor = -1;
+
+    //! true enables lighting
+    GLint lightingEnabled = -1;
+    //! Ambient color
+    GLint ambientColor = -1;
+    //! Diffuse color
+    GLint diffuseColor = -1;
+    //! Specular color
+    GLint specularColor = -1;
+
+    LightLocations lights[8] = {};
+};
+
 } // namespace Gfx
diff --git a/src/graphics/opengl/shaders/fragment_shader_33_interface.glsl b/src/graphics/opengl/shaders/fragment_shader_33_interface.glsl
new file mode 100644
index 0000000..6d64f4d
--- /dev/null
+++ b/src/graphics/opengl/shaders/fragment_shader_33_interface.glsl
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsitec.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
+
+// FRAGMENT SHADER - INTERFACE RENDERING
+#version 330 core
+
+uniform sampler2D uni_Texture;
+
+uniform bool uni_TextureEnabled;
+
+in VertexData
+{
+    vec4 Color;
+    vec2 TexCoord;
+} data;
+
+out vec4 out_FragColor;
+
+void main()
+{
+    if (uni_TextureEnabled)
+    {
+        out_FragColor = data.Color * texture(uni_Texture, data.TexCoord);
+    }
+    else
+    {
+        out_FragColor = data.Color;
+    }
+}
diff --git a/src/graphics/opengl/shaders/fragment_shader_33_pervertex.glsl b/src/graphics/opengl/shaders/fragment_shader_33_pervertex.glsl
index e8461bc..89df06b 100644
--- a/src/graphics/opengl/shaders/fragment_shader_33_pervertex.glsl
+++ b/src/graphics/opengl/shaders/fragment_shader_33_pervertex.glsl
@@ -18,7 +18,7 @@
  */
 
 // FRAGMENT SHADER - PER-VERTEX LIGHTING
-#version 330
+#version 330 core
 
 uniform sampler2D uni_PrimaryTexture;
 uniform sampler2D uni_SecondaryTexture;
diff --git a/src/graphics/opengl/shaders/fragment_shader_33_shadow.glsl b/src/graphics/opengl/shaders/fragment_shader_33_shadow.glsl
new file mode 100644
index 0000000..6f895e1
--- /dev/null
+++ b/src/graphics/opengl/shaders/fragment_shader_33_shadow.glsl
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsitec.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
+
+// FRAGMENT SHADER - SHADOW RENDERING
+#version 330 core
+
+uniform sampler2D uni_Texture;
+
+uniform bool uni_TextureEnabled;
+
+uniform bool uni_AlphaTestEnabled;
+uniform float uni_AlphaReference;
+
+in VertexData
+{
+    vec2 TexCoord;
+} data;
+
+out vec4 out_FragColor;
+
+void main()
+{
+    float alpha = 1.0f;
+
+    if (uni_TextureEnabled)
+    {
+        alpha *= texture(uni_Texture, data.TexCoord).a;
+    }
+
+    if (uni_AlphaTestEnabled)
+    {
+        if(alpha < uni_AlphaReference)
+            discard;
+    }
+
+    out_FragColor = vec4(1.0f);
+}
diff --git a/src/graphics/opengl/shaders/vertex_shader_33_interface.glsl b/src/graphics/opengl/shaders/vertex_shader_33_interface.glsl
new file mode 100644
index 0000000..1bf6845
--- /dev/null
+++ b/src/graphics/opengl/shaders/vertex_shader_33_interface.glsl
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsitec.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
+
+// VERTEX SHADER - INTERFACE RENDERING
+#version 330 core
+
+uniform mat4 uni_ProjectionMatrix;
+uniform mat4 uni_ViewMatrix;
+uniform mat4 uni_ModelMatrix;
+
+layout(location = 0) in vec4 in_VertexCoord;
+layout(location = 1) in vec3 in_Normal;
+layout(location = 2) in vec4 in_Color;
+layout(location = 3) in vec2 in_TexCoord0;
+layout(location = 4) in vec2 in_TexCoord1;
+
+out VertexData
+{
+    vec4 Color;
+    vec2 TexCoord;
+} data;
+
+void main()
+{
+    gl_Position = uni_ProjectionMatrix * uni_ViewMatrix * uni_ModelMatrix * in_VertexCoord;
+
+    data.Color = in_Color;
+    data.TexCoord = in_TexCoord0;
+}
diff --git a/src/graphics/opengl/shaders/vertex_shader_33_pervertex.glsl b/src/graphics/opengl/shaders/vertex_shader_33_pervertex.glsl
index eb764c3..6d95109 100644
--- a/src/graphics/opengl/shaders/vertex_shader_33_pervertex.glsl
+++ b/src/graphics/opengl/shaders/vertex_shader_33_pervertex.glsl
@@ -18,7 +18,7 @@
  */
 
 // VERTEX SHADER - PER-VERTEX LIGHTING
-#version 330
+#version 330 core
 
 struct LightParams
 {
diff --git a/src/graphics/opengl/shaders/vertex_shader_33_shadow.glsl b/src/graphics/opengl/shaders/vertex_shader_33_shadow.glsl
new file mode 100644
index 0000000..18e31bd
--- /dev/null
+++ b/src/graphics/opengl/shaders/vertex_shader_33_shadow.glsl
@@ -0,0 +1,43 @@
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsitec.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
+
+// VERTEX SHADER - SHADOW RENDERING
+#version 330 core
+
+uniform mat4 uni_ProjectionMatrix;
+uniform mat4 uni_ViewMatrix;
+uniform mat4 uni_ModelMatrix;
+
+layout(location = 0) in vec4 in_VertexCoord;
+layout(location = 1) in vec3 in_Normal;
+layout(location = 2) in vec4 in_Color;
+layout(location = 3) in vec2 in_TexCoord0;
+layout(location = 4) in vec2 in_TexCoord1;
+
+out VertexData
+{
+    vec2 TexCoord;
+} data;
+
+void main()
+{
+    gl_Position = uni_ProjectionMatrix * uni_ViewMatrix * uni_ModelMatrix * in_VertexCoord;
+
+    data.TexCoord = in_TexCoord0;
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list