Procházet zdrojové kódy

+ added depthtesting and blending support for shader passes

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
Alexis Maiquez před 5 roky
rodič
revize
59e6800f81

+ 2 - 2
src/WallpaperEngine/Render/CWallpaper.cpp

@@ -59,7 +59,7 @@ void CWallpaper::setupFramebuffers ()
     // bind the new texture to set settings on it
     glBindTexture (GL_TEXTURE_2D, this->m_mainTexture);
     // give OpenGL an empty image
-    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 1920, 1080, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
+    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 1920, 1080, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
 
     // set filtering parameters, otherwise the texture is not rendered
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -89,7 +89,7 @@ void CWallpaper::setupFramebuffers ()
     // bind the new texture to set settings on it
     glBindTexture (GL_TEXTURE_2D, this->m_subTexture);
     // give OpenGL an empty image
-    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 1920, 1080, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
+    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 1920, 1080, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
 
     // set filtering parameters, otherwise the texture is not rendered
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

+ 31 - 0
src/WallpaperEngine/Render/Objects/Effects/CPass.cpp

@@ -54,6 +54,37 @@ void CPass::render (GLuint drawTo, GLuint input)
     if (drawTo > 0)
         glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
+    // set texture blending
+    if (this->m_pass->getBlendingMode () == "translucent")
+    {
+        glEnable (GL_BLEND);
+        glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+    }
+    else if (this->m_pass->getBlendingMode () == "additive")
+    {
+        glEnable (GL_BLEND);
+        glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE);
+    }
+    else if (this->m_pass->getBlendingMode () == "normal")
+    {
+        glEnable (GL_BLEND);
+        glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO);
+    }
+    else
+    {
+        glDisable (GL_BLEND);
+    }
+
+    // set depth testing
+    if (this->m_pass->getDepthTest () == "disabled")
+    {
+        glDisable (GL_DEPTH_TEST);
+    }
+    else
+    {
+        glEnable (GL_DEPTH_TEST);
+    }
+
     // update variables used in the render process (like g_ModelViewProjectionMatrix)
     this->m_modelViewProjectionMatrix =
             this->m_material->getImage ()->getScene ()->getCamera ()->getProjection () *