Hi all,
here is second demo, it uses an other shader program called MskPrg , that will draw the movie in normal
color but with a mask that taken from red component of an other image. that movie will draw in Mouse
x & y coordinates. and over the black& white movie.
with MagicPro there is no end of your imagination. just imagine and let MagicPro does it.
here is the code
//****************************************//
// ************ //
// ***MagicPro library*** //
// ************ //
//****************************************//
//includepath "$/inc/"
$ filename "MagicProTest4.exe"
#include "..\..\inc\RTL32.inc"
#include "MagicPro.inc"
sys cam,ogrehead,light,SPrg,MskPrg,mskId,Movie,hgeSprite,MousX,MousY
void QueueStarted() , callback
{
Screen_Use2DView()
ML_StartShaderPrg(SPrg)
DrawMovieToScreen(Movie,0,0,800,600)
ML_StartShaderPrg(MskPrg)
ML_SetTexture(Image_GetPointer(mskId),1)
hgeSprite_Render(hgeSprite,MousX,MousY)
ML_StopShaderPrg()
Screen_Stop2DView()
}
Init("MagicPro Test #4")
Graphics3D(800,600)
defineQueueStarted(@QueueStarted)
setMediaDir("ZipMedia.zip")
setMediaDir("media")
setAmbientLight(30.0,30.0,50.0)
cam = CreateCamera
CameraRange(cam,1.0,1000.0)
ogrehead = LoadMesh("ogrehead.mesh",0,"")
PositionEntity(ogrehead,0.0,0.0,-150.0)
light = CreateLight()
PositionEntity(light,-200.0,200.0,50.0)
LightColor(light,255.0,200.0,150.0)
Movie = LoadMovie("Sandra - Infinite Kiss ( 2012 ).mpg")
LoopMovie(Movie,true)
RunMovie(Movie)
SPrg = ML_CreateHLSLPrg()
ML_EditPixelPrg(SPrg)
ML_AddToPrg("sampler2D tex0; ")
ML_AddToPrg("float4 main( float2 TexCoord : TEXCOORD0) : COLOR0 ")
ML_AddToPrg("{ ")
ML_AddToPrg(" float4 col = tex2D( tex0, TexCoord ); ")
ML_AddToPrg(" float gry = col.r*0.299+col.g*0.587+col.b*0.184; ")
ML_AddToPrg(" return float4(gry,gry,gry,col.a); ")
ML_AddToPrg("} ")
ML_CompilePixelPrg(SPrg,"main")
sys id = GetImageIDOfMovie(Movie)
single imgh = Image_GetHeight id
single imgw = Image_GetWidth id
hgeSprite = make_hgeSprite(id,0.0,0.0,imgw,imgh)
mskId = Image_GetFreeID()
Image_load ( mskId , "irr_media/lightFalloff.png")
MskPrg = ML_CreateHLSLPrg()
ML_EditPixelPrg(MskPrg)
ML_AddToPrg("sampler2D tex0; ")
ML_AddToPrg("sampler2D tex1; ")
ML_AddToPrg("float4 main( float2 TexCoord : TEXCOORD0) : COLOR0 ")
ML_AddToPrg("{ ")
ML_AddToPrg(" float4 c1 = tex2D( tex0, TexCoord ); ")
ML_AddToPrg(" float4 c2 = tex2D( tex1, TexCoord ); ")
ML_AddToPrg(" return float4(c1.r,c1.g,c1.b,c2.r); ")
ML_AddToPrg("} ")
ML_CompilePixelPrg(MskPrg,"main")
while not OIS_isKeyDown(KC_ESCAPE)
{
DoEvents
MousX = OIS_mouseX()
MousY = OIS_mouseY()
UpdateMovie(Movie)
RenderWorld()
Sync()
}
DeleteMovie(Movie)
EndGraphics()
X