Thank you for sharing code.
Emre, have you tried to see if your game works when you run fullscreen, then lock, then log back into the desktop to see what a running gamestudio does?
I've never tried fullscreen test before. You're right, it freezes when in fullscreen indeed.
However, when you log back in to a running windowed gamestudio exe, the game gave me a "cant create texture unnamed", but it didnt crash the game. When you select OK, the game seems to run ok in windowed mode after.
I surprised by this. Although i run four pp effects at the same time, i don't get any error. I don't know what caused this problem.
EDIT: Btw i found another solution and this is effective in any case in window mode. (Screensaver, UAC, Lock secreen, etc...)
#include <acknex.h>
#include <windows.h>
#include <default.c>
#ifndef material_and_view
#define material_and_view
MATERIAL* test_mat1 =
{
effect="Texture TargetMap;
sampler2D g_samSrcColor = sampler_state { texture = <TargetMap>; MipFilter = Linear; };
float4 postprocessing_negative( float2 Tex : TEXCOORD0 ) : COLOR0
{
float3 Color = 1. - tex2D( g_samSrcColor, Tex.xy).xyz;
return float4(Color,1.);
}
technique PostProcess
{
pass p1
{
AlphaBlendEnable = false;
VertexShader = null;
PixelShader = compile ps_2_0 postprocessing_negative();
}
}";
}
VIEW* post_view1 ={layer = 0; flags = PROCESS_TARGET; material=test_mat1;}
#endif
action testet()
{
while(1)
{
my.pan+=5*time_step;
wait(1);
}
}
function main()
{
video_mode=10;
video_screen=2;
wait(3);
fps_max=500;
level_load("");
camera.stage = post_view1;
ent_create(CUBE_MDL,vector(150,0,0),testet);
HWND foreground = GetForegroundWindow();
while(1)
{
foreground = GetForegroundWindow();
if(foreground!=hWnd)
{
beep();
camera.stage=NULL;
while(1)
{
foreground = GetForegroundWindow();
if(foreground==hWnd)
{
break;
}
wait(1);
}
camera.stage=post_view1;
beep();
}
wait(1);
}
}
EDIT 2: For fullscreen, you can use video_set after the background, instead of alt + enter. i don't know how but it restore something.
foreground = GetForegroundWindow();
if(foreground!=hWnd)
{
beep();
camera.stage=NULL;
while(1)
{
foreground = GetForegroundWindow();
if(foreground==hWnd)
{
break;
}
wait(1);
}
camera.stage=post_view1;
video_set(0,0,0,2);
beep();
}