Hi,
Is there a way to use the WritePixel command to paint a preset texture onto another texture, like a stamp?
Is there a way to use the WritePixel command to paint a preset texture onto another texture, like a stamp?
ApplyDecal source_texture , dest_texture [,r,g,b]Both 'texture' parameters should point to a loaded texture.


; Applying a DECAL to a texture ; Syntax Error Graphics3D 640,480 SetBuffer BackBuffer() cam=CreateCamera() : light=CreateLight() cube=CreateCube() : MoveEntity cube,0,0,4 cubetex=LoadTexture("wood.jpg") EntityTexture cube,cubetex decal=LoadTexture("decal.png") Repeat TurnEntity cube,0.5,0.6,0.7 If KeyHit(57) ApplyDecal decal,cubetex ,255,0,255 RenderWorld Text 10,10,"Press [SPACE] to apply the decal ..." Flip Until KeyHit(1) End ; Apply source texture to destination texture (with optional masking) Function ApplyDecal(sourceb,destb,maskR=0,maskG=0,maskB=0) Local gb=GraphicsBuffer() , rgb Local sb=TextureBuffer(sourceb) , db=TextureBuffer(destb) Local maxw=TextureWidth(sourceb) , maxh=TextureHeight(sourceb) If TextureWidth(destb)<maxw Then maxw=TextureWidth(destb) If TextureHeight(destb)<maxh Then maxh=TextureHeight(destb) LockBuffer sb : LockBuffer db For x=0 To maxw-1 For y=0 To maxh-1 rgb=ReadPixelFast(x,y,sb) And $00FFFFFF If Not rgb=((maskR Shl 16)+(maskG Shl 8)+maskB) WritePixelFast x,y,(rgb Or $FF000000),db EndIf Next Next UnlockBuffer sb : UnlockBuffer db SetBuffer gb End Function