[Scummvm-cvs-logs] SF.net SVN: scummvm:[51046] scummvm/branches/gsoc2010-opengl/backends/ graphics/opengl

vgvgf at users.sourceforge.net vgvgf at users.sourceforge.net
Tue Jul 20 01:58:49 CEST 2010


Revision: 51046
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51046&view=rev
Author:   vgvgf
Date:     2010-07-19 23:58:48 +0000 (Mon, 19 Jul 2010)

Log Message:
-----------
OPENGL: Fix adjustment of mouse coordinates when screen is resized and scaled.

Modified Paths:
--------------
    scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/opengl-graphics.cpp
    scummvm/branches/gsoc2010-opengl/backends/graphics/openglsdl/openglsdl-graphics.cpp

Modified: scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/opengl-graphics.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/opengl-graphics.cpp	2010-07-19 23:45:13 UTC (rev 51045)
+++ scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/opengl-graphics.cpp	2010-07-19 23:58:48 UTC (rev 51046)
@@ -134,7 +134,8 @@
 	//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 @@
 		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 @@
 	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 @@
 }
 
 bool OpenGLGraphicsManager::loadGFXMode() {
+	// Initialize OpenGL settings
 	initGL();
 
 	if (!_gameTexture) {
@@ -645,6 +651,10 @@
 			//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 @@
 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:

Modified: scummvm/branches/gsoc2010-opengl/backends/graphics/openglsdl/openglsdl-graphics.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/graphics/openglsdl/openglsdl-graphics.cpp	2010-07-19 23:45:13 UTC (rev 51045)
+++ scummvm/branches/gsoc2010-opengl/backends/graphics/openglsdl/openglsdl-graphics.cpp	2010-07-19 23:58:48 UTC (rev 51046)
@@ -279,8 +279,6 @@
 		break;*/
 	// HACK: Handle special SDL event
 	case OSystem_SDL::kSdlEventResize:
-		_videoMode.overlayWidth = event.mouse.x;
-		_videoMode.overlayHeight = event.mouse.y;
 		_videoMode.hardwareWidth = event.mouse.x;
 		_videoMode.hardwareHeight = event.mouse.y;
 		initGL();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list