Blitz3D blend mode missing!

Blitz3D Forums/Blitz3D Programming/Blitz3D blend mode missing!

I am rendering to the backbuffer and then copying to a texture buffer with the ambition of making a sprite with the black removed.

I tried masked mode but nothing happened? I'm not after a true alpha channel, just a fast way to make a masked sprite in realtime.

As soon as you write to the texture, the alphachannel is destroyed. Masked textures use the Alphachannel as well, where a Zero-Byte signals a masked texel.

thats stiffed my latest plan then
Why can copyrect not even do fast mask?

Because Mark hates the way you contruct levels with the lightmaps in the same file as the textures.

It's called effieciency and modularity :)

YOUR way INSISTS on the user splitting his files into seperate verts, triangles and pixels.

So you end up with ONE TRILLION useless TEXT documents for a SINGLE pixel.

I was playing with that this morning and got it working.
Sorrry for not crediting the sources of some of the code.
It was gleaned from the forum in a couple of searches and
some of marks code from the examples. spacebar sets it.
you'll have to make a 256x128 bmp with some pure black on it to replace the textures that are missing.
This is just masking. I'm not sure about alpha but I think it could be worked in.
SetBuffer BackBuffer()
Graphics3D 800,600,16,2

;create grid texture
grid_tex=CreateTexture( 16,16,8,1 )
ScaleTexture grid_tex,10,10
SetBuffer TextureBuffer( grid_tex )
ClsColor 255,255,255:Cls:ClsColor 0,0,0
Color 192,192,192:Rect 0,0,8,8:Rect 8,8,8,8
SetBuffer BackBuffer()
plane=CreatePlane()
EntityTexture plane,grid_tex


t_sphere=CreateSphere( 8 )
EntityShininess t_sphere,.2
For t=0 To 359 Step 36
	sphere=CopyEntity( t_sphere )
	EntityColor sphere,Rnd(256),Rnd(256),Rnd(256)
	TurnEntity sphere,0,t,0
	MoveEntity sphere,0,0,10
Next
FreeEntity t_sphere

;globals for text box
Global textbox=LoadTexture("textbox.bmp",306)
Global textbox1=LoadImage("textbox.bmp")
Global textbox2=LoadImage("textbox.bmp")

font=LoadFont("comic sans ms",22,True,True)
SetFont font


Global textboxsprite=CreateSprite()
EntityTexture textboxsprite,textbox

;PositionEntity textboxsprite,EntityX(textboxsprite),EntityY(textboxsprite)+15,EntityZ(textboxsprite)
ScaleSprite textboxsprite,10,5


cube=CreateCube()
PositionEntity cube,0,7,0
ScaleEntity cube,3,3,3

light=CreateLight()
TurnEntity light,45,45,0

camera=CreateCamera()
CameraClsColor camera,0,255,0


d#=-20

While Not KeyHit(1)
	
	If KeyDown(30) d=d+1
	If KeyDown(44) d=d-1
	If KeyDown(203) TurnEntity camera,0,-3,0
	If KeyDown(205) TurnEntity camera,0,+3,0
	If KeyDown(57) Then 	TextSprite(0,15,0,"They say there is a horrible monster to the south. It blocks the gate so no one may pass.")

	PositionEntity camera,0,14,0
	MoveEntity camera,0,0,d
	
	TurnEntity cube,.1,.2,.3
	UpdateWorld
	RenderWorld	
	Flip
Wend

Function TextSprite(X#,Y#,Z#,TextString$)
	;position
	PositionEntity textboxsprite,X#,Y#,Z#
	
	SetBuffer ImageBuffer(textbox1)
	ClsColor 0,0,0
	Cls	
	DrawImage textbox2,0,0
	;Text color
	Color 255,255,64
	posx=15
	posy=15
	While Len(TextString$)>28
		templen=28
		tempstr$=Left(TextString$,templen)		
		While (Right(tempstr$,1)<>" " And templen>1)
			templen=templen-1
			tempstr$=Left(TextString$,templen)
		Wend		
		TextString$=Right(TextString$,Len(TextString$)-templen)
		Text posx,posy,tempstr$
		posy=posy+15	
	Wend
	
	Text posx,posy,TextString$
	
	CopyRect 0,0,256,128,0,0,ImageBuffer(textbox1),TextureBuffer(textbox)	
	
	;copy image to texture
	LockBuffer TextureBuffer(textbox)
	For x=0 To TextureWidth(textbox)-1
		For y=0 To TextureHeight(textbox)-1
			pix=ReadPixelFast(x,y,TextureBuffer(textbox))
			If (pix And $FFFFFF)=0 Then WritePixelFast x,y,0,TextureBuffer(textbox) Else WritePixelFast x,y,(pix Or $FF000000),TextureBuffer(textbox)
		Next
	Next
	UnlockBuffer TextureBuffer(textbox)
End Function


Thanks arb, but isn't this slow to do?