[Scummvm-cvs-logs] CVS: residual debug.h,1.5,1.6 driver_gl.cpp,1.15,1.16 driver_gl.h,1.7,1.8 engine.cpp,1.28,1.29 main.cpp,1.25,1.26

Oliver Kiehl olki at users.sourceforge.net
Thu Apr 15 13:21:03 CEST 2004


Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11621

Modified Files:
	debug.h driver_gl.cpp driver_gl.h engine.cpp main.cpp 
Log Message:
a simple fps monitor


Index: debug.h
===================================================================
RCS file: /cvsroot/scummvm/residual/debug.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- debug.h	24 Mar 2004 12:20:46 -0000	1.5
+++ debug.h	15 Apr 2004 20:20:03 -0000	1.6
@@ -20,7 +20,7 @@
 #ifndef DEBUG_H
 #define DEBUG_H
 // Hacky toggles for experimental / debug code (defined/set in main.cpp)
-extern bool ZBUFFER_GLOBAL, SCREENBLOCKS_GLOBAL;
+extern bool ZBUFFER_GLOBAL, SCREENBLOCKS_GLOBAL, SHOWFPS_GLOBAL;
 
 void warning(const char *fmt, ...);
 void error(const char *fmt, ...);

Index: driver_gl.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_gl.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- driver_gl.cpp	14 Apr 2004 23:04:33 -0000	1.15
+++ driver_gl.cpp	15 Apr 2004 20:20:04 -0000	1.16
@@ -240,7 +240,7 @@
 }
 
 // Draw text string using emergency font
-void Driver::drawEmergString(int x, int y, const char *text, Color &fgColor) {
+void Driver::drawEmergString(int x, int y, const char *text, const Color &fgColor) {
         glMatrixMode(GL_PROJECTION);
         glPushMatrix();
         glLoadIdentity();

Index: driver_gl.h
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_gl.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- driver_gl.h	28 Mar 2004 11:00:16 -0000	1.7
+++ driver_gl.h	15 Apr 2004 20:20:04 -0000	1.8
@@ -42,7 +42,7 @@
 		void drawDepthBitmap(int x, int y, int w, int h, char *data);
 		void drawBitmap();
 
-		void drawEmergString(int x, int y, const char *text, Color &fgColor);
+		void drawEmergString(int x, int y, const char *text, const Color &fgColor);
 		void loadEmergFont();
 
 		void prepareSmushFrame(int width, int height, byte *bitmap);

Index: engine.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- engine.cpp	26 Mar 2004 06:08:00 -0000	1.28
+++ engine.cpp	15 Apr 2004 20:20:04 -0000	1.29
@@ -42,6 +42,9 @@
 	movieTime_ = 0;
 	frameTime_ = 0;
 	frameStart_ = SDL_GetTicks();
+	unsigned int frameCounter = 0;
+	unsigned int timeAccum = 0;
+	char fps[8] = "";
 
 	for (;;) {
 		// Process events
@@ -152,6 +155,15 @@
 				(*i)->draw();
 			}
 
+			if (SHOWFPS_GLOBAL) {
+				if (timeAccum > 1000) {
+					sprintf(fps, "%7.2f", (double)(frameCounter * 1000) / (double)timeAccum );
+					frameCounter = 0;
+					timeAccum = 0;
+				}
+				g_driver->drawEmergString(550, 25, fps, Color(255, 255, 255));
+			}
+
 			currScene_->drawBitmaps(ObjectState::OBJSTATE_OVERLAY);
 			
 			g_driver->flipBuffer();
@@ -165,6 +177,11 @@
 		frameTime_ = newStart - frameStart_;
 		frameStart_ = newStart;
 
+		if (SHOWFPS_GLOBAL) {
+			frameCounter++;
+			timeAccum += frameTime_;
+		}
+
 		lua_beginblock();
 		set_frameTime(frameTime_);
 		lua_endblock();

Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/main.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- main.cpp	25 Mar 2004 22:17:09 -0000	1.25
+++ main.cpp	15 Apr 2004 20:20:04 -0000	1.26
@@ -35,7 +35,7 @@
 #endif
 
 // Hacky global toggles for experimental/debug code
-bool ZBUFFER_GLOBAL, SCREENBLOCKS_GLOBAL;
+bool ZBUFFER_GLOBAL, SCREENBLOCKS_GLOBAL, SHOWFPS_GLOBAL;
 
 static void saveRegistry() {
 	Registry::instance()->save();
@@ -79,6 +79,7 @@
 	// Parse command line
 	ZBUFFER_GLOBAL = parseBoolStr(Registry::instance()->get("zbuffer"));
 	SCREENBLOCKS_GLOBAL = parseBoolStr(Registry::instance()->get("screenblocks"));
+	SHOWFPS_GLOBAL = parseBoolStr(Registry::instance()->get("showfps"));
 	for (i=1;i<argc;i++) {
 		if (strcmp(argv[i], "-zbuffer") == 0)
 			ZBUFFER_GLOBAL = true;
@@ -88,12 +89,17 @@
 			SCREENBLOCKS_GLOBAL = true;
 		else if (strcmp(argv[i], "-noscreenblocks") == 0)
 			SCREENBLOCKS_GLOBAL = false;
+		else if (strcmp(argv[i], "-fps") == 0)
+			SHOWFPS_GLOBAL = true;
+		else if (strcmp(argv[i], "-nofps") == 0)
+			SHOWFPS_GLOBAL = false;
 		else {
 			printf("Residual CVS Version\n");
 			printf("--------------------\n");
 			printf("Recognised options:\n");
 			printf("\t-[no]zbuffer\t\tEnable/disable ZBuffers (Very slow on older cards)\n");
 			printf("\t-[no]screenblocks\t\tEnable/disable Screenblocks (Experimental zbuffer speedup on older cards - BROKEN!!\n");
+			printf("\t-[no]showfps\t\tEnable/disable fps display in upper right corner\n");
 			exit(-1);
 		}
 	}





More information about the Scummvm-git-logs mailing list