Renamed Renderer_GL21 and Shader_GL21 to RendererOpenGL and ShaderOpenGL.

This commit is contained in:
Leon Styhre 2022-03-14 20:14:18 +01:00
parent f0c35d8509
commit 6ff0ff1c47
6 changed files with 60 additions and 60 deletions

View file

@ -74,8 +74,8 @@ set(CORE_HEADERS
# Renderers
${CMAKE_CURRENT_SOURCE_DIR}/src/renderers/Renderer.h
${CMAKE_CURRENT_SOURCE_DIR}/src/renderers/Renderer_GL21.h
${CMAKE_CURRENT_SOURCE_DIR}/src/renderers/Shader_GL21.h
${CMAKE_CURRENT_SOURCE_DIR}/src/renderers/RendererOpenGL.h
${CMAKE_CURRENT_SOURCE_DIR}/src/renderers/ShaderOpenGL.h
# Resources
${CMAKE_CURRENT_SOURCE_DIR}/src/resources/Font.h
@ -150,8 +150,8 @@ set(CORE_SOURCES
# Renderer
${CMAKE_CURRENT_SOURCE_DIR}/src/renderers/Renderer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/renderers/Renderer_GL21.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/renderers/Shader_GL21.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/renderers/RendererOpenGL.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/renderers/ShaderOpenGL.cpp
# Resources
${CMAKE_CURRENT_SOURCE_DIR}/src/resources/Font.cpp

View file

@ -11,8 +11,8 @@
#include "ImageIO.h"
#include "Log.h"
#include "Settings.h"
#include "Shader_GL21.h"
#include "renderers/Renderer_GL21.h"
#include "renderers/RendererOpenGL.h"
#include "renderers/ShaderOpenGL.h"
#include "resources/ResourceManager.h"
#if defined(_WIN64)

View file

@ -1,12 +1,12 @@
// SPDX-License-Identifier: MIT
//
// EmulationStation Desktop Edition
// Renderer_GL21.cpp
// RendererOpenGL.cpp
//
// OpenGL / OpenGL ES renderering functions.
//
#include "renderers/Renderer_GL21.h"
#include "renderers/RendererOpenGL.h"
#include "Settings.h"
@ -43,7 +43,7 @@ RendererOpenGL* RendererOpenGL::getInstance()
return &instance;
}
Shader* RendererOpenGL::getShaderProgram(unsigned int shaderID)
ShaderOpenGL* RendererOpenGL::getShaderProgram(unsigned int shaderID)
{
unsigned int index {0};
@ -71,7 +71,7 @@ bool RendererOpenGL::loadShaders()
shaderFiles.push_back(":/shaders/glsl/scanlines.glsl");
for (auto it = shaderFiles.cbegin(); it != shaderFiles.cend(); ++it) {
Shader* loadShader = new Shader();
ShaderOpenGL* loadShader = new ShaderOpenGL();
loadShader->loadShaderFile(*it, GL_VERTEX_SHADER);
loadShader->loadShaderFile(*it, GL_FRAGMENT_SHADER);
@ -300,7 +300,7 @@ unsigned int RendererOpenGL::createTexture(const TextureType type,
const unsigned int height,
void* data)
{
const GLenum textureType {RendererOpenGL::convertTextureType(type)};
const GLenum textureType {convertTextureType(type)};
unsigned int texture;
GL_CHECK_ERROR(glGenTextures(1, &texture));
@ -337,7 +337,7 @@ void RendererOpenGL::updateTexture(const unsigned int texture,
const unsigned int height,
void* data)
{
const GLenum textureType {RendererOpenGL::convertTextureType(type)};
const GLenum textureType {convertTextureType(type)};
GL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, texture));
GL_CHECK_ERROR(glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, textureType,
@ -362,12 +362,12 @@ void RendererOpenGL::drawTriangleStrips(const Vertex* vertices,
const float width {vertices[3].position[0]};
const float height {vertices[3].position[1]};
GL_CHECK_ERROR(glBlendFunc(RendererOpenGL::convertBlendFactor(srcBlendFactorFactor),
RendererOpenGL::convertBlendFactor(dstBlendFactorFactor)));
GL_CHECK_ERROR(glBlendFunc(convertBlendFactor(srcBlendFactorFactor),
convertBlendFactor(dstBlendFactorFactor)));
if (vertices->shaders == 0 || vertices->shaders & SHADER_CORE) {
if (mCoreShader == nullptr)
mCoreShader = RendererOpenGL::getShaderProgram(SHADER_CORE);
mCoreShader = getShaderProgram(SHADER_CORE);
if (mCoreShader) {
if (mLastShader != mCoreShader)
mCoreShader->activateShaders();
@ -388,7 +388,7 @@ void RendererOpenGL::drawTriangleStrips(const Vertex* vertices,
}
else if (vertices->shaders & SHADER_BLUR_HORIZONTAL) {
if (mBlurHorizontalShader == nullptr)
mBlurHorizontalShader = RendererOpenGL::getShaderProgram(SHADER_BLUR_HORIZONTAL);
mBlurHorizontalShader = getShaderProgram(SHADER_BLUR_HORIZONTAL);
if (mBlurHorizontalShader) {
if (mLastShader != mBlurHorizontalShader)
mBlurHorizontalShader->activateShaders();
@ -405,7 +405,7 @@ void RendererOpenGL::drawTriangleStrips(const Vertex* vertices,
}
else if (vertices->shaders & SHADER_BLUR_VERTICAL) {
if (mBlurVerticalShader == nullptr)
mBlurVerticalShader = RendererOpenGL::getShaderProgram(SHADER_BLUR_VERTICAL);
mBlurVerticalShader = getShaderProgram(SHADER_BLUR_VERTICAL);
if (mBlurVerticalShader) {
if (mLastShader != mBlurVerticalShader)
mBlurVerticalShader->activateShaders();
@ -422,7 +422,7 @@ void RendererOpenGL::drawTriangleStrips(const Vertex* vertices,
}
else if (vertices->shaders & SHADER_SCANLINES) {
if (mScanlinelShader == nullptr)
mScanlinelShader = RendererOpenGL::getShaderProgram(SHADER_SCANLINES);
mScanlinelShader = getShaderProgram(SHADER_SCANLINES);
float shaderWidth {width * 1.2f};
// Scale the scanlines relative to screen resolution.
float screenHeightModifier {getScreenHeightModifier()};

View file

@ -1,16 +1,16 @@
// SPDX-License-Identifier: MIT
//
// EmulationStation Desktop Edition
// Renderer_GL21.h
// RendererOpenGL.h
//
// OpenGL / OpenGL ES renderering functions.
//
#ifndef ES_CORE_RENDERER_RENDERER_GL21_H
#define ES_CORE_RENDERER_RENDERER_GL21_H
#ifndef ES_CORE_RENDERER_RENDERER_OPENGL_H
#define ES_CORE_RENDERER_RENDERER_OPENGL_H
#include "Shader_GL21.h"
#include "renderers/Renderer.h"
#include "renderers/ShaderOpenGL.h"
#if defined(USE_OPENGLES)
#include <GLES3/gl3.h>
@ -28,7 +28,7 @@ public:
static RendererOpenGL* getInstance();
Shader* getShaderProgram(unsigned int shaderID);
ShaderOpenGL* getShaderProgram(unsigned int shaderID);
bool loadShaders() override;
GLenum convertBlendFactor(const BlendFactor BlendFactorFactor);
@ -72,7 +72,7 @@ public:
unsigned char* textureRGBA = nullptr) override;
private:
std::vector<Shader*> mShaderProgramVector;
std::vector<ShaderOpenGL*> mShaderProgramVector;
GLuint mShaderFBO1;
GLuint mShaderFBO2;
GLuint mVertexBuffer1;
@ -82,11 +82,11 @@ private:
GLuint mWhiteTexture;
GLuint mPostProcTexture1;
GLuint mPostProcTexture2;
Shader* mCoreShader;
Shader* mBlurHorizontalShader;
Shader* mBlurVerticalShader;
Shader* mScanlinelShader;
Shader* mLastShader;
ShaderOpenGL* mCoreShader;
ShaderOpenGL* mBlurHorizontalShader;
ShaderOpenGL* mBlurVerticalShader;
ShaderOpenGL* mScanlinelShader;
ShaderOpenGL* mLastShader;
};
#endif // ES_CORE_RENDERER_RENDERER_GL21_H
#endif // ES_CORE_RENDERER_RENDERER_OPENGL_H

View file

@ -1,18 +1,18 @@
// SPDX-License-Identifier: MIT
//
// EmulationStation Desktop Edition
// Shader_GL21.cpp
// ShaderOpenGL.cpp
//
// OpenGL 2.1 GLSL shader functions.
// OpenGL / OpenGL ES shader functions.
//
#include "Shader_GL21.h"
#include "ShaderOpenGL.h"
#include "Log.h"
#include "renderers/Renderer.h"
#include "resources/ResourceManager.h"
Shader::Shader()
ShaderOpenGL::ShaderOpenGL()
: mProgramID {0}
, mShaderMVPMatrix {0}
, mShaderPosition {0}
@ -28,13 +28,13 @@ Shader::Shader()
{
}
Shader::~Shader()
ShaderOpenGL::~ShaderOpenGL()
{
// Delete the shader program when destroyed.
deleteProgram(mProgramID);
}
void Shader::loadShaderFile(const std::string& path, GLenum shaderType)
void ShaderOpenGL::loadShaderFile(const std::string& path, GLenum shaderType)
{
std::string preprocessorDefines;
std::string shaderCode;
@ -59,7 +59,7 @@ void Shader::loadShaderFile(const std::string& path, GLenum shaderType)
mShaderVector.push_back(std::make_tuple(path, preprocessorDefines + shaderCode, shaderType));
}
bool Shader::createProgram()
bool ShaderOpenGL::createProgram()
{
GLint programSuccess;
@ -112,9 +112,9 @@ bool Shader::createProgram()
return true;
}
void Shader::deleteProgram(GLuint programID) { GL_CHECK_ERROR(glDeleteProgram(programID)); }
void ShaderOpenGL::deleteProgram(GLuint programID) { GL_CHECK_ERROR(glDeleteProgram(programID)); }
void Shader::getVariableLocations(GLuint programID)
void ShaderOpenGL::getVariableLocations(GLuint programID)
{
// Some of the variable names are chosen to be compatible with the RetroArch GLSL shaders.
mShaderMVPMatrix = glGetUniformLocation(mProgramID, "MVPMatrix");
@ -130,14 +130,14 @@ void Shader::getVariableLocations(GLuint programID)
mShaderPostProcessing = glGetUniformLocation(mProgramID, "postProcessing");
}
void Shader::setModelViewProjectionMatrix(glm::mat4 mvpMatrix)
void ShaderOpenGL::setModelViewProjectionMatrix(glm::mat4 mvpMatrix)
{
if (mShaderMVPMatrix != GL_INVALID_VALUE && mShaderMVPMatrix != GL_INVALID_OPERATION)
GL_CHECK_ERROR(glUniformMatrix4fv(mShaderMVPMatrix, 1, GL_FALSE,
reinterpret_cast<GLfloat*>(&mvpMatrix)));
}
void Shader::setAttribPointers()
void ShaderOpenGL::setAttribPointers()
{
if (mShaderPosition != -1)
GL_CHECK_ERROR(glVertexAttribPointer(
@ -154,61 +154,61 @@ void Shader::setAttribPointers()
reinterpret_cast<const void*>(offsetof(Renderer::Vertex, color))));
}
void Shader::setTextureSize(std::array<GLfloat, 2> shaderVec2)
void ShaderOpenGL::setTextureSize(std::array<GLfloat, 2> shaderVec2)
{
if (mShaderTextureSize != -1)
GL_CHECK_ERROR(glUniform2f(mShaderTextureSize, shaderVec2[0], shaderVec2[1]));
}
void Shader::setOpacity(GLfloat opacity)
void ShaderOpenGL::setOpacity(GLfloat opacity)
{
if (mShaderOpacity != -1)
GL_CHECK_ERROR(glUniform1f(mShaderOpacity, opacity));
}
void Shader::setSaturation(GLfloat saturation)
void ShaderOpenGL::setSaturation(GLfloat saturation)
{
if (mShaderSaturation != -1)
GL_CHECK_ERROR(glUniform1f(mShaderSaturation, saturation));
}
void Shader::setDimming(GLfloat dimming)
void ShaderOpenGL::setDimming(GLfloat dimming)
{
if (mShaderDimming != -1)
GL_CHECK_ERROR(glUniform1f(mShaderDimming, dimming));
}
void Shader::setBGRAToRGBA(GLboolean BGRAToRGBA)
void ShaderOpenGL::setBGRAToRGBA(GLboolean BGRAToRGBA)
{
if (mShaderBGRAToRGBA != -1)
GL_CHECK_ERROR(glUniform1i(mShaderBGRAToRGBA, BGRAToRGBA ? 1 : 0));
}
void Shader::setFont(GLboolean font)
void ShaderOpenGL::setFont(GLboolean font)
{
if (mShaderFont != -1)
GL_CHECK_ERROR(glUniform1i(mShaderFont, font ? 1 : 0));
}
void Shader::setPostProcessing(GLboolean postProcessing)
void ShaderOpenGL::setPostProcessing(GLboolean postProcessing)
{
if (mShaderPostProcessing != -1)
GL_CHECK_ERROR(glUniform1i(mShaderPostProcessing, postProcessing ? 1 : 0));
}
void Shader::activateShaders()
void ShaderOpenGL::activateShaders()
{
// Install the shader program.
GL_CHECK_ERROR(glUseProgram(mProgramID));
}
void Shader::deactivateShaders()
void ShaderOpenGL::deactivateShaders()
{
// Remove the shader program.
GL_CHECK_ERROR(glUseProgram(0));
}
void Shader::printProgramInfoLog(GLuint programID)
void ShaderOpenGL::printProgramInfoLog(GLuint programID)
{
if (glIsProgram(programID)) {
int logLength;
@ -229,7 +229,7 @@ void Shader::printProgramInfoLog(GLuint programID)
}
}
void Shader::printShaderInfoLog(GLuint shaderID, GLenum shaderType, bool error)
void ShaderOpenGL::printShaderInfoLog(GLuint shaderID, GLenum shaderType, bool error)
{
if (glIsShader(shaderID)) {
int logLength;

View file

@ -1,13 +1,13 @@
// SPDX-License-Identifier: MIT
//
// EmulationStation Desktop Edition
// Shader_GL21.h
// ShaderOpenGL.h
//
// OpenGL 2.1 GLSL shader functions.
// OpenGL / OpenGL ES shader functions.
//
#ifndef ES_CORE_RENDERER_SHADER_GL21_H
#define ES_CORE_RENDERER_SHADER_GL21_H
#ifndef ES_CORE_RENDERER_SHADER_OPENGL_H
#define ES_CORE_RENDERER_SHADER_OPENGL_H
#define GL_GLEXT_PROTOTYPES
@ -49,11 +49,11 @@ static inline void _GLCheckError(const std::string& funcName)
#define GL_CHECK_ERROR(Function) (Function)
#endif
class Shader
class ShaderOpenGL
{
public:
Shader();
~Shader();
ShaderOpenGL();
~ShaderOpenGL();
// Loads the shader source code only, no compilation done at this point.
void loadShaderFile(const std::string& path, GLenum shaderType);
@ -102,4 +102,4 @@ private:
GLint mShaderPostProcessing;
};
#endif // ES_CORE_RENDERER_SHADER_GL21_H
#endif // ES_CORE_RENDERER_SHADER_OPENGL_H