linter: opengl_shader.cpp

This commit is contained in:
2025-10-24 17:21:17 +02:00
parent 636e4d932a
commit 3cfb65320c
2 changed files with 16 additions and 16 deletions

View File

@@ -15,7 +15,7 @@ OpenGLShader::~OpenGLShader() {
} }
#ifndef __APPLE__ #ifndef __APPLE__
bool OpenGLShader::initGLExtensions() { auto OpenGLShader::initGLExtensions() -> bool {
glCreateShader = (PFNGLCREATESHADERPROC)SDL_GL_GetProcAddress("glCreateShader"); glCreateShader = (PFNGLCREATESHADERPROC)SDL_GL_GetProcAddress("glCreateShader");
glShaderSource = (PFNGLSHADERSOURCEPROC)SDL_GL_GetProcAddress("glShaderSource"); glShaderSource = (PFNGLSHADERSOURCEPROC)SDL_GL_GetProcAddress("glShaderSource");
glCompileShader = (PFNGLCOMPILESHADERPROC)SDL_GL_GetProcAddress("glCompileShader"); glCompileShader = (PFNGLCOMPILESHADERPROC)SDL_GL_GetProcAddress("glCompileShader");
@@ -62,7 +62,7 @@ void OpenGLShader::checkGLError(const char* operation) {
} }
} }
GLuint OpenGLShader::compileShader(const std::string& source, GLenum shader_type) { auto OpenGLShader::compileShader(const std::string& source, GLenum shader_type) -> GLuint {
if (source.empty()) { if (source.empty()) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"ERROR: El código fuente del shader está vacío"); "ERROR: El código fuente del shader está vacío");
@@ -105,7 +105,7 @@ GLuint OpenGLShader::compileShader(const std::string& source, GLenum shader_type
return shader_id; return shader_id;
} }
GLuint OpenGLShader::linkProgram(GLuint vertex_shader, GLuint fragment_shader) { auto OpenGLShader::linkProgram(GLuint vertex_shader, GLuint fragment_shader) -> GLuint {
GLuint program = glCreateProgram(); GLuint program = glCreateProgram();
if (program == 0) { if (program == 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
@@ -211,7 +211,7 @@ void OpenGLShader::createQuadGeometry() {
glBindVertexArray(0); glBindVertexArray(0);
} }
GLuint OpenGLShader::getTextureID(SDL_Texture* texture) { auto OpenGLShader::getTextureID(SDL_Texture* texture) -> GLuint {
if (!texture) return 1; if (!texture) return 1;
SDL_PropertiesID props = SDL_GetTextureProperties(texture); SDL_PropertiesID props = SDL_GetTextureProperties(texture);
@@ -237,10 +237,10 @@ GLuint OpenGLShader::getTextureID(SDL_Texture* texture) {
return texture_id; return texture_id;
} }
bool OpenGLShader::init(SDL_Window* window, auto OpenGLShader::init(SDL_Window* window,
SDL_Texture* texture, SDL_Texture* texture,
const std::string& vertex_source, const std::string& vertex_source,
const std::string& fragment_source) { const std::string& fragment_source) -> bool {
window_ = window; window_ = window;
back_buffer_ = texture; back_buffer_ = texture;
renderer_ = SDL_GetRenderer(window); renderer_ = SDL_GetRenderer(window);

View File

@@ -23,23 +23,23 @@ class OpenGLShader : public ShaderBackend {
OpenGLShader() = default; OpenGLShader() = default;
~OpenGLShader() override; ~OpenGLShader() override;
bool init(SDL_Window* window, auto init(SDL_Window* window,
SDL_Texture* texture, SDL_Texture* texture,
const std::string& vertex_source, const std::string& vertex_source,
const std::string& fragment_source) override; const std::string& fragment_source) -> bool override;
void render() override; void render() override;
void setTextureSize(float width, float height) override; void setTextureSize(float width, float height) override;
void cleanup() override; void cleanup() override final;
bool isHardwareAccelerated() const override { return is_initialized_; } [[nodiscard]] auto isHardwareAccelerated() const -> bool override { return is_initialized_; }
private: private:
// Funciones auxiliares // Funciones auxiliares
bool initGLExtensions(); auto initGLExtensions() -> bool;
GLuint compileShader(const std::string& source, GLenum shader_type); auto compileShader(const std::string& source, GLenum shader_type) -> GLuint;
GLuint linkProgram(GLuint vertex_shader, GLuint fragment_shader); auto linkProgram(GLuint vertex_shader, GLuint fragment_shader) -> GLuint;
void createQuadGeometry(); void createQuadGeometry();
GLuint getTextureID(SDL_Texture* texture); auto getTextureID(SDL_Texture* texture) -> GLuint;
void checkGLError(const char* operation); void checkGLError(const char* operation);
// Estado SDL // Estado SDL
@@ -59,8 +59,8 @@ class OpenGLShader : public ShaderBackend {
// Tamaños // Tamaños
int window_width_ = 0; int window_width_ = 0;
int window_height_ = 0; int window_height_ = 0;
float texture_width_ = 0.0f; float texture_width_ = 0.0F;
float texture_height_ = 0.0f; float texture_height_ = 0.0F;
// Estado // Estado
bool is_initialized_ = false; bool is_initialized_ = false;