///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <mtlView.c>
#define PRAGMA_PATH "%EXE_DIR%\templates\images";
#define PRAGMA_PATH "%EXE_DIR%\samples";
FONT* testfont = font_create("Arial#40");
//material to clear the fx canvas
MATERIAL* MatObjFillAlpha =
{
effect="
Texture TargetMap;
sampler2D SrcColor = sampler_state
{
texture = <TargetMap>;
MinFilter = linear;
MagFilter = linear;
MipFilter = linear;
AddressU = Clamp;
AddressV = Clamp;
};
float4 FillAlpha( float2 texCoord : TEXCOORD0 ) : COLOR0
{
float4 color;
color = tex2D(SrcColor, texCoord);
color.a = 0;
color.rgb = 1;
return color;
}
technique PostProcess
{
pass p1
{
AlphaBlendEnable = false;
VertexShader = null;
PixelShader = compile ps_1_0 FillAlpha();
}
}
";
}
//bumpmap for wave effect
BMAP* bump_map="rock.tga";
//material for wave effect
MATERIAL* test_mat =
{
skin1=bump_map;
effect="
texture TargetMap;
texture mtlSkin1;
sampler2D Map1 = sampler_state
{
Texture = <TargetMap>;
};
sampler2D BumpSampler = sampler_state
{
Texture = <mtlSkin1>;
};
float4 vecTime;
float4 PIXEL_S(float2 Tex:TEXCOORD0 ):COLOR
{
float2 BumpText = tex2D(BumpSampler, float2(Tex.x,Tex.y-0.1*0.1*vecTime.w)).rg*2-1;
Tex += BumpText*(0.01f);
float4 color = tex2D(Map1,Tex);
return color;
}
technique testtech
{
pass p1
{
PixelShader = compile ps_2_0 PIXEL_S();
}
}";
}
//BMAPS
BMAP* lite_c_logo="logo_800.jpg";
BMAP* invent="invent.pcx";
//PRIMARY PANELS
PANEL* testpanA;
PANEL* testpanB;
PANEL* testpanC;
//PRIMARY PANEL BLUEPRINTS FOR PANEL CREATION
//ALSO USED FOR FX PANELS TO CLONE PANELS/ELEMENTS
STRING* testpanAstr =
"
bmap=lite_c_logo;
digits(20,20,\"ID 1\",*,0,0);
button(40, 40, invent, invent, invent, NULL, NULL, NULL);
pos_x=0;
pos_y=0;
size_x=800;
size_y=600;
red=128;
green=128;
blue=128;
layer=0;
flags=LIGHT;
";
STRING* testpanBstr =
"
bmap=lite_c_logo;
digits(20,20,\"ID 2\",*,0,0);
digits(20,40,\"ID 2\",*,0,0);
pos_x=100;
pos_y=100;
size_x=400;
size_y=200;
red=128;
green=128;
blue=128;
layer=1;
flags=LIGHT;
";
STRING* testpanCstr =
"
bmap=lite_c_logo;
digits(20,20,\"ID 3\",*,0,0);
pos_x=350;
pos_y=150;
size_x=350;
size_y=250;
red=128;
green=128;
blue=128;
layer=2;
flags=LIGHT;
";
//EVO2D PANEL SHADER
//fx_ids
int fx_id[100];
//Remove any Fx from any panel that uses the fx_id
void remove_fx(int fx_ids)
{
fx_id[fx_ids] = false;
}
//Apply Fx to a panel
void fx_shader(int fx_ids, PANEL* target_panel, STRING* clone_str, MATERIAL* add_mtl, int fx_transparency, int fx_layer)
{
if(fx_ids<0){fx_ids=0;}
if(fx_ids>99){fx_ids=99;}
fx_id[fx_ids] = true;
PANEL* targetpan = pan_create ( clone_str, fx_layer );
PANEL* destpan = pan_create ( "", fx_layer );
targetpan.alpha = fx_transparency;
layer_sort(target_panel, fx_layer);
layer_sort(targetpan, fx_layer);
layer_sort(destpan, fx_layer);
set(targetpan,SHOW | LIGHT);
set(destpan, SHOW );
targetpan.target_map = bmap_createblack ( screen_size.x, screen_size.y, 32 );
destpan.bmap = bmap_createblack ( screen_size.x, screen_size.y, 32 );
while ( fx_id[fx_ids] )
{
bmap_process ( destpan.bmap, targetpan.target_map, MatObjFillAlpha );
bmap_process ( destpan.bmap, targetpan.target_map, add_mtl );
vec_set(targetpan.blue, target_panel.blue);
destpan.pos_x = target_panel.pos_x;
destpan.pos_y = target_panel.pos_y;
destpan.size_x = target_panel.size_x;
destpan.size_y = target_panel.size_y;
targetpan.pos_x=destpan.pos_x-target_panel.pos_x;
targetpan.pos_y=destpan.pos_y-target_panel.pos_y;
targetpan.size_x=target_panel.size_x;
targetpan.size_y=target_panel.size_y;
wait(1);
}
safe_remove(targetpan.target_map);
safe_remove(destpan.bmap);
safe_remove(targetpan);
safe_remove(destpan);
}
//EVO2D FX Test
function main()
{
fps_max=60;
vec_set(screen_color,vector(1,1,1));
vec_set(sky_color,vector(0,0,0));
video_mode=9;
video_screen=2;
video_set(800,600,32,2);
wait(3);
//Create primary panels from string data
testpanA = pan_create ( testpanAstr, 0 );
testpanB = pan_create ( testpanBstr, 1 );
testpanC = pan_create ( testpanCstr, 2 );
wait(1);
//Need this. Otherwise vecTime doesn't work.
level_load("");
//convert rock.tga to normalmap
bmap_to_normals(bump_map,10);
//Example
//Plays through adding and removing material effect panels
//If fx have the same ID, they will be removed at the same time when calling remove_fx(ID);
//If fx have different IDs, only that fx ID will be removed when calling remove_fx(ID);
wait(-2);
fx_shader(0, testpanA, testpanAstr, test_mat, 100, 0);
wait(-2);
fx_shader(0, testpanB, testpanBstr, mtl_erode, 100, 1);
wait(-2);
fx_shader(0, testpanC, testpanCstr, mtl_sharpen2, 100, 2);
wait(-2);
remove_fx(0);
wait(-2);
fx_shader(0, testpanA, testpanAstr, mtl_sepia, 100, 0);
wait(-2);
fx_shader(0, testpanB, testpanBstr, mtl_monochrome, 100, 1);
wait(-2);
fx_shader(0, testpanC, testpanCstr, mtl_negative, 100, 2);
wait(-2);
remove_fx(0);
wait(-2);
fx_shader(0, testpanA, testpanAstr, mtl_emboss, 100, 0);
wait(-2);
fx_shader(0, testpanB, testpanBstr, mtl_laplace, 100, 1);
wait(-2);
fx_shader(0, testpanC, testpanCstr, mtl_lens, 100, 2);
wait(-2);
remove_fx(0);
wait(-2);
fx_shader(0, testpanA, testpanAstr, test_mat, 100, 0);
while(!key_esc){wait(1);}
sys_exit("exit");
}