[Scummvm-cvs-logs] CVS: scummvm/backends/sdl sdl-common.cpp,1.83,1.84 sdl-common.h,1.37,1.38 sdl_gl.cpp,1.54,1.55

Max Horn fingolfin at users.sourceforge.net
Sun Sep 14 05:53:05 CEST 2003


Update of /cvsroot/scummvm/scummvm/backends/sdl
In directory sc8-pr-cvs1:/tmp/cvs-serv12981

Modified Files:
	sdl-common.cpp sdl-common.h sdl_gl.cpp 
Log Message:
evil fix for #bug 801293 (ALL: Ctrl+alt+b opengl switch) and some cleanup

Index: sdl-common.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.cpp,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- sdl-common.cpp	10 Sep 2003 12:15:50 -0000	1.83
+++ sdl-common.cpp	14 Sep 2003 12:52:37 -0000	1.84
@@ -529,6 +529,30 @@
 	return key;
 }
 
+void OSystem_SDL_Common::fillMouseEvent(Event &event, int x, int y) {
+	event.mouse.x = x;
+	event.mouse.y = y;
+	
+	// FIXME: HACK HACK HACK. This works around an odd problem in the OpenGL
+	// variant of the SDL backend, where the mouse y coordinates are reversed.
+	// Since the OpenGL variants is quite hackish anyway, we have to hard code
+	// here a screen height of 480).
+	if (_mode_flags & DF_REVERSE_Y)
+		event.mouse.y = 480 - event.mouse.y;
+	
+	// Update the "keyboard mouse" coords
+	km.x = event.mouse.x;
+	km.y = event.mouse.y;
+
+	// Adjust for the screen scaling
+	event.mouse.x /= _scaleFactor;
+	event.mouse.y /= _scaleFactor;
+
+	// Optionally perform aspect ratio adjusting
+	if (_adjustAspectRatio)
+		event.mouse.y = aspect2Real(event.mouse.y);
+}
+
 bool OSystem_SDL_Common::poll_event(Event *event) {
 	SDL_Event ev;
 	int axis;
@@ -722,14 +746,7 @@
 
 		case SDL_MOUSEMOTION:
 			event->event_code = EVENT_MOUSEMOVE;
-			km.x = event->mouse.x = ev.motion.x;
-			km.y = event->mouse.y = ev.motion.y;
-
-			event->mouse.x /= _scaleFactor;
-			event->mouse.y /= _scaleFactor;
-
-			if (_adjustAspectRatio)
-				event->mouse.y = aspect2Real(event->mouse.y);
+			fillMouseEvent(*event, ev.motion.x, ev.motion.y);
 			
 			set_mouse_pos(event->mouse.x, event->mouse.y);
 			return true;
@@ -747,13 +764,8 @@
 #endif
 			else
 				break;
-			km.x = event->mouse.x = ev.button.x;
-			km.y = event->mouse.y = ev.button.y;
-			event->mouse.x /= _scaleFactor;
-			event->mouse.y /= _scaleFactor;
 
-			if (_adjustAspectRatio)
-				event->mouse.y = aspect2Real(event->mouse.y);
+			fillMouseEvent(*event, ev.button.x, ev.button.y);
 
 			return true;
 
@@ -764,13 +776,7 @@
 				event->event_code = EVENT_RBUTTONUP;
 			else
 				break;
-			event->mouse.x = ev.button.x;
-			event->mouse.y = ev.button.y;
-			event->mouse.x /= _scaleFactor;
-			event->mouse.y /= _scaleFactor;
-
-			if (_adjustAspectRatio)
-				event->mouse.y = aspect2Real(event->mouse.y);
+			fillMouseEvent(*event, ev.button.x, ev.button.y);
 
 			return true;
 

Index: sdl-common.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- sdl-common.h	11 Sep 2003 23:53:38 -0000	1.37
+++ sdl-common.h	14 Sep 2003 12:52:37 -0000	1.38
@@ -149,7 +149,8 @@
 
 	enum {
 		DF_WANT_RECT_OPTIM			= 1 << 0,
-		DF_UPDATE_EXPAND_1_PIXEL	= 1 << 3
+		DF_UPDATE_EXPAND_1_PIXEL	= 1 << 1,
+		DF_REVERSE_Y				= 1 << 2
 	};
 
 	bool _forceFull; // Force full redraw on next update_screen
@@ -185,9 +186,7 @@
 		MousePos() : x(0), y(0), w(0), h(0) {}
 	};
 
-	// joystick
-	SDL_Joystick *_joystick;
-
+	// mouse
 	bool _mouseVisible;
 	bool _mouseDrawn;
 	const byte *_mouseData;
@@ -197,6 +196,9 @@
 	int16 _mouseHotspotX;
 	int16 _mouseHotspotY;
 
+	// joystick
+	SDL_Joystick *_joystick;
+
 	// Shake mode
 	int _currentShakePos;
 	int _newShakePos;
@@ -213,20 +215,21 @@
 	void add_dirty_rgn_auto(const byte *buf);
 	void mk_checksums(const byte *buf);
 
-	static void fill_sound(void *userdata, Uint8 * stream, int len);
-	
 	void add_dirty_rect(int x, int y, int w, int h);
 
 	virtual void draw_mouse();
 	virtual void undraw_mouse();
 	/** Set the position of the virtual mouse cursor. */
 	void set_mouse_pos(int x, int y);
+	void fillMouseEvent(Event &event, int x, int y);
 
 
 	virtual void load_gfx_mode() = 0;
 	virtual void unload_gfx_mode() = 0;
 
 	virtual bool save_screenshot(const char *filename) = 0;
+	
+	virtual int effectiveScreenHeight() { return (_adjustAspectRatio ? 240 : _screenHeight) * _scaleFactor; }
 
 	void setup_icon();
 	void kbd_mouse();

Index: sdl_gl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl_gl.cpp,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- sdl_gl.cpp	10 Sep 2003 12:15:51 -0000	1.54
+++ sdl_gl.cpp	14 Sep 2003 12:52:38 -0000	1.55
@@ -102,8 +102,23 @@
 	switch(_mode) {
 	case GFX_BILINEAR:
 		_usingOpenGL = true;
+		_mode_flags |= DF_REVERSE_Y;
 		_mode = GFX_NORMAL;
 		break;
+
+	case GFX_NORMAL:
+		_scaleFactor = 1;
+		_scaler_proc = Normal1x;
+		break;
+	case GFX_DOUBLESIZE:
+		_scaleFactor = 2;
+		_scaler_proc = Normal2x;
+		break;
+	case GFX_TRIPLESIZE:
+		_scaleFactor = 3;
+		_scaler_proc = Normal3x;
+		break;
+
 	case GFX_2XSAI:
 		_scaleFactor = 2;
 		_scaler_proc = _2xSaI;
@@ -132,31 +147,16 @@
 		_scaleFactor = 2;
 		_scaler_proc = DotMatrix;
 		break;
-	case GFX_DOUBLESIZE:
-		_scaleFactor = 2;
-		_scaler_proc = Normal2x;
-		break;
 
-	case GFX_TRIPLESIZE:
-		_scaleFactor = 3;
-		_scaler_proc = Normal3x;
-		break;
-
-	case GFX_NORMAL:
-		_scaleFactor = 1; //_usingOpenGL ? 2 : 1;
-		_scaler_proc = Normal1x;
-		break;
 	default:
 		error("unknown gfx mode %d", _mode);
-		_mode = GFX_NORMAL;
-		_scaleFactor = 1;
-		_scaler_proc = Normal1x;
 	}
-
+	
 	if (_mode != GFX_NORMAL) {
-	  _usingOpenGL = false;
+		_usingOpenGL = false;
+		_mode_flags &= ~DF_REVERSE_Y;
 	}
-  
+
 	//
 	// Create the surface that contains the 8 bit game data
 	//
@@ -630,11 +630,11 @@
 		}
 
 	} else if (param == PROP_SET_GFX_MODE) {
-
 		if (value->gfx_mode > 10) { // OpenGL modes
 			if (!_usingOpenGL) {
 				_usingOpenGL = true;
 				_mode = GFX_NORMAL;
+				_mode_flags |= DF_REVERSE_Y;
 				_scaleFactor = 1;
 				_scaler_proc = Normal1x;
 				hotswap_gfx_mode();
@@ -655,6 +655,7 @@
 				if (_usingOpenGL) {
 					_glBilinearFilter = false;
 					_usingOpenGL = false;
+					_mode_flags &= ~DF_REVERSE_Y;
 				}
 				
 				hotswap_gfx_mode();





More information about the Scummvm-git-logs mailing list