Hi,
In order to achieve transparency I usually do a writepixel with &0 to each and every pixel. That can take some time. So, I thought what I'd do was create a small texture (8x8), write each pixel to black and then copyrect that however many times needed to erase large textures.
It certainly sped things up but did not give me transparency. What am I doing wrong?
In order to achieve transparency I usually do a writepixel with &0 to each and every pixel. That can take some time. So, I thought what I'd do was create a small texture (8x8), write each pixel to black and then copyrect that however many times needed to erase large textures.
It certainly sped things up but did not give me transparency. What am I doing wrong?
Graphics3D 640,480,1 Const One%=1,Texture_EraserSize=8 Sprite1=CreateSprite() Sprite2=CreateSprite() Sprite1_Texture=CreateTexture(64,64,2) Sprite2_Texture=CreateTexture(64,64,2) Repeat Choice$=Upper(Input("Mask by Blocks/Pixels (B/P)")) Select Choice Case "B" Initialise_TextureBlocks Sprite1_Texture Exit Case "P" Initialise_TexturePixels Sprite1_Texture Exit End Select Forever White=GetRGB(255,255,255) SetBuffer TextureBuffer(Sprite2_Texture) For LoopX=29 To 39 For LoopY=False To 63 WritePixel LoopX,LoopY,White Next Next For LoopY=29 To 39 For LoopX=False To 63 WritePixel LoopX,LoopY,White Next Next SetBuffer BackBuffer() EntityTexture Sprite1,Sprite1_Texture EntityTexture Sprite2,Sprite2_Texture CreateCamera() PositionEntity Sprite1,0,0,5 PositionEntity Sprite2,0,0,6 While Not KeyDown(One) RenderWorld VWait Flip False Wend End Function Initialise_TextureBlocks(TextureNo) TextureEraser=CreateTexture(Texture_EraserSize,Texture_EraserSize) Initialise_TexturePixels TextureEraser NoPels=Texture_EraserSize-One XLimit=Texturewidth(TextureNo)-One YLimit=Textureheight(TextureNo)-One For LoopX=False To XLimit Step Texture_EraserSize For LoopY=False To YLimit Step Texture_EraserSize CopyRect False,False,NoPels,NoPels,LoopX,LoopY,TextureBuffer(TextureEraser),TextureBuffer(TextureNo) Next Next FreeTexture TextureEraser End Function Function Initialise_TexturePixels(TextureNo) IHeight=TextureHeight(TextureNo)-One IWidth=TextureWidth(TextureNo)-One SetBuffer TextureBuffer(TextureNo) LockBuffer TextureBuffer(TextureNo) For LoopX = False To IWidth For LoopY=False To IHeight WritePixelFast LoopX,LoopY,False Next Next UnlockBuffer TextureBuffer(TextureNo) SetBuffer BackBuffer() End Function Function GetRGB%(Red%,Green%,Blue%) Return 255 Shl 24 + Red Shl 16 + Green Shl 8 + Blue End Function