Masking Problem

Blitz3D Forums/Blitz3D Programming/Masking Problem

mkg(Posted 2008) [#1]
I've searched the forums and haven't been able to find anything that answers the exact problem I'm having.

I need a 2d map that is revealed as the player icon moves. This is in B3D using Sprite Candy.

I load the texture for the mask (i.e. the blacked out part of the map):
texMask=LoadTexture("mytex.bmp",4)

I set up the Sprite Candy objects:
HUD_01%=HUD_Create(camera)
mask_file%=HUD_LoadMemoryResource(texMask,4)
layer_mask%=HUD_CreateLayer(HUD_01,mask_file)
img_mask=HUD_CreateImage(layer_mask,400,300,0,0,1024,1024)

Then I draw a rectangle on the texture like this:
SetBuffer TextureBuffer(texMask)
Color 0,0,0
Rect xpos,ypos,10,10,1
SetBuffer BackBuffer()

It all displays fine.

When I move on the map it draws a black rectangle that I can see on the SC image.

BUT I don't want to see a black rectangle I want a transparent rectangle!

So am I missing some additional command? Or I am not able to do what I want this way? Ideas please - this is one of those little problems that is starting to annoy me :(


Rroff(Posted 2008) [#2]
edit ignore


Ross C(Posted 2008) [#3]
If your copying the texture in anyway, the alpha information will be lost, thus the masking info also will be.

Pass the texture across to this function:

http://www.blitzbasic.com/codearcs/codearcs.php?code=1013


mkg(Posted 2008) [#4]
Thanks a lot - I got it working with your function. As I'm using a large texure (1024x1024) it is slow. However it's fine used thus: When the player is on the main screen (with an unmasked minimap) and moves around, black squares are drawn on the mask. But I only call your masking function when the player switches to the main map - which they would only do occasionally. This has a delay of approx two seconds which is acceptable (on the low spec laptop I use for development).


Ross C(Posted 2008) [#5]
You will be able to make it alot faster by using the 256 Force to VRAM flag, on your texture, when loading or creating it. It may be unstable though on some PC's with lower VRAM.