feat: Soporte OpenGL ES 3.1 para Raspberry Pi
- Creados shaders GLSL ES 3.1 (crtpi_*_es.glsl) - Detección automática: intenta cargar ES primero, fallback a Desktop - Windows: pide OpenGL 3.3 Core Profile explícitamente - Linux/RPi: deja que SDL elija (usará OpenGL ES si está disponible) - assets.txt actualizado con shaders ES como opcionales Resuelve problema en RPi 5 donde OpenGL 3.3 Core no está soportado pero OpenGL ES 3.1 sí lo está mediante drivers Mesa/VideoCore.
This commit is contained in:
@@ -229,15 +229,37 @@ void Screen::renderInfo() {
|
||||
// Carga el contenido de los archivos GLSL
|
||||
void Screen::loadShaders() {
|
||||
if (vertex_shader_source_.empty()) {
|
||||
const std::string VERTEX_FILE = "crtpi_vertex.glsl";
|
||||
// Detectar si necesitamos OpenGL ES (Raspberry Pi)
|
||||
// Intentar cargar versión ES primero si existe
|
||||
std::string VERTEX_FILE = "crtpi_vertex_es.glsl";
|
||||
auto data = Asset::get()->loadData(VERTEX_FILE);
|
||||
|
||||
if (data.empty()) {
|
||||
// Si no existe versión ES, usar versión Desktop
|
||||
VERTEX_FILE = "crtpi_vertex.glsl";
|
||||
data = Asset::get()->loadData(VERTEX_FILE);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Usando shaders OpenGL Desktop 3.3");
|
||||
} else {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Usando shaders OpenGL ES 3.1 (Raspberry Pi)");
|
||||
}
|
||||
|
||||
if (!data.empty()) {
|
||||
vertex_shader_source_ = std::string(data.begin(), data.end());
|
||||
}
|
||||
}
|
||||
if (fragment_shader_source_.empty()) {
|
||||
const std::string FRAGMENT_FILE = "crtpi_fragment.glsl";
|
||||
// Intentar cargar versión ES primero si existe
|
||||
std::string FRAGMENT_FILE = "crtpi_fragment_es.glsl";
|
||||
auto data = Asset::get()->loadData(FRAGMENT_FILE);
|
||||
|
||||
if (data.empty()) {
|
||||
// Si no existe versión ES, usar versión Desktop
|
||||
FRAGMENT_FILE = "crtpi_fragment.glsl";
|
||||
data = Asset::get()->loadData(FRAGMENT_FILE);
|
||||
}
|
||||
|
||||
if (!data.empty()) {
|
||||
fragment_shader_source_ = std::string(data.begin(), data.end());
|
||||
}
|
||||
@@ -330,10 +352,19 @@ auto Screen::initSDLVideo() -> bool {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Warning: Failed to set OpenGL hint!");
|
||||
}
|
||||
// Configurar contexto OpenGL 3.3 Core Profile
|
||||
// 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
|
||||
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");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Crear ventana
|
||||
|
||||
Reference in New Issue
Block a user