treballant en arreglas els includes de SDL3

This commit is contained in:
2025-07-18 13:58:58 +02:00
parent e4b16a6602
commit 2aaba7938c
77 changed files with 3211 additions and 2458 deletions

View File

@@ -1,9 +1,9 @@
#include "jail_shader.h"
#include <SDL3/SDL_log.h> // Para SDL_LogCategory, SDL_LogError, SDL_LogWarn
#include <SDL3/SDL_rect.h> // Para SDL_FPoint, SDL_Point
#include <cstring> // Para strncmp
#include <stdexcept> // Para runtime_error
#include <vector> // Para vector
#include <SDL3/SDL.h> // Para SDL_LogCategory, SDL_LogError, SDL_LogWarn
#include <SDL3/SDL.h> // Para SDL_FPoint, SDL_Point
#include <cstring> // Para strncmp
#include <stdexcept> // Para runtime_error
#include <vector> // Para vector
#ifdef __APPLE__
#include "CoreFoundation/CoreFoundation.h" // Para Core Foundation en macOS
@@ -75,13 +75,13 @@ namespace shader
#endif
// Función para verificar errores de OpenGL
void checkGLError(const char* operation)
void checkGLError(const char *operation)
{
GLenum error = glGetError();
if (error != GL_NO_ERROR)
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Error OpenGL en %s: 0x%x", operation, error);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Error OpenGL en %s: 0x%x", operation, error);
}
}
@@ -160,7 +160,7 @@ namespace shader
checkGLError("glAttachShader vertex");
glAttachShader(program_id, fragment_shader_id);
checkGLError("glAttachShader fragment");
glLinkProgram(program_id);
checkGLError("glLinkProgram");
@@ -218,34 +218,38 @@ namespace shader
}
// Función para obtener el ID de textura OpenGL desde SDL3
GLuint getTextureID(SDL_Texture* texture)
GLuint getTextureID(SDL_Texture *texture)
{
if (!texture) return DEFAULT_TEXTURE_ID;
if (!texture)
return DEFAULT_TEXTURE_ID;
// Intentar obtener el ID de textura OpenGL desde las propiedades de SDL3
SDL_PropertiesID props = SDL_GetTextureProperties(texture);
GLuint textureId = 0;
// Intentar diferentes nombres de propiedades según la versión de SDL3
textureId = (GLuint)(uintptr_t)SDL_GetPointerProperty(props, "SDL.texture.opengl.texture", nullptr);
// Si la primera no funciona, intentar con el nombre alternativo
if (textureId == 0) {
if (textureId == 0)
{
textureId = (GLuint)(uintptr_t)SDL_GetPointerProperty(props, "texture.opengl.texture", nullptr);
}
// Si aún no funciona, intentar obtener como número
if (textureId == 0) {
if (textureId == 0)
{
textureId = (GLuint)SDL_GetNumberProperty(props, "SDL.texture.opengl.texture", DEFAULT_TEXTURE_ID);
}
// Si ninguna funciona, usar el método manual de bindeo de textura
if (textureId == 0) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"No se pudo obtener el ID de textura OpenGL, usando ID por defecto (%d)", DEFAULT_TEXTURE_ID);
if (textureId == 0)
{
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"No se pudo obtener el ID de textura OpenGL, usando ID por defecto (%d)", DEFAULT_TEXTURE_ID);
textureId = DEFAULT_TEXTURE_ID;
}
return textureId;
}
@@ -254,7 +258,7 @@ namespace shader
shader::win = window;
shader::renderer = SDL_GetRenderer(window);
shader::backBuffer = back_buffer_texture;
if (!shader::renderer)
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: No se pudo obtener el renderer de la ventana.");
@@ -297,7 +301,7 @@ namespace shader
usingOpenGL = false;
return false;
}
usingOpenGL = true;
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Shader system initialized successfully.");
return true;
@@ -315,10 +319,10 @@ namespace shader
// Guardar estados de OpenGL
GLint oldProgramId;
glGetIntegerv(GL_CURRENT_PROGRAM, &oldProgramId);
GLint oldViewport[4];
glGetIntegerv(GL_VIEWPORT, oldViewport);
GLboolean wasTextureEnabled = glIsEnabled(GL_TEXTURE_2D);
GLint oldTextureId;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTextureId);
@@ -435,7 +439,7 @@ namespace shader
programId = INVALID_PROGRAM_ID;
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Programa de shaders liberado.");
}
// Reinicializar variables
win = nullptr;
renderer = nullptr;