From 8b015b65bd31f105ade3eaeb50fec2dc5bb0a5ea Mon Sep 17 00:00:00 2001 From: Laurent Merckx Date: Tue, 20 Feb 2018 06:31:46 +0100 Subject: [PATCH] SDL: Support fullscreen on RPI (#1398) Uses 24 a depth buffer if possible on OpenGL ES --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 4 ++++ graphics/opengl/context.cpp | 4 ++++ graphics/opengl/context.h | 3 +++ graphics/opengl/framebuffer.cpp | 6 +++++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 2e53b5bd6b6..638b75042e5 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -476,10 +476,14 @@ void OpenGLSdlGraphicsManager::showOverlay() { _overlayBackground = nullptr; if (g_engine) { + if (_frameBuffer) + _frameBuffer->detach(); // If there is a game running capture the screen, so that it can be shown "below" the overlay. _overlayBackground = new OpenGL::TiledSurface(_overlayWidth, _overlayHeight, _overlayFormat); Graphics::Surface *background = _overlayBackground->getBackingSurface(); glReadPixels(0, 0, background->w, background->h, GL_RGBA, GL_UNSIGNED_BYTE, background->getPixels()); + if (_frameBuffer) + _frameBuffer->attach(); } } diff --git a/graphics/opengl/context.cpp b/graphics/opengl/context.cpp index 84bd83fe3b8..54756a4d047 100644 --- a/graphics/opengl/context.cpp +++ b/graphics/opengl/context.cpp @@ -50,6 +50,7 @@ void Context::reset() { packedDepthStencilSupported = false; unpackSubImageSupported = false; framebufferObjectMultisampleSupported = false; + OESDepth24 = false; multisampleMaxSamples = -1; } @@ -96,7 +97,10 @@ void Context::initialize(ContextType contextType) { EXTFramebufferMultisample = true; } else if (token == "GL_EXT_framebuffer_blit") { EXTFramebufferBlit = true; + } else if (token == "GL_OES_depth24") { + OESDepth24 = true; } + } int glslVersion = getGLSLVersion(); diff --git a/graphics/opengl/context.h b/graphics/opengl/context.h index b6c75a28e9d..391a7be54cf 100644 --- a/graphics/opengl/context.h +++ b/graphics/opengl/context.h @@ -85,6 +85,9 @@ public: /** Whether specifying a pitch when uploading to textures is available or not */ bool unpackSubImageSupported; + + /** Whether depth component 24 is supported or not */ + bool OESDepth24; int getGLSLVersion() const; }; diff --git a/graphics/opengl/framebuffer.cpp b/graphics/opengl/framebuffer.cpp index df262dfbe09..07cdb3c2859 100644 --- a/graphics/opengl/framebuffer.cpp +++ b/graphics/opengl/framebuffer.cpp @@ -49,6 +49,7 @@ #ifdef USE_GLES2 #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES +#define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES #endif namespace OpenGL { @@ -115,6 +116,9 @@ static void grabFramebufferObjectPointers() { static bool usePackedBuffer() { return OpenGLContext.packedDepthStencilSupported; } +static bool useDepthComponent24() { + return OpenGLContext.OESDepth24; +} FrameBuffer::FrameBuffer(uint width, uint height) : Texture(width, height) { @@ -154,7 +158,7 @@ void FrameBuffer::init() { glBindRenderbuffer(GL_RENDERBUFFER, 0); } else { glBindRenderbuffer(GL_RENDERBUFFER, _renderBuffers[0]); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, _texWidth, _texHeight); + glRenderbufferStorage(GL_RENDERBUFFER, useDepthComponent24() ? GL_DEPTH_COMPONENT24 : GL_DEPTH_COMPONENT16, _texWidth, _texHeight); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _renderBuffers[0]); glBindRenderbuffer(GL_RENDERBUFFER, _renderBuffers[1]);