Fade Screen speed challenge!

BlitzPlus Forums/BlitzPlus Programming/Fade Screen speed challenge!

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.

Yes you are probably right about the "pastime" thing, English isn't my first language :)

Its 3am and I couldn't sleep, so here is an example of doing pokeInt directly to the backbuffer and imagebuffers. Using pokeInt directly on the backbuffer doesn't work on all graphics cards from my experience, so its better to use imagebuffers and do drawimage or drawblock for this if you want to be sure.

Graphics 640,480,32,2

	; CREATE IMAGEBUFFER 1 AND STORE BANK LOCATION AND PITCH
	temp1 = CreateImage( 64, 64 )
	SetBuffer ImageBuffer( temp1 )
	LockBuffer ImageBuffer( temp1 )
	imagebank1 = LockedPixels()
	imagepitch1 = LockedPitch()
	UnlockBuffer ImageBuffer( temp1 )

	; CREATE IMAGEBUFFER 2 AND STORE BANK LOCATION AND PITCH
	temp2 = CreateImage( 64, 64 )
	SetBuffer ImageBuffer( temp2 )
	LockBuffer ImageBuffer( temp2 )
	imagebank2 = LockedPixels()
	imagepitch2 = LockedPitch()
	UnlockBuffer ImageBuffer( temp2 )

	; CREATE IMAGEBUFFER 3 AND STORE BANK LOCATION AND PITCH
	temp3 = CreateImage( 64, 64 )
	SetBuffer ImageBuffer( temp3 )
	LockBuffer ImageBuffer( temp3 )
	imagebank3 = LockedPixels()
	imagepitch3 = LockedPitch()
	UnlockBuffer ImageBuffer( temp3 )

	SetBuffer BackBuffer()
	While Not KeyHit(1)
	Cls

	; LOCK THE BUFFERS
	LockBuffer BackBuffer()
	LockBuffer ImageBuffer( temp1 )
	LockBuffer ImageBuffer( temp2 )
	LockBuffer ImageBuffer( temp3 )

	; MAKE WHITE NOICE BAR ON BACKBUFFER ON THE TOP OF THE SCREEN
		bank = LockedPixels()
		For y = 0 To 15
			Yoffset = y * LockedPitch()
			For x = 0 To 639
				col = Rnd( $FF )
				PokeInt bank, Yoffset + x * 4, col Shl 16 + col Shl 8 + col
			Next
		Next

	; MAKE RED NOISE IN IMAGEBUFFER 1
		For y = 0 To 63
			Yoffset = y * imagepitch1
			For x = 0 To 63
			PokeInt imagebank1, Yoffset + x * 4, Rnd( $FF ) Shl 16
			Next
		Next

	; MAKE GREEN NOISE IN IMAGEBUFFER 2
		For y = 0 To 63
			Yoffset = y * imagepitch2
			For x = 0 To 63
			PokeInt imagebank2, Yoffset + x * 4, Rnd( $FF ) Shl 8
			Next
		Next

	; MAKE BLUE NOISE IN IMAGEBUFFER 3
		For y = 0 To 63
			Yoffset = y * imagepitch3
			For x = 0 To 63
			PokeInt imagebank3, Yoffset + x * 4, Rnd( $FF )
			Next
		Next

	; UNLOCK THE BUFFERS
	UnlockBuffer ImageBuffer( temp3 )
	UnlockBuffer ImageBuffer( temp2 )
	UnlockBuffer ImageBuffer( temp1 )
	UnlockBuffer BackBuffer()

	; DRAW THE 3 IMAGES ONTO THE SCREEN
	DrawBlock temp1, 288 + Cos( angle ) * 100, 208 + Sin( angle ) * 100
	DrawBlock temp2, 288 + Cos( angle+120 ) * 100, 208 + Sin( angle+120 ) * 100
	DrawBlock temp3, 288 + Cos( angle+240 ) * 100, 208 + Sin( angle+240 ) * 100

	; CHANGE THE ANGLE
	angle = angle + 3 : If angle > 359 Then angle = angle - 360

	Flip
Wend
; FREE THE IMAGES
FreeImage temp1
FreeImage temp2
FreeImage temp3
End


[edit]
This will work with B3D as well using that lockedpixels lib that Andreas made which I linked to previously.