aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Marzini2010-08-03 02:30:36 +0000
committerAlejandro Marzini2010-08-03 02:30:36 +0000
commit498c17655dbc448ed8bdd8146b0ca1dd0dfc9463 (patch)
treea1c4e2699fe8aed5e410e42e16580ec9ce3485fb
parent5439b173b3df4580f9a3ea50b145779024dd5543 (diff)
downloadscummvm-rg350-498c17655dbc448ed8bdd8146b0ca1dd0dfc9463.tar.gz
scummvm-rg350-498c17655dbc448ed8bdd8146b0ca1dd0dfc9463.tar.bz2
scummvm-rg350-498c17655dbc448ed8bdd8146b0ca1dd0dfc9463.zip
OPENGL: Refresh OpenGL textures on all loadGFX() calls.
OpenGL context may be destroyed after calling SDL_SetVideoMode, so it is better to always recreate the textures. svn-id: r51675
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp21
-rw-r--r--backends/graphics/opengl/opengl-graphics.h1
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.cpp9
3 files changed, 8 insertions, 23 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index dfb020c256..ddace8f3a4 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -230,7 +230,6 @@ void OpenGLGraphicsManager::beginGFXTransaction() {
_transactionDetails.sizeChanged = false;
_transactionDetails.needHotswap = false;
_transactionDetails.needUpdatescreen = false;
- _transactionDetails.newContext = false;
_transactionDetails.filterChanged = false;
#ifdef USE_RGB_COLOR
_transactionDetails.formatChanged = false;
@@ -1075,7 +1074,8 @@ void OpenGLGraphicsManager::loadTextures() {
getGLPixelFormat(Graphics::PixelFormat::createFormatCLUT8(), bpp, intformat, format, type);
#endif
_gameTexture = new GLTexture(bpp, intformat, format, type);
- }
+ } else
+ _gameTexture->refresh();
_overlayFormat = Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0);
@@ -1086,24 +1086,19 @@ void OpenGLGraphicsManager::loadTextures() {
GLenum type;
getGLPixelFormat(_overlayFormat, bpp, intformat, format, type);
_overlayTexture = new GLTexture(bpp, intformat, format, type);
- }
+ } else
+ _overlayTexture->refresh();
if (!_cursorTexture)
_cursorTexture = new GLTexture(4, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
+ else
+ _cursorTexture->refresh();
GLint filter = _videoMode.antialiasing ? GL_LINEAR : GL_NEAREST;
_gameTexture->setFilter(filter);
_overlayTexture->setFilter(filter);
_cursorTexture->setFilter(filter);
- if (_transactionDetails.newContext || _transactionDetails.filterChanged) {
- // If the context was destroyed or it is needed to change the texture filter
- // we need to recreate the textures
- _gameTexture->refresh();
- _overlayTexture->refresh();
- _cursorTexture->refresh();
- }
-
// Allocate texture memory and finish refreshing
_gameTexture->allocBuffer(_videoMode.screenWidth, _videoMode.screenHeight);
_overlayTexture->allocBuffer(_videoMode.overlayWidth, _videoMode.overlayHeight);
@@ -1127,9 +1122,9 @@ void OpenGLGraphicsManager::loadTextures() {
#ifdef USE_OSD
if (!_osdTexture)
_osdTexture = new GLTexture(2, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1);
-
- if (_transactionDetails.newContext || _transactionDetails.filterChanged)
+ else
_osdTexture->refresh();
+
_osdTexture->allocBuffer(_videoMode.overlayWidth, _videoMode.overlayHeight);
#endif
}
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 9672252deb..60c569726f 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -136,7 +136,6 @@ protected:
bool sizeChanged;
bool needHotswap;
bool needUpdatescreen;
- bool newContext;
bool filterChanged;
#ifdef USE_RGB_COLOR
bool formatChanged;
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 1904ab674f..cdaf3a3ebd 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -357,11 +357,6 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() {
// Failed setuping a fullscreen mode
return false;
- // If changing to any fullscreen mode or from fullscreen,
- // the OpenGL context is destroyed
- if (_oldVideoMode.fullscreen || _videoMode.fullscreen)
- _transactionDetails.newContext = true;
-
// Create our window
_hwscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 32,
_videoMode.fullscreen ? (SDL_FULLSCREEN | SDL_OPENGL) : (SDL_OPENGL | SDL_RESIZABLE)
@@ -586,10 +581,6 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
_videoMode.hardwareHeight = event.mouse.y;
_screenResized = true;
_transactionDetails.sizeChanged = true;
- // The OpenGL context is not always destroyed during resizing,
- // however it is better to waste some time recreating it than
- // getting a blank screen
- _transactionDetails.newContext = true;
endGFXTransaction();
return true;