Window losing focus

Blitz3D Forums/Blitz3D Programming/Window losing focus

Farflame(Posted 2007) [#1]
This is a minor problem for my game, but something I'd like to fix anyway, or at least understand what's going on.

I've recently changed my game to a scalable window instead of full-screen, but I've noticed that when my window loses focus - for example if I hit the windows 'Start' button - the screen stops updating, until it gains focus again.

Why is this happening, and is there a simple solution?


Pinete(Posted 2007) [#2]
Have you downloaded the latest update ob Blitz3d?
it solves a lot of problems of this nature...

regards!,


Farflame(Posted 2007) [#3]
I have yes, it doesn't seem to solve this one. It might be something to do with my program which only updates the screen occasionally (it's a management game rather than an action game so screen updates aren't needed every frame), but I tried making it update every 0.5 seconds or so, but it still doesn't do anything if the window doesn't have focus.


Mr. Slat(Posted 2007) [#4]
well, that only happens when you're running the program in blitz, but with the executable that will be solved... believe me, it happened to me too :P

try it out. build the .exe and run it.


DGuy(Posted 2007) [#5]
If you are using the new 1.99 version, then this bit from the release notes applies to your situation:

"Also added 2 new windowed graphics modes: 6 and 7. These are similar to modes 2 and 3, but will
auto-suspend the application when it loses activation. These new modes are highly recommended!"


"Auto-suspend" means a Blitz3D windowed app will no longer use up CPU time when it is not the app with focus, IOW, the app will pause until it regains focus.

This is actually what well behaved apps should do (I'm really surprised it took so long for B3D to do this): If the user switches away from App-A to another app, App-A should not continue to hog the CPU, potentially slowing down the app the user is now trying to work with.


Farflame(Posted 2007) [#6]
Ahhh thanks DGuy, I am using the new mode 7. Have to admit I didn't quite understand that part. For my app, which only updates the screen when the users does something (as it's a management game rather than an action game), I'd prefer it to keep running in the background as it's usually just idling anyway.