diff options
author | Alejandro Marzini | 2010-07-19 23:58:48 +0000 |
---|---|---|
committer | Alejandro Marzini | 2010-07-19 23:58:48 +0000 |
commit | f6e04fe03bfc5177229cf0ff29b850925cece2e1 (patch) | |
tree | 9f45231362ef7ecab819b5ae7023c63d6c1bda1b /backends/graphics/opengl/opengl-graphics.cpp | |
parent | 6f70a303bcda770b831e4d22b119f814d2a3a29d (diff) | |
download | scummvm-rg350-f6e04fe03bfc5177229cf0ff29b850925cece2e1.tar.gz scummvm-rg350-f6e04fe03bfc5177229cf0ff29b850925cece2e1.tar.bz2 scummvm-rg350-f6e04fe03bfc5177229cf0ff29b850925cece2e1.zip |
OPENGL: Fix adjustment of mouse coordinates when screen is resized and scaled.
svn-id: r51046
Diffstat (limited to 'backends/graphics/opengl/opengl-graphics.cpp')
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 54be9c408c..413f4221f1 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -134,7 +134,8 @@ void OpenGLGraphicsManager::initSize(uint width, uint height, const Graphics::Pi //avoid redundant format changes Graphics::PixelFormat newFormat; if (!format) - newFormat = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);//Graphics::PixelFormat::createFormatCLUT8(); + newFormat = Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0); + //newFormat = Graphics::PixelFormat::createFormatCLUT8(); else newFormat = *format; @@ -551,7 +552,7 @@ void OpenGLGraphicsManager::internUpdateScreen() { if (_cursorNeedsRedraw) refreshCursor(); _cursorTexture->drawTexture(_cursorState.x - _cursorState.hotX, - _cursorState.y - _cursorState.hotY, _cursorState.w, _cursorState.h); + _cursorState.y - _cursorState.hotY, _cursorState.w, _cursorState.h); } } @@ -568,16 +569,20 @@ void OpenGLGraphicsManager::initGL() { CHECK_GL_ERROR( glShadeModel(GL_FLAT) ); CHECK_GL_ERROR( glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST) ); + // Setup alpha blend (For overlay and cursor) CHECK_GL_ERROR( glEnable(GL_BLEND) ); CHECK_GL_ERROR( glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ); + // Enable rendering with vertex and coord arrays CHECK_GL_ERROR( glEnableClientState(GL_VERTEX_ARRAY) ); CHECK_GL_ERROR( glEnableClientState(GL_TEXTURE_COORD_ARRAY) ); CHECK_GL_ERROR( glEnable(GL_TEXTURE_2D) ); + // Setup the GL viewport CHECK_GL_ERROR( glViewport(0, 0, _videoMode.hardwareWidth, _videoMode.hardwareHeight) ); + // Setup coordinates system CHECK_GL_ERROR( glMatrixMode(GL_PROJECTION) ); CHECK_GL_ERROR( glLoadIdentity() ); CHECK_GL_ERROR( glOrtho(0, _videoMode.hardwareWidth, _videoMode.hardwareHeight, 0, -1, 1) ); @@ -586,6 +591,7 @@ void OpenGLGraphicsManager::initGL() { } bool OpenGLGraphicsManager::loadGFXMode() { + // Initialize OpenGL settings initGL(); if (!_gameTexture) { @@ -645,6 +651,10 @@ void OpenGLGraphicsManager::adjustMouseEvent(const Common::Event &event) { //if (_videoMode.aspectRatioCorrection) // newEvent.mouse.y = aspect2Real(newEvent.mouse.y); } + if (_videoMode.hardwareWidth != _videoMode.overlayWidth) + newEvent.mouse.x /= (float)_videoMode.hardwareWidth / _videoMode.overlayWidth; + if (_videoMode.hardwareHeight != _videoMode.overlayHeight) + newEvent.mouse.y /= (float)_videoMode.hardwareHeight / _videoMode.overlayHeight; g_system->getEventManager()->pushEvent(newEvent); } } @@ -652,7 +662,7 @@ void OpenGLGraphicsManager::adjustMouseEvent(const Common::Event &event) { bool OpenGLGraphicsManager::notifyEvent(const Common::Event &event) { switch (event.type) { case Common::EVENT_MOUSEMOVE: - if (event.synthetic) + if (!event.synthetic) setMousePos(event.mouse.x, event.mouse.y); case Common::EVENT_LBUTTONDOWN: case Common::EVENT_RBUTTONDOWN: |