SDL: Support fullscreen on RPI (#1398)

Uses 24 a depth buffer if possible on OpenGL ES
This commit is contained in:
Laurent Merckx 2018-02-20 06:31:46 +01:00 committed by Bastien Bouclet
parent 43bc857b05
commit 8b015b65bd
4 changed files with 16 additions and 1 deletions

View file

@ -476,10 +476,14 @@ void OpenGLSdlGraphicsManager::showOverlay() {
_overlayBackground = nullptr; _overlayBackground = nullptr;
if (g_engine) { 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. // 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); _overlayBackground = new OpenGL::TiledSurface(_overlayWidth, _overlayHeight, _overlayFormat);
Graphics::Surface *background = _overlayBackground->getBackingSurface(); Graphics::Surface *background = _overlayBackground->getBackingSurface();
glReadPixels(0, 0, background->w, background->h, GL_RGBA, GL_UNSIGNED_BYTE, background->getPixels()); glReadPixels(0, 0, background->w, background->h, GL_RGBA, GL_UNSIGNED_BYTE, background->getPixels());
if (_frameBuffer)
_frameBuffer->attach();
} }
} }

View file

@ -50,6 +50,7 @@ void Context::reset() {
packedDepthStencilSupported = false; packedDepthStencilSupported = false;
unpackSubImageSupported = false; unpackSubImageSupported = false;
framebufferObjectMultisampleSupported = false; framebufferObjectMultisampleSupported = false;
OESDepth24 = false;
multisampleMaxSamples = -1; multisampleMaxSamples = -1;
} }
@ -96,7 +97,10 @@ void Context::initialize(ContextType contextType) {
EXTFramebufferMultisample = true; EXTFramebufferMultisample = true;
} else if (token == "GL_EXT_framebuffer_blit") { } else if (token == "GL_EXT_framebuffer_blit") {
EXTFramebufferBlit = true; EXTFramebufferBlit = true;
} else if (token == "GL_OES_depth24") {
OESDepth24 = true;
} }
} }
int glslVersion = getGLSLVersion(); int glslVersion = getGLSLVersion();

View file

@ -85,6 +85,9 @@ public:
/** Whether specifying a pitch when uploading to textures is available or not */ /** Whether specifying a pitch when uploading to textures is available or not */
bool unpackSubImageSupported; bool unpackSubImageSupported;
/** Whether depth component 24 is supported or not */
bool OESDepth24;
int getGLSLVersion() const; int getGLSLVersion() const;
}; };

View file

@ -49,6 +49,7 @@
#ifdef USE_GLES2 #ifdef USE_GLES2
#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
#define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES
#endif #endif
namespace OpenGL { namespace OpenGL {
@ -115,6 +116,9 @@ static void grabFramebufferObjectPointers() {
static bool usePackedBuffer() { static bool usePackedBuffer() {
return OpenGLContext.packedDepthStencilSupported; return OpenGLContext.packedDepthStencilSupported;
} }
static bool useDepthComponent24() {
return OpenGLContext.OESDepth24;
}
FrameBuffer::FrameBuffer(uint width, uint height) : FrameBuffer::FrameBuffer(uint width, uint height) :
Texture(width, height) { Texture(width, height) {
@ -154,7 +158,7 @@ void FrameBuffer::init() {
glBindRenderbuffer(GL_RENDERBUFFER, 0); glBindRenderbuffer(GL_RENDERBUFFER, 0);
} else { } else {
glBindRenderbuffer(GL_RENDERBUFFER, _renderBuffers[0]); 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]); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _renderBuffers[0]);
glBindRenderbuffer(GL_RENDERBUFFER, _renderBuffers[1]); glBindRenderbuffer(GL_RENDERBUFFER, _renderBuffers[1]);