Author Topic: Fast Screen Updates  (Read 409 times)

0 Members and 1 Guest are viewing this topic.

Offline rdc

  • Pentium
  • *****
  • Posts: 1480
  • Karma: 138
    • View Profile
    • Clark Productions
Fast Screen Updates
« on: June 25, 2009 »


A little example of using pointers and memcpy to speed up screen updates.

Code: [Select]
#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

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 16787
  • Karma: 439
  • evil/good
    • View Profile
    • My Homepage
Re: Fast Screen Updates
« Reply #1 on: June 25, 2009 »
Would work nice for drawing background graphics as well, nice one Rick :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline rdc

  • Pentium
  • *****
  • Posts: 1480
  • Karma: 138
    • View Profile
    • Clark Productions
Re: Fast Screen Updates
« Reply #2 on: June 25, 2009 »
Thanks.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7145
  • Karma: 69
    • View Profile
Re: Fast Screen Updates
« Reply #3 on: June 25, 2009 »
Nice one RDC, i've been learning a similar system for Gravity.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won: