Fixed alpha value of translucent parts in PNG files. Fixes #241.

This commit is contained in:
Leonardo Zide
2018-07-04 11:19:15 -07:00
parent 508b1e416f
commit b09439d97d
4 changed files with 33 additions and 3 deletions
+4 -1
View File
@@ -346,7 +346,10 @@ void lcContext::SetDefaultState()
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (gSupportsBlendFuncSeparate)
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_ONE);
else
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0.5f, 0.1f);
+21
View File
@@ -6,6 +6,7 @@ bool gSupportsVertexBufferObject;
bool gSupportsFramebufferObjectARB;
bool gSupportsFramebufferObjectEXT;
bool gSupportsTexImage2DMultisample;
bool gSupportsBlendFuncSeparate;
bool gSupportsAnisotropic;
GLfloat gMaxAnisotropy;
@@ -117,6 +118,8 @@ PFNGLVERTEXATTRIBPOINTERPROC lcVertexAttribPointer;
PFNGLTEXIMAGE2DMULTISAMPLEPROC lcTexImage2DMultisample;
PFNGLBLENDFUNCSEPARATEPROC lcBlendFuncSeparate;
#endif
static bool lcIsGLExtensionSupported(const GLubyte* Extensions, const char* Name)
@@ -270,6 +273,15 @@ void lcInitializeGLExtensions(const QGLContext* Context)
gSupportsFramebufferObjectEXT = true;
}
if (lcIsGLExtensionSupported(Extensions, "GL_EXT_blend_func_separate"))
{
#ifdef LC_LOAD_GLEXTENSIONS
lcBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)Context->getProcAddress("glBlendFuncSeparateEXT");
#endif
gSupportsBlendFuncSeparate = true;
}
const GLubyte* GLSLVersion = glGetString(GL_SHADING_LANGUAGE_VERSION);
int GLSLMajor = 0, GLSLMinor = 0;
@@ -344,6 +356,15 @@ void lcInitializeGLExtensions(const QGLContext* Context)
gSupportsTexImage2DMultisample = true;
}
if (VersionMajor >= 4)
{
#ifdef LC_LOAD_GLEXTENSIONS
lcBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)Context->getProcAddress("glBlendFuncSeparate");
#endif
gSupportsBlendFuncSeparate = true;
}
#endif
#ifdef LC_OPENGLES
+5
View File
@@ -7,6 +7,7 @@ extern bool gSupportsVertexBufferObject;
extern bool gSupportsFramebufferObjectARB;
extern bool gSupportsFramebufferObjectEXT;
extern bool gSupportsTexImage2DMultisample;
extern bool gSupportsBlendFuncSeparate;
extern bool gSupportsAnisotropic;
extern GLfloat gMaxAnisotropy;
@@ -122,6 +123,8 @@ extern PFNGLVERTEXATTRIBPOINTERPROC lcVertexAttribPointer;
extern PFNGLTEXIMAGE2DMULTISAMPLEPROC lcTexImage2DMultisample;
extern PFNGLBLENDFUNCSEPARATEPROC lcBlendFuncSeparate;
#define glBindBuffer lcBindBufferARB
#define glDeleteBuffers lcDeleteBuffersARB
#define glGenBuffers lcGenBuffersARB
@@ -228,4 +231,6 @@ extern PFNGLTEXIMAGE2DMULTISAMPLEPROC lcTexImage2DMultisample;
#define glTexImage2DMultisample lcTexImage2DMultisample
#define glBlendFuncSeparate lcBlendFuncSeparate
#endif
+3 -2
View File
@@ -23,12 +23,13 @@ lcQAboutDialog::lcQAboutDialog(QWidget *parent) :
QString BuffersFormat = tr("Color Buffer: %1 bits %2 %3\nDepth Buffer: %4 bits\nStencil Buffer: %5 bits\n\n");
QString Buffers = BuffersFormat.arg(QString::number(ColorDepth), Format.rgba() ? "RGBA" : tr("indexed"), Format.doubleBuffer() ? tr("double buffered") : QString(), QString::number(Format.depthBufferSize()), QString::number(Format.stencilBufferSize()));
QString ExtensionsFormat = tr("GL_ARB_vertex_buffer_object extension: %1\nGL_ARB_framebuffer_object extension: %2\nGL_EXT_framebuffer_object extension: %3\nGL_EXT_texture_filter_anisotropic extension: %4\n");
QString ExtensionsFormat = tr("GL_ARB_vertex_buffer_object extension: %1\nGL_ARB_framebuffer_object extension: %2\nGL_EXT_framebuffer_object extension: %3\nGL_EXT_blend_func_separate: %4\nGL_EXT_texture_filter_anisotropic extension: %5\n");
QString VertexBufferObject = gSupportsVertexBufferObject ? tr("Supported") : tr("Not supported");
QString FramebufferObjectARB = gSupportsFramebufferObjectARB ? tr("Supported") : tr("Not supported");
QString FramebufferObjectEXT = gSupportsFramebufferObjectEXT ? tr("Supported") : tr("Not supported");
QString BlendFuncSeparateEXT = gSupportsBlendFuncSeparate ? tr("Supported") : tr("Not supported");
QString Anisotropic = gSupportsAnisotropic ? tr("Supported (max %1)").arg(gMaxAnisotropy) : tr("Not supported");
QString Extensions = ExtensionsFormat.arg(VertexBufferObject, FramebufferObjectARB, FramebufferObjectEXT, Anisotropic);
QString Extensions = ExtensionsFormat.arg(VertexBufferObject, FramebufferObjectARB, FramebufferObjectEXT, BlendFuncSeparateEXT, Anisotropic);
ui->info->setText(Version + Buffers + Extensions);
}