SDL: Remove the Capabilities structure
This commit is contained in:
parent
8ede0e39ca
commit
f00b6fc195
4 changed files with 17 additions and 33 deletions
|
@ -44,12 +44,12 @@
|
||||||
#include "image/bmp.h"
|
#include "image/bmp.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OpenGLSdlGraphics3dManager::OpenGLSdlGraphics3dManager(SdlEventSource *eventSource, SdlWindow *window, const Capabilities &capabilities)
|
OpenGLSdlGraphics3dManager::OpenGLSdlGraphics3dManager(SdlEventSource *eventSource, SdlWindow *window, bool supportsFrameBuffer)
|
||||||
: SdlGraphics3dManager(eventSource, window),
|
: SdlGraphics3dManager(eventSource, window),
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
_glContext(nullptr),
|
_glContext(nullptr),
|
||||||
#endif
|
#endif
|
||||||
_capabilities(capabilities),
|
_supportsFrameBuffer(supportsFrameBuffer),
|
||||||
_overlayVisible(false),
|
_overlayVisible(false),
|
||||||
_overlayScreen(nullptr),
|
_overlayScreen(nullptr),
|
||||||
_overlayBackground(nullptr),
|
_overlayBackground(nullptr),
|
||||||
|
@ -504,7 +504,7 @@ bool OpenGLSdlGraphics3dManager::createOrUpdateGLContext(uint gameWidth, uint ga
|
||||||
|
|
||||||
bool OpenGLSdlGraphics3dManager::shouldRenderToFramebuffer() const {
|
bool OpenGLSdlGraphics3dManager::shouldRenderToFramebuffer() const {
|
||||||
bool engineSupportsArbitraryResolutions = !g_engine || g_engine->hasFeature(Engine::kSupportsArbitraryResolutions);
|
bool engineSupportsArbitraryResolutions = !g_engine || g_engine->hasFeature(Engine::kSupportsArbitraryResolutions);
|
||||||
return !engineSupportsArbitraryResolutions && _capabilities.openGLFrameBuffer;
|
return !engineSupportsArbitraryResolutions && _supportsFrameBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenGLSdlGraphics3dManager::isVSyncEnabled() const {
|
bool OpenGLSdlGraphics3dManager::isVSyncEnabled() const {
|
||||||
|
|
|
@ -41,22 +41,7 @@ namespace OpenGL {
|
||||||
*/
|
*/
|
||||||
class OpenGLSdlGraphics3dManager : public SdlGraphics3dManager {
|
class OpenGLSdlGraphics3dManager : public SdlGraphics3dManager {
|
||||||
public:
|
public:
|
||||||
/**
|
OpenGLSdlGraphics3dManager(SdlEventSource *eventSource, SdlWindow *window, bool supportsFrameBuffer);
|
||||||
* Capabilities of the current device
|
|
||||||
*/
|
|
||||||
struct Capabilities {
|
|
||||||
/**
|
|
||||||
* Is the device capable of rendering to OpenGL framebuffers
|
|
||||||
*/
|
|
||||||
bool openGLFrameBuffer;
|
|
||||||
|
|
||||||
/** Supported levels of MSAA when using the OpenGL renderers */
|
|
||||||
Common::Array<uint> openGLAntiAliasLevels;
|
|
||||||
|
|
||||||
Capabilities() : openGLFrameBuffer(false) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
OpenGLSdlGraphics3dManager(SdlEventSource *eventSource, SdlWindow *window, const Capabilities &capabilities);
|
|
||||||
virtual ~OpenGLSdlGraphics3dManager();
|
virtual ~OpenGLSdlGraphics3dManager();
|
||||||
|
|
||||||
// GraphicsManager API - Features
|
// GraphicsManager API - Features
|
||||||
|
@ -109,7 +94,7 @@ protected:
|
||||||
void deinitializeRenderer();
|
void deinitializeRenderer();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const Capabilities &_capabilities;
|
bool _supportsFrameBuffer;
|
||||||
|
|
||||||
Math::Rect2d _gameRect;
|
Math::Rect2d _gameRect;
|
||||||
|
|
||||||
|
|
|
@ -306,10 +306,10 @@ void OSystem_SDL::initBackend() {
|
||||||
|
|
||||||
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
|
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
|
||||||
void OSystem_SDL::detectFramebufferSupport() {
|
void OSystem_SDL::detectFramebufferSupport() {
|
||||||
_capabilities.openGLFrameBuffer = false;
|
_supportsFrameBuffer = false;
|
||||||
#if defined(USE_GLES2)
|
#if defined(USE_GLES2)
|
||||||
// Framebuffers are always available with GLES2
|
// Framebuffers are always available with GLES2
|
||||||
_capabilities.openGLFrameBuffer = true;
|
_supportsFrameBuffer = true;
|
||||||
#elif !defined(AMIGAOS)
|
#elif !defined(AMIGAOS)
|
||||||
// Spawn a 32x32 window off-screen with a GL context to test if framebuffers are supported
|
// Spawn a 32x32 window off-screen with a GL context to test if framebuffers are supported
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
@ -318,7 +318,7 @@ void OSystem_SDL::detectFramebufferSupport() {
|
||||||
SDL_GLContext glContext = SDL_GL_CreateContext(window);
|
SDL_GLContext glContext = SDL_GL_CreateContext(window);
|
||||||
if (glContext) {
|
if (glContext) {
|
||||||
OpenGLContext.initialize(OpenGL::kOGLContextGL);
|
OpenGLContext.initialize(OpenGL::kOGLContextGL);
|
||||||
_capabilities.openGLFrameBuffer = OpenGLContext.framebufferObjectSupported;
|
_supportsFrameBuffer = OpenGLContext.framebufferObjectSupported;
|
||||||
OpenGLContext.reset();
|
OpenGLContext.reset();
|
||||||
SDL_GL_DeleteContext(glContext);
|
SDL_GL_DeleteContext(glContext);
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ void OSystem_SDL::detectFramebufferSupport() {
|
||||||
SDL_SetVideoMode(32, 32, 0, SDL_OPENGL);
|
SDL_SetVideoMode(32, 32, 0, SDL_OPENGL);
|
||||||
SDL_putenv(const_cast<char *>("SDL_VIDEO_WINDOW_POS=center"));
|
SDL_putenv(const_cast<char *>("SDL_VIDEO_WINDOW_POS=center"));
|
||||||
OpenGLContext.initialize(OpenGL::kOGLContextGL);
|
OpenGLContext.initialize(OpenGL::kOGLContextGL);
|
||||||
_capabilities.openGLFrameBuffer = OpenGLContext.framebufferObjectSupported;
|
_supportsFrameBuffer = OpenGLContext.framebufferObjectSupported;
|
||||||
OpenGLContext.reset();
|
OpenGLContext.reset();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -337,7 +337,7 @@ void OSystem_SDL::detectFramebufferSupport() {
|
||||||
|
|
||||||
void OSystem_SDL::detectAntiAliasingSupport() {
|
void OSystem_SDL::detectAntiAliasingSupport() {
|
||||||
#ifndef NINTENDO_SWITCH
|
#ifndef NINTENDO_SWITCH
|
||||||
_capabilities.openGLAntiAliasLevels.clear();
|
_antiAliasLevels.clear();
|
||||||
|
|
||||||
int requestedSamples = 2;
|
int requestedSamples = 2;
|
||||||
while (requestedSamples <= 32) {
|
while (requestedSamples <= 32) {
|
||||||
|
@ -353,7 +353,7 @@ void OSystem_SDL::detectAntiAliasingSupport() {
|
||||||
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &actualSamples);
|
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &actualSamples);
|
||||||
|
|
||||||
if (actualSamples == requestedSamples) {
|
if (actualSamples == requestedSamples) {
|
||||||
_capabilities.openGLAntiAliasLevels.push_back(requestedSamples);
|
_antiAliasLevels.push_back(requestedSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GL_DeleteContext(glContext);
|
SDL_GL_DeleteContext(glContext);
|
||||||
|
@ -370,7 +370,7 @@ void OSystem_SDL::detectAntiAliasingSupport() {
|
||||||
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &actualSamples);
|
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &actualSamples);
|
||||||
|
|
||||||
if (actualSamples == requestedSamples) {
|
if (actualSamples == requestedSamples) {
|
||||||
_capabilities.openGLAntiAliasLevels.push_back(requestedSamples);
|
_antiAliasLevels.push_back(requestedSamples);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ void OSystem_SDL::setWindowCaption(const Common::U32String &caption) {
|
||||||
|
|
||||||
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
|
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
|
||||||
Common::Array<uint> OSystem_SDL::getSupportedAntiAliasingLevels() const {
|
Common::Array<uint> OSystem_SDL::getSupportedAntiAliasingLevels() const {
|
||||||
return _capabilities.openGLAntiAliasLevels;
|
return _antiAliasLevels;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -777,7 +777,7 @@ bool OSystem_SDL::setGraphicsMode(int mode, uint flags) {
|
||||||
sdlGraphics3dManager->deactivateManager();
|
sdlGraphics3dManager->deactivateManager();
|
||||||
delete sdlGraphics3dManager;
|
delete sdlGraphics3dManager;
|
||||||
}
|
}
|
||||||
_graphicsManager = sdlGraphics3dManager = new OpenGLSdlGraphics3dManager(_eventSource, _window, _capabilities);
|
_graphicsManager = sdlGraphics3dManager = new OpenGLSdlGraphics3dManager(_eventSource, _window, _supportsFrameBuffer);
|
||||||
switchedManager = true;
|
switchedManager = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,9 +36,6 @@
|
||||||
#ifdef USE_DISCORD
|
#ifdef USE_DISCORD
|
||||||
class DiscordPresence;
|
class DiscordPresence;
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
|
|
||||||
#include "backends/graphics3d/openglsdl/openglsdl-graphics3d.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base OSystem class for all SDL ports.
|
* Base OSystem class for all SDL ports.
|
||||||
|
@ -132,7 +129,9 @@ protected:
|
||||||
// Graphics capabilities
|
// Graphics capabilities
|
||||||
void detectFramebufferSupport();
|
void detectFramebufferSupport();
|
||||||
void detectAntiAliasingSupport();
|
void detectAntiAliasingSupport();
|
||||||
OpenGLSdlGraphics3dManager::Capabilities _capabilities;
|
|
||||||
|
bool _supportsFrameBuffer;
|
||||||
|
Common::Array<uint> _antiAliasLevels;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue