+ added depthtesting and blending support for shader passes

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2021-09-02 09:05:12 +02:00
parent 09d53e8dd7
commit 59e6800f81
2 changed files with 33 additions and 2 deletions

View File

@ -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);

View File

@ -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 () *