as soon as you draw something to a texture, the alpha channel get's lost. This will affect msaked as well as alphaed textures.
The best solution that I know is to fix the alpha channel manually. if you update your HUD each frame, it may be too slow. Especially when you wanted to use one big quad that stretches across the entire screen for all the HUD element. Think about to use a set of HUD quads with smaller textures and only update the ones that have been edited.
function fixalpha(tex)
setbuffer texturebuffer(tex)
lockbuffer()
for y=0 to textureheight(tex)-1
for x=0 to texturewidth(tex)-1
rgb=readpixelfast(x,y) and $ffffff
; the next line calculates the brightness of the pixel. this would be the alpha value of a texture when it was loaded with the alpha flag
; bri=((rgb shr 16)+((rgb shr 8)and $ff)+(rgb and $ff))/3
; an other method is to make everything semitransparent, only the black parts are fully transparent
if rgb=0 then
bri=0
else
bri=127
endif
argb2=(bri shl 24) or rgb
writepixelfast x,y,argb2
next
next
unlockbuffer()
setbuffer backbuffer()
end function
|