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);
|
setDebugInfoEnabled(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Inicializa los shaders si están activos en opciones
|
// Los shaders se inicializarán lazy en el primer render si están activos
|
||||||
initShaders();
|
// Esto evita problemas con texturas vacías al inicio
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@@ -96,8 +96,19 @@ void Screen::renderPresent() {
|
|||||||
SDL_SetRenderTarget(renderer_, nullptr);
|
SDL_SetRenderTarget(renderer_, nullptr);
|
||||||
clean();
|
clean();
|
||||||
|
|
||||||
if (Options::video.shaders && shader_backend_) {
|
if (Options::video.shaders) {
|
||||||
shader_backend_->render();
|
// 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 {
|
} else {
|
||||||
SDL_RenderTexture(renderer_, game_canvas_, nullptr, nullptr);
|
SDL_RenderTexture(renderer_, game_canvas_, nullptr, nullptr);
|
||||||
SDL_RenderPresent(renderer_);
|
SDL_RenderPresent(renderer_);
|
||||||
@@ -344,22 +355,25 @@ auto Screen::initSDLVideo() -> bool {
|
|||||||
"Warning: Failed to set Metal hint!");
|
"Warning: Failed to set Metal hint!");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
// Configurar hint de render driver
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Windows: Usar OpenGL Desktop
|
||||||
if (!SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl")) {
|
if (!SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl")) {
|
||||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Warning: Failed to set OpenGL hint!");
|
"Warning: Failed to set OpenGL hint!");
|
||||||
}
|
}
|
||||||
// Configurar contexto OpenGL
|
// Pedir explícitamente OpenGL 3.3 Core Profile
|
||||||
// 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
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_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_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Solicitando OpenGL 3.3 Core Profile");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Solicitando OpenGL 3.3 Core Profile");
|
||||||
#else
|
#else
|
||||||
// Linux/RPi: dejar que SDL elija (probablemente OpenGL ES)
|
// Linux/RPi: Intentar OpenGL ES primero
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Usando OpenGL por defecto del sistema");
|
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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user