Problem with TextureBuffer() ?

Blitz3D Forums/Blitz3D Programming/Problem with TextureBuffer() ?

Guy Fawkes(Posted 2014) [#1]
Hi all. I was finishing work on the progress bar code on my other thread & needed to turn it into a "live texture" (in other words, it's a texture that automatically animates when applied to a model), when I noticed for some reason that the texture won't show up on the "quad" or flat cube as a transparent texture no matter what I try.

Can someone please tell me how to fix this?



Thank You so kindly! :)

~GF


Floyd(Posted 2014) [#2]
Transparency came up recently in another thread: here.

I put my code into a function called CreateTestTexture( ). Use that to create the bartex texture to get an idea of how it works.

Function CreateTestTexture( )

	tex=CreateTexture( 256,256, 1 + 2 + 16 + 32 )  ; color + alpha + clamp u + clamp v
	
	SetBuffer TextureBuffer( tex )
	For x = 0 To 255
		For y = 0 To 255
			WritePixel x, y, (x Shl 24) + $FFFF00  ; alpha=x  R=255 G=255 B=0
		Next
	Next
	
	img = CreateImage( 200, 100 )
	SetBuffer ImageBuffer( img )
	Color 0,0,255
	tempFont = LoadFont( "arial", 80 )
	SetFont tempfont
	Text 0,0, "Hello"
	FreeFont tempfont
	
	imgbuff = ImageBuffer( img )
	texbuff = TextureBuffer( tex )
	For x = 0 To 199
		For y = 0 To 99
			imgpixel = ReadPixel( x, y, imgbuff ) And $FFFFFF  ; just the color data
			If imgpixel <> 0 
				texpixel = ReadPixel( x+50, y+90, texbuff ) And $FF000000  ; just alpha
				WritePixel x+50, y+90, texpixel + imgpixel, texbuff
			End If
		Next
	Next
	SetBuffer BackBuffer()
	FreeImage img
	
	Return tex
	
End Function



Guy Fawkes(Posted 2014) [#3]
Thanks ALOT, Floyd! This works PERFECTLY! :)

~GF


Guy Fawkes(Posted 2016) [#4]
Is there a way to make this work with any size texture?

Thanks, guys! :)

~GF


Matty(Posted 2016) [#5]
Use the width and height parameter of the create texture command.


RemiD(Posted 2016) [#6]
GF at his finest :)


Guy Fawkes(Posted 2016) [#7]
RemiD, being a d*** as always. Please leave if you're gonna do nothing but bash people.


Guy Fawkes(Posted 2016) [#8]
Thank You, Matty. :)

~GF


RemiD(Posted 2016) [#9]
Related to this topic : http://www.blitzbasic.com/Community/posts.php?topic=102563 (post#4)