feat: Forzar OpenGL ES en Linux/RPi mediante SDL hint
- Windows: hint 'opengl' + OpenGL 3.3 Core Profile - Linux/RPi: hint 'opengles2,opengl' (intenta ES, fallback a Desktop) - SDL_WINDOW_OPENGL flag es genérico, funciona con ambos También lazy initialization de shaders para evitar textura vacía.
This commit is contained in:
@@ -55,8 +55,8 @@ Screen::Screen()
|
||||
setDebugInfoEnabled(true);
|
||||
#endif
|
||||
|
||||
// Inicializa los shaders si están activos en opciones
|
||||
initShaders();
|
||||
// Los shaders se inicializarán lazy en el primer render si están activos
|
||||
// Esto evita problemas con texturas vacías al inicio
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -96,8 +96,19 @@ void Screen::renderPresent() {
|
||||
SDL_SetRenderTarget(renderer_, nullptr);
|
||||
clean();
|
||||
|
||||
if (Options::video.shaders && shader_backend_) {
|
||||
shader_backend_->render();
|
||||
if (Options::video.shaders) {
|
||||
// Lazy initialization: inicializar shaders la primera vez que se usan
|
||||
if (!shader_backend_) {
|
||||
initShaders();
|
||||
}
|
||||
|
||||
if (shader_backend_) {
|
||||
shader_backend_->render();
|
||||
} else {
|
||||
// Fallback si falla la inicialización
|
||||
SDL_RenderTexture(renderer_, game_canvas_, nullptr, nullptr);
|
||||
SDL_RenderPresent(renderer_);
|
||||
}
|
||||
} else {
|
||||
SDL_RenderTexture(renderer_, game_canvas_, nullptr, nullptr);
|
||||
SDL_RenderPresent(renderer_);
|
||||
@@ -344,22 +355,25 @@ auto Screen::initSDLVideo() -> bool {
|
||||
"Warning: Failed to set Metal hint!");
|
||||
}
|
||||
#else
|
||||
// Configurar hint de render driver
|
||||
#ifdef _WIN32
|
||||
// Windows: Usar OpenGL Desktop
|
||||
if (!SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl")) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Warning: Failed to set OpenGL hint!");
|
||||
}
|
||||
// Configurar contexto OpenGL
|
||||
// En Raspberry Pi, NO pedir Core Profile porque solo soporta OpenGL ES
|
||||
// SDL elegirá automáticamente OpenGL ES 3.1 si está disponible
|
||||
#ifdef _WIN32
|
||||
// Solo en Windows pedimos explícitamente OpenGL 3.3 Core Profile
|
||||
// Pedir explícitamente OpenGL 3.3 Core Profile
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Solicitando OpenGL 3.3 Core Profile");
|
||||
#else
|
||||
// Linux/RPi: dejar que SDL elija (probablemente OpenGL ES)
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Usando OpenGL por defecto del sistema");
|
||||
// Linux/RPi: Intentar OpenGL ES primero
|
||||
if (!SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles2,opengl")) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Warning: Failed to set OpenGL ES hint!");
|
||||
}
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Solicitando OpenGL ES (fallback a OpenGL Desktop)");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user