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
This commit is contained in:
Alejandro Marzini 2010-08-03 02:30:36 +00:00
parent 5439b173b3
commit 498c17655d
3 changed files with 8 additions and 23 deletions

View File

@ -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
}

View File

@ -136,7 +136,6 @@ protected:
bool sizeChanged;
bool needHotswap;
bool needUpdatescreen;
bool newContext;
bool filterChanged;
#ifdef USE_RGB_COLOR
bool formatChanged;

View File

@ -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;