aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/opengl
diff options
context:
space:
mode:
authorBastien Bouclet2017-08-04 10:25:22 +0200
committerBastien Bouclet2017-08-05 08:36:32 +0200
commit8e4697946e4bb1cbb42897f9b052ec040be5dd06 (patch)
tree5dfb65afc3d4819f1c4de7807bdf9e91e8e86ad8 /backends/graphics/opengl
parentd6de8e52c3e6b8d53608e08eb3dec31a4dd6b172 (diff)
downloadscummvm-rg350-8e4697946e4bb1cbb42897f9b052ec040be5dd06.tar.gz
scummvm-rg350-8e4697946e4bb1cbb42897f9b052ec040be5dd06.tar.bz2
scummvm-rg350-8e4697946e4bb1cbb42897f9b052ec040be5dd06.zip
OPENGL: Always clear the whole backbuffer
Previously we were clearing the whole backbuffer for 3 frames after a window size change, and then only clearing the game area. This assumes the OpenGL driver uses at most 3 render buffer and uses them in sequential order. This does not seem to be the case on Linux when using an Intel integrated GPU. Instead we now clear the whole backbuffer on each frame to make sure there are no leftovers remaining on the screen. All semi-recent GPUs should have hardware clear anyway so this should not impact negatively performance. Possibly fixes #10025.
Diffstat (limited to 'backends/graphics/opengl')
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp46
-rw-r--r--backends/graphics/opengl/opengl-graphics.h5
2 files changed, 14 insertions, 37 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index fc27270648..28ca110d91 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -60,7 +60,7 @@ OpenGLGraphicsManager::OpenGLGraphicsManager()
_cursorX(0), _cursorY(0), _cursorDisplayX(0),_cursorDisplayY(0), _cursorHotspotX(0), _cursorHotspotY(0),
_cursorHotspotXScaled(0), _cursorHotspotYScaled(0), _cursorWidthScaled(0), _cursorHeightScaled(0),
_cursorKeyColor(0), _cursorVisible(false), _cursorDontScale(false), _cursorPaletteEnabled(false),
- _forceRedraw(false), _scissorOverride(3)
+ _forceRedraw(false)
#ifdef USE_OSD
, _osdMessageChangeRequest(false), _osdMessageAlpha(0), _osdMessageFadeStartTime(0), _osdMessageSurface(nullptr),
_osdIconSurface(nullptr)
@@ -381,10 +381,8 @@ void OpenGLGraphicsManager::updateScreen() {
}
#ifdef USE_OSD
- {
- if (_osdMessageChangeRequest) {
- osdMessageUpdateSurface();
- }
+ if (_osdMessageChangeRequest) {
+ osdMessageUpdateSurface();
}
if (_osdIconSurface) {
@@ -413,18 +411,13 @@ void OpenGLGraphicsManager::updateScreen() {
_overlay->updateGLTexture();
// Clear the screen buffer.
- if (_scissorOverride && !_overlayVisible) {
- // In certain cases we need to assure that the whole screen area is
- // cleared. For example, when switching from overlay visible to
- // invisible, we need to assure that all contents are cleared to
- // properly remove all overlay contents.
- _backBuffer.enableScissorTest(false);
- GL_CALL(glClear(GL_COLOR_BUFFER_BIT));
- _backBuffer.enableScissorTest(true);
+ GL_CALL(glClear(GL_COLOR_BUFFER_BIT));
- --_scissorOverride;
- } else {
- GL_CALL(glClear(GL_COLOR_BUFFER_BIT));
+ if (!_overlayVisible) {
+ // The scissor test is enabled to:
+ // - Clip the cursor to the game screen
+ // - Clip the game screen when the shake offset is non-zero
+ _backBuffer.enableScissorTest(true);
}
const GLfloat shakeOffset = _gameScreenShakeOffset * (GLfloat)_displayHeight / _gameScreen->getHeight();
@@ -449,6 +442,10 @@ void OpenGLGraphicsManager::updateScreen() {
_cursorWidthScaled, _cursorHeightScaled);
}
+ if (!_overlayVisible) {
+ _backBuffer.enableScissorTest(false);
+ }
+
#ifdef USE_OSD
// Fourth step: Draw the OSD.
if (_osdMessageSurface) {
@@ -530,9 +527,6 @@ void OpenGLGraphicsManager::showOverlay() {
_overlayVisible = true;
_forceRedraw = true;
- // Allow drawing inside full screen area.
- _backBuffer.enableScissorTest(false);
-
// Update cursor position.
setMousePosition(_cursorX, _cursorY);
}
@@ -541,10 +535,6 @@ void OpenGLGraphicsManager::hideOverlay() {
_overlayVisible = false;
_forceRedraw = true;
- // Limit drawing to screen area.
- _backBuffer.enableScissorTest(true);
- _scissorOverride = 3;
-
// Update cursor position.
setMousePosition(_cursorX, _cursorY);
}
@@ -961,15 +951,9 @@ void OpenGLGraphicsManager::notifyContextCreate(const Graphics::PixelFormat &def
_backBuffer.setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// Setup alpha blend (for overlay and cursor).
_backBuffer.enableBlend(true);
- // Setup scissor state accordingly.
- _backBuffer.enableScissorTest(!_overlayVisible);
g_context.getActivePipeline()->setFramebuffer(&_backBuffer);
- // Clear the whole screen for the first three frames to assure any
- // leftovers are cleared.
- _scissorOverride = 3;
-
// We use a "pack" alignment (when reading from textures) to 4 here,
// since the only place where we really use it is the BMP screenshot
// code and that requires the same alignment too.
@@ -1246,14 +1230,12 @@ void OpenGLGraphicsManager::recalculateDisplayArea() {
_displayY = (_outputScreenHeight - _displayHeight) / 2;
// Setup drawing limitation for game graphics.
- // This invovles some trickery because OpenGL's viewport coordinate system
+ // This involves some trickery because OpenGL's viewport coordinate system
// is upside down compared to ours.
_backBuffer.setScissorBox(_displayX,
_outputScreenHeight - _displayHeight - _displayY,
_displayWidth,
_displayHeight);
- // Clear the whole screen for the first three frames to remove leftovers.
- _scissorOverride = 3;
// Update the cursor position to adjust for new display area.
setMousePosition(_cursorX, _cursorY);
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index f5f4cab305..e02137bba7 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -533,11 +533,6 @@ private:
*/
bool _forceRedraw;
- /**
- * Number of frames glClear shall ignore scissor testing.
- */
- uint _scissorOverride;
-
#ifdef USE_OSD
//
// OSD