Changed some variables names and debug logging info for the OpenGL renderer.

Also simplified a pixel conversion in the core.glsl shader.
This commit is contained in:
Leon Styhre 2022-03-15 17:14:55 +01:00
parent 1abfc06038
commit 29501af68f
5 changed files with 19 additions and 21 deletions

View file

@ -363,8 +363,8 @@ void Renderer::drawRect(const float x,
bool horizontalGradient,
const float opacity,
const float dimming,
const BlendFactor srcBlendFactorFactor,
const BlendFactor dstBlendFactorFactor)
const BlendFactor srcBlendFactor,
const BlendFactor dstBlendFactor)
{
Vertex vertices[4];
@ -393,5 +393,5 @@ void Renderer::drawRect(const float x,
vertices->dimming = dimming;
bindTexture(0);
drawTriangleStrips(vertices, 4, srcBlendFactorFactor, dstBlendFactorFactor);
drawTriangleStrips(vertices, 4, srcBlendFactor, dstBlendFactor);
}

View file

@ -87,10 +87,10 @@ bool RendererOpenGL::loadShaders()
return true;
}
GLenum RendererOpenGL::convertBlendFactor(const BlendFactor BlendFactorFactor)
GLenum RendererOpenGL::convertBlendFactor(const BlendFactor BlendFactor)
{
// clang-format off
switch (BlendFactorFactor) {
switch (BlendFactor) {
case BlendFactor::ZERO: { return GL_ZERO; } break;
case BlendFactor::ONE: { return GL_ONE; } break;
case BlendFactor::SRC_COLOR: { return GL_SRC_COLOR; } break;
@ -168,13 +168,11 @@ bool RendererOpenGL::createContext()
LOG(LogInfo) << "GL version: " << version;
#if defined(_WIN64)
LOG(LogInfo) << "EmulationStation renderer: OpenGL 3.3 with GLEW";
#else
#if defined(USE_OPENGLES)
#elif defined(USE_OPENGLES)
LOG(LogInfo) << "EmulationStation renderer: OpenGL ES 3.0";
#else
LOG(LogInfo) << "EmulationStation renderer: OpenGL 3.3";
#endif
#endif
#if !defined(USE_OPENGLES)
// TODO: Fix the issue that causes the first glClearColor function call to fail.
@ -356,14 +354,14 @@ void RendererOpenGL::bindTexture(const unsigned int texture)
void RendererOpenGL::drawTriangleStrips(const Vertex* vertices,
const unsigned int numVertices,
const BlendFactor srcBlendFactorFactor,
const BlendFactor dstBlendFactorFactor)
const BlendFactor srcBlendFactor,
const BlendFactor dstBlendFactor)
{
const float width {vertices[3].position[0]};
const float height {vertices[3].position[1]};
GL_CHECK_ERROR(glBlendFunc(convertBlendFactor(srcBlendFactorFactor),
convertBlendFactor(dstBlendFactorFactor)));
GL_CHECK_ERROR(
glBlendFunc(convertBlendFactor(srcBlendFactor), convertBlendFactor(dstBlendFactor)));
if (vertices->shaders == 0 || vertices->shaders & Shader::CORE) {
if (mCoreShader == nullptr)

View file

@ -31,7 +31,7 @@ public:
ShaderOpenGL* getShaderProgram(unsigned int shaderID);
bool loadShaders() override;
GLenum convertBlendFactor(const BlendFactor BlendFactorFactor);
GLenum convertBlendFactor(const BlendFactor BlendFactor);
GLenum convertTextureType(const TextureType type);
void setup() override;

View file

@ -75,8 +75,8 @@ bool ShaderOpenGL::createProgram()
glGetShaderiv(currentShader, GL_COMPILE_STATUS, &shaderCompiled);
if (shaderCompiled != GL_TRUE) {
LOG(LogError) << "OpenGL error: Unable to compile shader " << currentShader << " ("
<< std::get<0>(*it) << ").";
LOG(LogError) << "ShaderOpenGL::createProgram(): Unable to compile shader "
<< currentShader << " (" << std::get<0>(*it) << ")";
printShaderInfoLog(currentShader, std::get<2>(*it), true);
return false;
}
@ -91,7 +91,7 @@ bool ShaderOpenGL::createProgram()
glGetProgramiv(mProgramID, GL_LINK_STATUS, &programSuccess);
if (programSuccess != GL_TRUE) {
LOG(LogError) << "OpenGL error: Unable to link program " << mProgramID << ".";
LOG(LogError) << "ShaderOpenGL::createProgram(): Unable to link program " << mProgramID;
printProgramInfoLog(mProgramID);
return false;
}
@ -204,12 +204,12 @@ void ShaderOpenGL::printProgramInfoLog(GLuint programID)
glGetProgramInfoLog(programID, maxLength, &logLength, &infoLog.front());
if (logLength > 0) {
LOG(LogDebug) << "Renderer_GL21::printProgramInfoLog():\n"
LOG(LogDebug) << "ShaderOpenGL::createProgram()::\n"
<< std::string(infoLog.begin(), infoLog.end());
}
}
else {
LOG(LogError) << "OpenGL error: " << programID << " is not a program.";
LOG(LogError) << "ShaderOpenGL::createProgram(): " << programID << " is not a program";
}
}
@ -228,7 +228,7 @@ void ShaderOpenGL::printShaderInfoLog(GLuint shaderID, GLenum shaderType, bool e
glGetShaderInfoLog(shaderID, maxLength, &logLength, &infoLog.front());
if (logLength > 0) {
LOG(LogDebug) << "Shader_GL21::printShaderInfoLog(): " << (error ? "Error" : "Warning")
LOG(LogDebug) << "ShaderOpenGL::createProgram(): " << (error ? "Error" : "Warning")
<< " in "
<< (shaderType == GL_VERTEX_SHADER ? "VERTEX section:\n" :
"FRAGMENT section:\n")
@ -236,6 +236,6 @@ void ShaderOpenGL::printShaderInfoLog(GLuint shaderID, GLenum shaderType, bool e
}
}
else {
LOG(LogError) << "OpenGL error: " << shaderID << " is not a shader.";
LOG(LogError) << "ShaderOpenGL::createProgram():: " << shaderID << " is not a shader";
}
}

View file

@ -81,7 +81,7 @@ void main()
// BGRA to RGBA conversion.
if (0u != (shaderFlags & 1u))
sampledColor = vec4(sampledColor.bgr, sampledColor.a);
sampledColor = sampledColor.bgra;
FragColor = sampledColor;
}