You actually need to set the alpha channel on masked textures to make the mask. So you need to use readpixelfast and writepixelfast, to get it to work.Graphics3D 640,480,0,2
SetBuffer BackBuffer()
tex = CreateTexture(256,256,1+4)
For x = 0 To 255
For y = 0 To 255
red = Abs(127.5-x)*2
grn = Abs(127.5-y)*2
blu = 100
alp = ((y + x) Mod 64)*4
WritePixel x,y,(alp Shl 24) + (red Shl 16) + (grn Shl 8) + blu,TextureBuffer(tex)
Next
Next
font = LoadFont("arial",35)
SetFont font
Text 128,128,"HELLO WORLD",True,True
FreeFont font
For x = 0 To 255
For y = 0 To 255
If ReadPixel(x,y,BackBuffer()) = -1
red = 255
grn = 255
blu = 255
alp = 255
WritePixel x,y,(alp Shl 24) + (red Shl 16) + (grn Shl 8) + blu,TextureBuffer(tex)
EndIf
Next
Next
cube = CreateSphere(32)
EntityTexture cube,tex
EntityFX cube,1+16
camera = CreateCamera()
PositionEntity camera,0,0,-3
Repeat
TurnEntity cube,0,-1,0
RenderWorld
Flip
Until KeyHit(1)
|