1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "common/scummsys.h"
#ifdef __amigaos4__
#include "backends/platform/sdl/amigaos/amigaos.h"
#include "backends/fs/amigaos/amigaos-fs-factory.h"
#include "backends/dialogs/amigaos/amigaos-dialogs.h"
static bool cleanupDone = false;
static void cleanup() {
if (!cleanupDone)
g_system->destroy();
}
OSystem_AmigaOS::~OSystem_AmigaOS() {
cleanupDone = true;
}
void OSystem_AmigaOS::init() {
// Register cleanup function to avoid unfreed signals
if (atexit(cleanup))
warning("Failed to register cleanup function via atexit()");
// Initialize File System Factory
_fsFactory = new AmigaOSFilesystemFactory();
// Invoke parent implementation of this method
OSystem_SDL::init();
#if defined(USE_SYSDIALOGS)
_dialogManager = new AmigaOSDialogManager();
#endif
}
bool OSystem_AmigaOS::hasFeature(Feature f) {
#if defined(USE_SYSDIALOGS)
if (f == kFeatureSystemBrowserDialog)
return true;
#endif
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;
}
}
// First time user defaults
ConfMan.registerDefault("audio_buffer_size", "2048");
ConfMan.registerDefault("extrapath", Common::Path("extras/"));
ConfMan.registerDefault("iconspath", Common::Path("icons/"));
ConfMan.registerDefault("pluginspath", Common::Path("plugins/"));
ConfMan.registerDefault("savepath", Common::Path("saves/"));
ConfMan.registerDefault("themepath", Common::Path("themes/"));
// First time .ini defaults
if (!ConfMan.hasKey("audio_buffer_size")) {
ConfMan.set("audio_buffer_size", "2048");
}
if (!ConfMan.hasKey("extrapath")) {
ConfMan.setPath("extrapath", "extras/");
}
if (!ConfMan.hasKey("iconspath")) {
ConfMan.setPath("iconspath", "icons/");
}
if (!ConfMan.hasKey("pluginspath")) {
ConfMan.setPath("pluginspath", "plugins/");
}
if (!ConfMan.hasKey("savepath")) {
ConfMan.setPath("savepath", "saves/");
}
if (!ConfMan.hasKey("themepath")) {
ConfMan.setPath("themepath", "themes/");
}
OSystem_SDL::initBackend();
}
#endif
|