Paint the Alphachannel

Blitz3D Forums/Blitz3D Programming/Paint the Alphachannel

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Graphics3D 1280,1024,32,1
SetBuffer BackBuffer()

cam=CreateCamera()
CameraRange cam,.001,10

obj1=CreateSprite();snow
obj2=CreateSprite();ground

SpriteViewMode obj1,2
SpriteViewMode obj2,2

EntityBlend obj1,3

tex1=CreateTexture(1024,1024,1+4+256);snow
tex2=CreateTexture(1024,1024,1+256);ground

;snow
SetBuffer TextureBuffer(tex1)
Color 0,255,255
Rect 0,0,1023,1023,1

;ground
SetBuffer TextureBuffer(tex2)
Color 0,128,0
Rect 0,0,1024,1024,1

EntityTexture obj1,tex1;snow
EntityTexture obj2,tex2;ground

PositionEntity obj1,0,0,-.1
PositionEntity obj2,0,0,0
PositionEntity cam,0,-1,-1
PointEntity cam,obj2

snow=CreateImage(1024,1024)
SetBuffer ImageBuffer(snow)
Color 255,255,255
Rect 0,0,1024,1024,1

foot=CreateImage(25,25)
SetBuffer ImageBuffer(foot)
MaskImage foot,255,255,255
Color 255,255,255
Rect 0,0,25,25,1
Color 0,0,0
Oval 5,0,15,25,1

SetBuffer BackBuffer()

Color 255,255,255

fpst=0
fps=30
time=MilliSecs()
SeedRnd time
angle#=0
Repeat
	angle=(angle+1) Mod 360
	RotateEntity obj1,0,0,angle
	RotateEntity obj2,0,0,angle
;	MoveEntity cam,0,0,Sin(angle*4)/10
	
	SetBuffer ImageBuffer(snow)
	For a=0 To 250				;I can set this up to 1250 and still get 60 fps
		x=Rand(999)				;  (my monitor only allows up to 60fps)
		y=Rand(999)
		DrawImage foot,x,y
	Next
	CopyRect 0,0,1024,1024,0,0,ImageBuffer(snow),TextureBuffer(tex1)
	SetBuffer BackBuffer()
	
	RenderWorld
	fpst=fpst+1
	If MilliSecs()-time>1000
		fps=fpst
		fpst=0
		time=MilliSecs()
		Text 0,0,fps,0,0;the text command really hurts performance
						; - so I'm only blinking the framerate once a second
	EndIf
;	Text 0,0,fps,0,0	;uncomment this line and comment the one in the if/endif
						;  to see a constant framerate
						;  this line will cut my fps to 30 - even without debug
	
	Flip
Until KeyHit(1)
End