Posted By: Lion_Ts
Tips and Tricks - ALT+TAB and CPU usage - 09/09/05 17:09
Hi!
Look at this:
No game pausing:
cpu usage ~97%
Freezing funcs only:
cpu usage ~60%
Code:
restrict fps:
cpu usage ~7%
Code:
disable camera:
cpu usage ~0% !
Code:
Ok, if you read this, you understand now, for low cpu usage catch loose focus event and disable your camera.
Look at this:
No game pausing:
cpu usage ~97%
Freezing funcs only:
cpu usage ~60%
Code:
var wndf=0;
starter pause_game_at_alt_tab() //pause game on loose focus
{
while (1)
{
if (window_focus == 0){
if (!wndf){
wndf=1;
// camera.visible=off;
// fps_max=4;
freeze_mode = 1;
}
}else{
if (wndf){
freeze_mode = 0;
// fps_max=40;
// camera.visible=on;
wndf=0;
}
}
wait(1);
}
}
restrict fps:
cpu usage ~7%
Code:
var wndf=0;
starter pause_game_at_alt_tab() //pause game on loose focus
{
while (1)
{
if (window_focus == 0){
if (!wndf){
wndf=1;
// camera.visible=off;
fps_max=4;
freeze_mode = 1;
}
}else{
if (wndf){
freeze_mode = 0;
fps_max=40;
// camera.visible=on;
wndf=0;
}
}
wait(1);
}
}
disable camera:
cpu usage ~0% !
Code:
var wndf=0;
starter pause_game_at_alt_tab() //pause game on loose focus
{
while (1)
{
if (window_focus == 0){
if (!wndf){
wndf=1;
camera.visible=off;
fps_max=4;
freeze_mode = 1;
}
}else{
if (wndf){
freeze_mode = 0;
fps_max=40;
camera.visible=on;
wndf=0;
}
}
wait(1);
}
}
Ok, if you read this, you understand now, for low cpu usage catch loose focus event and disable your camera.