Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: rdc on June 25, 2009
-
A little example of using pointers and memcpy to speed up screen updates.
#Include "fbgfx.bi"
#Include "crt.bi"
#Define sw 640
#Define sh 480
ScreenRes sw, sh, 32
Dim buffer As UInteger Ptr
buffer = Callocate(sw * sh, SizeOf(UInteger))
For y As Integer = 0 To sh - 1
For x As Integer = 0 To sw - 1
'Write to buffer.
buffer[y * sw + x] = RGB(0, 255, 0)
Next
Next
'Copy buffer to screen.
ScreenLock
memcpy ScreenPtr, buffer, sw*sh*4
ScreenUnLock
Sleep
-
Would work nice for drawing background graphics as well, nice one Rick :)
-
Thanks.
-
Nice one RDC, i've been learning a similar system for Gravity.