Game Development Community

Engine loading in background (windows)

by Jari · in Torque Game Engine · 03/28/2007 (11:37 am) · 3 replies

Hello.
After upgrading to 1.5 I noticed that when the engine's window is left background it loads much slower. This is understandable considering how windows can distribute the progress priorities. But is it possible to give somehow top priority so that you don't have to have the windows focused in order to get the game loaded in time?
Thanks, I hope some one has experince in windows threading.

#1
03/28/2007 (11:53 am)
The code you'd want to change is in winWindow.cc starting around line 978:

else if (window && gWindowCreated) 
   {
      // If we are in background or minimized, sleep for 100ms or until message is recieved
      DWORD foregroundProcessId;
      GetWindowThreadProcessId(window, &foregroundProcessId);
	   if (!SceneLighting::isLighting())
	   {
         if (foregroundProcessId != winState.processId || isWindowMinimized()) 
         {
            MsgWaitForMultipleObjects(0, NULL, false, 100, QS_ALLINPUT);
            windowForeground  = 0;
         }
		   else
            windowForeground = 1;
      }
	}

You could skip this sleep under various conditions, such as whether or not you were done loading, whether or not you were running dedicated, etc.
#2
03/28/2007 (11:56 am)
Hmm... I realized that what I've pasted to you is from 1.3, and it's also been modified by us.

Still, in winWindow.cc, there is likely a loop that sleeps for a little while if the window is left in the background.
#3
03/28/2007 (12:50 pm)
Thanks Tim, looks like just what was needed. :)