Text doens't alpha..

Blitz3D Forums/Blitz3D Programming/Text doens't alpha..

Liberator(Posted 2005) [#1]
Quick questions.... in the example:

; TextureBuffer Example
; ---------------------

Graphics3D 640,480
SetBuffer BackBuffer()

camera=CreateCamera()

light=CreateLight()
RotateEntity light,90,0,0

cube=CreateCube()
PositionEntity cube,0,0,5

; Create texture of size 256x256
tex=CreateTexture(256,256)

; Set buffer - texture buffer
SetBuffer TextureBuffer(tex)

; Clear texture buffer with background white color
ClsColor 255,255,255
Cls

; Draw text on texture
font=LoadFont("arial",24)
SetFont font
Color 0,0,0
Text 0,0,"This texture"
Text 0,40,"was created using" : Color 0,0,255
Text 0,80,"CreateTexture()" : Color 0,0,0
Text 0,120,"and drawn to using" : Color 0,0,255
Text 0,160,"SetBuffer TextureBuffer()"

; Texture cube with texture
EntityTexture cube,tex

; Set buffer - backbuffer
SetBuffer BackBuffer()

While Not KeyDown( 1 )

pitch#=0
yaw#=0
roll#=0

If KeyDown( 208 )=True Then pitch#=-1
If KeyDown( 200 )=True Then pitch#=1
If KeyDown( 203 )=True Then yaw#=-1
If KeyDown( 205 )=True Then yaw#=1
If KeyDown( 45 )=True Then roll#=-1
If KeyDown( 44 )=True Then roll#=1

TurnEntity cube,pitch#,yaw#,roll#

RenderWorld
Flip

Wend
End

-------------------------------

Try creating the 'tex' texture with the masked flag so it says "tex=CreateTexture(256,256,1+4)". Now why does nothing show up? Shoulden't the text be transparent? Or is there somthing about the way textures work that I'm simply not understanding....


Beaker(Posted 2005) [#2]
Take a look here:
http://www.blitzbasic.com/codearcs/codearcs.php?code=548


RGR(Posted 2005) [#3]
@Liberator
I made the same as you did, months ago and someone pointed me into the right direction.
After you make CLS the alpha values are still 0 at each pixel - so you have to poke the alphavalues on each pixel of the texture.
Another way would be to create an image, save it and load it as Texture with Flags.
Naturally better would be to have a Command ClsColor(R,G,B,A#=1.0)


jfk EO-11110(Posted 2005) [#4]
If I remember correctly, you can TEXT to a texturebuffer exactly one time, IF the alpha-channel is already set. To prevent slow writepixel commands you may create a dummy texture of the same size, set its alpha bytes to zero (using writepixelfast) and then COPYRECT (instead of CLS) from this dummy texture to the target texture whenever you plan to write some new TEXT to the target texture.