Sprite Masking problem

Blitz3D Forums/Blitz3D Programming/Sprite Masking problem

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Me again. Here's a sample program to illustrate the problem. Set the constant at the top to 48, run it, and use the arrow keys to rotate, and the label looks good but has a black box around it. Change the constant to 52, and you should see the weird behavior I described above, rather than the black box just being transparent.

---

; This value is the oddball... I need Clamp U and Clamp V flags turned on, so it should be 16+32=48.
; When I turn on masking (4) and use a value of 52, it halves my text and adds a black box.

Global mode = 48 ; switch this between 48 and 52

Global camera_obj
Global light_obj
Global sphere_obj
Global sprite_obj
Global sphere2_obj

Global rot

Global scrap



; initialize graphics modes

Graphics3D maxx, maxy, 16, 1
SetBuffer BackBuffer()



; define camera and light

camera_obj = CreateCamera()
PositionEntity camera_obj, 0, 0, -10

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


; define spheres

sphere_obj = CreateSphere()

sphere2_obj = CreateSphere()
PositionEntity sphere2_obj, -1, -1.5, 5


; draw sphere's label on screen and copy it into texture
; define the label as being 256 pixels across and 32 down

scrap = CreateTexture (256, 32, mode)


; draw the text on this label, then use copyrect to put it in the texture buffer

Cls
Text 128, 0, "This is a sphere", 1
CopyRect 0, 0, 256, 32, 0, 0, BackBuffer(), TextureBuffer(scrap)


; create label sprite and texture it with "scrap"

label_obj = CreateSprite()
PositionEntity label_obj, 0, -1.5, 0
ScaleSprite label_obj, 4, 0.5
EntityTexture label_obj, scrap


; we don't need scrap anymore - clear it out

FreeImage scrap


; draw the world

While Not KeyHit(1)

PositionEntity camera_obj, 0, 0, 0
RotateEntity camera_obj, 0, rot, 0
MoveEntity camera_obj, 0, 0, -10

RenderWorld()
Flip

If KeyDown(203) Then
rot = (rot-2) Mod 360
End If
If KeyDown(205) Then
rot = (rot+2) Mod 360
End If

Wend