Browse Source

General clean-up and fixes for the Sandbox example.

David Piuva 5 years ago
parent
commit
bd44d1b7df
2 changed files with 20 additions and 24 deletions
  1. 1 1
      Source/SDK/sandbox/media/interface.lof
  2. 19 23
      Source/SDK/sandbox/sandbox.cpp

+ 1 - 1
Source/SDK/sandbox/media/interface.lof

@@ -5,7 +5,7 @@ Begin : Panel
 		Name = "toolPanel"
 		Left = +0
 		Top = +0
-		Right = 10%+100
+		Right = 8%+100
 		Bottom = 100%
 		Solid = 1
 		Color = 100,150,100

+ 19 - 23
Source/SDK/sandbox/sandbox.cpp

@@ -369,10 +369,9 @@ void sandbox_main() {
 
 	while(running) {
 		double timer = time_getSeconds();
-		double startTime = 0.0;
 
-		// Always render the image when profiling
-		updateImage = overlayMode != OverlayMode_Tools;
+		// Always render the image when profiling or moving the camera
+		updateImage = overlayMode != OverlayMode_Tools || cameraMovement.x != 0 || cameraMovement.y != 0;
 
 		// Execute actions
 		if (window_executeEvents(window)) {
@@ -478,9 +477,7 @@ void sandbox_main() {
 			}
 
 			// Overlays
-			startTime = time_getSeconds();
-				window_drawComponents(window);
-			debugText("Draw GUI: ", (time_getSeconds() - startTime) * 1000.0, " ms\n");
+			window_drawComponents(window);
 			// Profiling mode
 			if (overlayMode == OverlayMode_Profiling) {
 				IVector2D writer = IVector2D(10, 10);
@@ -490,27 +487,26 @@ void sandbox_main() {
 			}
 
 			window_showCanvas(window);
-
-			double newTime = time_getSeconds();
-			secondsPerFrame = newTime - frameStartTime;
-			frameStartTime = newTime;
-			debugText("Total frame: ", secondsPerFrame * 1000.0, " ms\n\n");
-
-			// Profiling
-			if (secondsPerFrame > maxFrameTime) { maxFrameTime = secondsPerFrame; }
-			profileFrameCount++;
-			if (newTime > profileStartTime + 1.0) {
-				double duration = newTime - profileStartTime;
-				profileFrameRate = (double)profileFrameCount / duration;
-				profileStartTime = newTime;
-				profileFrameCount = 0;
-				lastMaxFrameTime = maxFrameTime;
-				maxFrameTime = 0.0;
-			}
 		} else {
 			// If updateImage is false then just delay a bit while waiting for input
 			time_sleepSeconds(0.01);
 		}
+
+		double newTime = time_getSeconds();
+		secondsPerFrame = newTime - frameStartTime;
+		frameStartTime = newTime;
+
+		// Profiling
+		if (secondsPerFrame > maxFrameTime) { maxFrameTime = secondsPerFrame; }
+		profileFrameCount++;
+		if (newTime > profileStartTime + 1.0) {
+			double duration = newTime - profileStartTime;
+			profileFrameRate = (double)profileFrameCount / duration;
+			profileStartTime = newTime;
+			profileFrameCount = 0;
+			lastMaxFrameTime = maxFrameTime;
+			maxFrameTime = 0.0;
+		}
 	}
 }