#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
#ifndef fps_counter
#define fps_counter
var temp_fps;
var actual_fps;
function check_fps()
{
while(1)
{
temp_fps = 0.9*temp_fps+0.1/time_frame;
actual_fps=temp_fps*16;
DEBUG_VAR(actual_fps,10);
wait(1);
}
}
#endif
#define DESKTOP_SWITCHDESKTOP 0x0100L
#define DF_ALLOWOTHERACCOUNTHOOK 0x0001
int DesktopResult;
int is_stage_off=0;
HWND* DeskHwnd;
function onexit()
{
CloseDesktop(DeskHwnd);// i don't know if it's necessary.
}
function main()
{
video_mode=10;
video_screen=2;
wait(3);
fps_max=500;
check_fps();
on_exit=onexit;
level_load("");
camera.stage = post_view1;
DeskHwnd = OpenDesktop("Default", DF_ALLOWOTHERACCOUNTHOOK, false, DESKTOP_SWITCHDESKTOP);
while(1)
{
if (DeskHwnd != 0)
{
DesktopResult = SwitchDesktop(DeskHwnd);
}
if (DesktopResult == 0)//Desktop is locked via uac or lock screen
{
//remove the stage immediatly
if(is_stage_off==0)
{
diag("\n\n!LOCKED!\n");
camera.stage=NULL;
is_stage_off=1;
/*
"wait(actual_fps);" is important, because desktop is locked and unlocked two time at once. (i don't know why)
e.g: when you locked your screen and open it again. Diag message must be "!Locked! !Unloked!" But it doesn't.
instead, it's "!Locked! !Unloked! !Locked! !Unloked!"
That my cause a crash when we use pp_add and pp_remove repeatedly.
So wait for it. No problem with this way.
*/
wait(actual_fps);
}
}
else//Desktop is UNlocked
{
//setup post effect again
if(is_stage_off==1)
{
diag("\n\n!UNLOCKED!\n");
camera.stage=post_view1;
is_stage_off=0;
wait(1);
}
}
wait(1);
}
}