Can't write to custom alpha'd texture

Blitz3D Forums/Blitz3D Programming/Can't write to custom alpha'd texture

Shifty Geezer(Posted 2005) [#1]
Okay, having solved my other problem, another takes it's place :(

I have been creating textures from copying parts of an image, and I could write on these textures using SetBuffer and Text.

I now create my textures with the masked (4) flag set, and I can mask of unwanted pixels. But now text doesn't write anything. I try writing in white, black, blue or red, but nothing is visible on the texture. Doh!


jfk EO-11110(Posted 2005) [#2]
In masked mode the alpha byte decides of a texel is visible or not. IF the alpha byte is 0 then it's invisible, everything else is fully opaque.

You may set the alphabyte this way:

alpha= 123 ; just an example for an alpha value for a texel
rgb=readpixel(x,y) and $FFFFFF
argb=(alpha shl 24) or rgb
writepixel x,y, argb

Furthermore some Cards fail to TEXT directly to a texturebuffer, in this case you may want to TEXT to te backbuffer, then copyrect to the texture, then set the alpha bytes.

Setting the alphabytes is somewhat timeconsuming, so I'd suggest to use an additive blending mode for text textures, so you only have to copyrect the text, no need for alpha-ing the alpha channel.


Shifty Geezer(Posted 2005) [#3]
I can write ot hte texturebuffer without trouble (though thanks for the warning - I'll need to address this problem for other machines...).

What I don't understand is I set the texture's alpha bits to FF (visible) and then text, but nothing appears. Seems texting works on a TEXT on or OFF mode regardles of alpha bits?

Ugh. Guess there's no easy solution. There rarely ever is :(


jfk EO-11110(Posted 2005) [#4]
you need to text first, then set the alpha bytes. writing or drawing to a texture will earse the alpha channel, so xou gotta restore it manually. Maybe that's the problem.