Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
/* 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/>.
*
*/
#define FORBIDDEN_SYMBOL_ALLOW_ALL
#include "backends/graphics/ios/ios-graphics.h"
#include "backends/graphics/ios/renderbuffer.h"
#include "backends/graphics/opengl/pipelines/pipeline.h"
#include "backends/platform/ios7/ios7_osys_main.h"
iOSGraphicsManager::iOSGraphicsManager() :
_insets{0, 0, 0, 0} {
initSurface();
}
iOSGraphicsManager::~iOSGraphicsManager() {
deinitSurface();
}
void iOSGraphicsManager::initSurface() {
OSystem_iOS7 *sys = dynamic_cast<OSystem_iOS7 *>(g_system);
// Create OpenGL context
GLuint rbo = sys->createOpenGLContext();
notifyContextCreate(OpenGL::kContextGLES2,
new OpenGL::RenderbufferTarget(rbo),
OpenGL::Texture::getRGBAPixelFormat(),
OpenGL::Texture::getRGBAPixelFormat());
handleResize(sys->getScreenWidth(), sys->getScreenHeight());
_old_touch_mode = kTouchModeTouchpad;
// not in 3D, not in GUI
sys->applyTouchSettings(false, false);
}
void iOSGraphicsManager::deinitSurface() {
notifyContextDestroy();
dynamic_cast<OSystem_iOS7 *>(g_system)->destroyOpenGLContext();
}
void iOSGraphicsManager::notifyResize(const int width, const int height) {
handleResize(width, height);
}
bool iOSGraphicsManager::loadVideoMode(uint requestedWidth, uint requestedHeight, bool resizable, int antialiasing) {
// As GLES2 provides FBO, OpenGL graphics manager must ask us for a resizable surface
assert(resizable);
if (antialiasing != 0) {
warning("Requesting antialiased video mode while not available");
}
/* The iOS and tvOS video modes are always full screen */
return true;
}
void iOSGraphicsManager::showOverlay(bool inGUI) {
if (_overlayVisible && inGUI == _overlayInGUI)
return;
// Don't change touch mode when not changing mouse coordinates
if (inGUI) {
_old_touch_mode = dynamic_cast<OSystem_iOS7 *>(g_system)->getCurrentTouchMode();
// not in 3D, in overlay
dynamic_cast<OSystem_iOS7 *>(g_system)->applyTouchSettings(false, true);
} else if (_overlayInGUI) {
// Restore touch mode active before overlay was shown
dynamic_cast<OSystem_iOS7 *>(g_system)->setCurrentTouchMode(static_cast<TouchMode>(_old_touch_mode));
}
OpenGL::OpenGLGraphicsManager::showOverlay(inGUI);
}
void iOSGraphicsManager::hideOverlay() {
if (_overlayInGUI) {
// Restore touch mode active before overlay was shown
dynamic_cast<OSystem_iOS7 *>(g_system)->setCurrentTouchMode(static_cast<TouchMode>(_old_touch_mode));
}
OpenGL::OpenGLGraphicsManager::hideOverlay();
}
float iOSGraphicsManager::getHiDPIScreenFactor() const {
return dynamic_cast<OSystem_iOS7 *>(g_system)->getSystemHiDPIScreenFactor();
}
void iOSGraphicsManager::refreshScreen() {
dynamic_cast<OSystem_iOS7 *>(g_system)->refreshScreen();
}
bool iOSGraphicsManager::notifyMousePosition(Common::Point &mouse) {
mouse.x = CLIP<int16>(mouse.x, _activeArea.drawRect.left, _activeArea.drawRect.right);
mouse.y = CLIP<int16>(mouse.y, _activeArea.drawRect.top, _activeArea.drawRect.bottom);
setMousePosition(mouse.x, mouse.y);
mouse = convertWindowToVirtual(mouse.x, mouse.y);
return true;
}

View File

@@ -0,0 +1,62 @@
/* 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/>.
*
*/
#ifndef BACKENDS_GRAPHICS_IOS_IOS_GRAPHICS_H
#define BACKENDS_GRAPHICS_IOS_IOS_GRAPHICS_H
#include "common/scummsys.h"
#include <OpenGLES/ES2/gl.h>
#include "backends/graphics/opengl/opengl-graphics.h"
class iOSGraphicsManager :
public OpenGL::OpenGLGraphicsManager {
public:
iOSGraphicsManager();
virtual ~iOSGraphicsManager();
void initSurface();
void deinitSurface();
void notifyResize(const int width, const int height);
bool notifyMousePosition(Common::Point &mouse);
Common::Point getMousePosition() { return Common::Point(_cursorX, _cursorY); }
float getHiDPIScreenFactor() const override;
void setSafeAreaInsets(int l, int r, int t, int b) { _insets.left = l; _insets.top = t; _insets.right = r; _insets.bottom = b; }
WindowedGraphicsManager::Insets getSafeAreaInsets() const override { return _insets; }
protected:
void setSystemMousePosition(const int x, const int y) override {}
bool loadVideoMode(uint requestedWidth, uint requestedHeight, bool resizable, int antialiasing) override;
void showOverlay(bool inGUI) override;
void hideOverlay() override;
void refreshScreen() override;
int _old_touch_mode;
WindowedGraphicsManager::Insets _insets;
};
#endif

View File

@@ -0,0 +1,92 @@
/* 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 "backends/graphics/ios/renderbuffer.h"
#include "graphics/opengl/debug.h"
namespace OpenGL {
//
// Render to backbuffer target implementation
//
RenderbufferTarget::RenderbufferTarget(GLuint renderbufferID)
: _glRBO(renderbufferID), _glFBO(0) {
}
RenderbufferTarget::~RenderbufferTarget() {
GL_CALL_SAFE(glDeleteFramebuffers, (1, &_glFBO));
}
void RenderbufferTarget::activateInternal() {
bool needUpdate = false;
// Allocate framebuffer object if necessary.
if (!_glFBO) {
GL_CALL(glGenFramebuffers(1, &_glFBO));
needUpdate = true;
}
// Attach FBO to rendering context.
GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, _glFBO));
// Attach render buffer to newly created FBO.
if (needUpdate) {
GL_CALL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _glRBO));
}
}
bool RenderbufferTarget::setSize(uint width, uint height) {
// Set viewport dimensions.
_viewport[0] = 0;
_viewport[1] = 0;
_viewport[2] = width;
_viewport[3] = height;
// Setup orthogonal projection matrix.
_projectionMatrix(0, 0) = 2.0f / width;
_projectionMatrix(0, 1) = 0.0f;
_projectionMatrix(0, 2) = 0.0f;
_projectionMatrix(0, 3) = 0.0f;
_projectionMatrix(1, 0) = 0.0f;
_projectionMatrix(1, 1) = -2.0f / height;
_projectionMatrix(1, 2) = 0.0f;
_projectionMatrix(1, 3) = 0.0f;
_projectionMatrix(2, 0) = 0.0f;
_projectionMatrix(2, 1) = 0.0f;
_projectionMatrix(2, 2) = 0.0f;
_projectionMatrix(2, 3) = 0.0f;
_projectionMatrix(3, 0) = -1.0f;
_projectionMatrix(3, 1) = 1.0f;
_projectionMatrix(3, 2) = 0.0f;
_projectionMatrix(3, 3) = 1.0f;
// Directly apply changes when we are active.
if (isActive()) {
applyViewport();
applyProjectionMatrix();
}
return true;
}
} // End of namespace OpenGL

View File

@@ -0,0 +1,55 @@
/* 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/>.
*
*/
#ifndef BACKENDS_GRAPHICS_IOS_RENDERBUFFER_H
#define BACKENDS_GRAPHICS_IOS_RENDERBUFFER_H
#include "backends/graphics/opengl/framebuffer.h"
namespace OpenGL {
/**
* Render to renderbuffer framebuffer implementation.
*
* This target allows to render to a renderbuffer, which can then be used as
* a rendering source like expected on iOS.
*/
class RenderbufferTarget : public Framebuffer {
public:
RenderbufferTarget(GLuint renderbufferID);
~RenderbufferTarget() override;
/**
* Set size of the render target.
*/
bool setSize(uint width, uint height) override;
protected:
void activateInternal() override;
private:
GLuint _glRBO;
GLuint _glFBO;
};
} // End of namespace OpenGL
#endif