AMIGAOS: Let user select the OpenGL implementation

This commit is contained in:
Le Philousophe 2022-01-24 13:55:16 +01:00
parent a17f10d1dc
commit 41638a09d1
2 changed files with 55 additions and 0 deletions

View File

@ -47,4 +47,58 @@ bool OSystem_AmigaOS::hasFeature(Feature f) {
return OSystem_SDL::hasFeature(f);
}
void OSystem_AmigaOS::initBackend() {
// AmigaOS4 SDL provides two OpenGL implementations (OpenGL 1.3 with miniGL and OpenGL ES with OGLES2)
// This is chosen by setting the profile mask attribute before the first window creation but after init
int force = 0;
if (ConfMan.hasKey("opengl_implementation")) {
Common::String implem = ConfMan.get("opengl_implementation");
if (implem == "gl") {
force = 1;;
} else if (implem == "gles2") {
force = 2;
}
}
// If not forcing, try OGLES2 first
if (!force || force == 2) {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
if (SDL_GL_LoadLibrary(NULL) < 0) {
if (force) {
warning("OpenGL implementation chosen is unsupported, falling back");
force = 0;
}
// SDL doesn't seem to be clean when loading fail
SDL_GL_UnloadLibrary();
SDL_GL_ResetAttributes();
} else {
// Loading succeeded, don't try anything more
force = 2;
}
}
// If not forcing, next try miniGL
if (!force || force == 1) {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
if (SDL_GL_LoadLibrary(NULL) < 0) {
if (force) {
warning("OpenGL implementation chosen is unsupported, falling back");
force = 0;
}
// SDL doesn't seem to be clean when loading fail
SDL_GL_UnloadLibrary();
SDL_GL_ResetAttributes();
} else {
// Loading succeeded, don't try anything more
force = 1;
}
}
OSystem_SDL::initBackend();
}
#endif

View File

@ -32,6 +32,7 @@ public:
bool hasFeature(Feature f) override;
void init() override;
void initBackend() override;
};
#endif