Back Rendering (with TextureQuad)
This example copies a rotated region to a texture using the TextureQuad function.
[pbcode]
loadfont "arial",1,90,0
Dim Vertx#(4)
Dim VertY#(4)
global Screen=NewFxIMage(GetScreenWidth(),GetScreenHeight())
Texture=NewFxIMage(256,256)
c1=rndrgb()
c2=rndrgb()
c3=rndrgb()
c4=rndrgb()
Do
rendertoimage screen
setcursor 0,0
Shadebox 0,0,getscreenwidth(),getScreenHeight(),c1,c2,c3,c4
Text 100,100,"Hello World"
DRawQuad(Texture,mousex(),mousey(),256,256,Angle#)
Angle#=wrapangle(Angle#,1)
rendertoscreen
drawimage screen,0,0,false
xpos=GetScreenWidth()-GetIMageWidth(Texture)
Ypos=GetScreenHeight()-GetIMageHeight(Texture)
drawimage Texture,xpos,ypos,false
Sync
loop
Function DRawQuad(Texture,X,Y,Width,Height,Angle#)
oldsurface=getsurface()
vertx#(0)=(Width/-2.0)
verty#(0)=(Height/-2.0)
vertx#(1)=(Width/2.0)
verty#(1)=(Height/-2.0)
vertx#(2)=(Width/2.0)
verty#(2)=(Height/2.0)
vertx#(3)=(Width/-2.0)
verty#(3)=(Height/2.0)
ca#=cos(angle#)
sa#=sin(angle#)
For lp=0 to 3
xpos#= vertx#(lp)
ypos#= verty#(lp)
vertx#(lp)=floor(x+((ca#*xpos#)-(sa#*ypos#)))
vertY#(lp)=floor(y+((ca#*ypos#)+(sa#*xpos#)))
next
iw=GetImageWidth(Texture)
ih=GetImageHeight(Texture)
u1=vertx#(0)
v1=verty#(0)
u2=vertx#(1)
v2=verty#(1)
u3=vertx#(2)
v3=verty#(2)
u4=vertx#(3)
v4=verty#(3)
rendertoimage texture
texturequad Screen,0,0,u1,v1,iw,0,u2,v2,iw,ih,u3,v3,0,ih,u4,v4,false+8
rendertoimage oldsurface
lxpos#=vertx#(3)
lypos#=vertY#(3)
For lp=0 to 3
xpos#= vertx#(lp)
ypos#= verty#(lp)
line xpos#,ypos#,lxpos#,lypos#
lxpos#=xpos#
lypos#=ypos#
next
EndFunction
[/pbcode]