rem Pixel Shader Usage

rem init screen
backdrop off

rem Create an object
ObjectNumber=1
make object sphere ObjectNumber,10

rem If Pixel Shaders supported
if get maximum pixel shader version()>0

 rem Create a pixel shader from a text file
 PixelShaderNumber=1
 create pixel shader from file PixelShaderNumber, "pixelshader.psh"

 rem Provide pixel shader with a texture
 ImageNumber=1
 load image "face.bmp",ImageNumber
 set pixel shader texture PixelShaderNumber, 0, ImageNumber

 rem Check if pixel shader was created
 if pixel shader exist(PixelShaderNumber)=1

  rem Apply pixel shader to object
  set pixel shader on ObjectNumber, PixelShaderNumber

 endif

 rem Main loop
 while mouseclick()<>2
  set cursor 0,0 : print "Press Right Mouse Button To Exit"
 endwhile

 rem Check if pixel shader was created
 if pixel shader exist(PixelShaderNumber)=1

  rem Deactivate pixel shader of the object
  set pixel shader off ObjectNumber

  rem Delete a pixel shader
  delete pixel shader PixelShaderNumber

 endif

else
 print "No Pixel Shader Support - Press Key" : wait key
endif

rem Delete object
delete object ObjectNumber

rem End program
end
