News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Screen/Image Direct Memory Access

Started by kevin, February 28, 2007, 08:45:14 AM

Previous topic - Next topic

kevin

 This Tidbit shows how you can use GetImagePtr to access the backbuffer directly.

PlayBASIC Code: [Select]
ScreenWidth      =640
ScreenHeight =400

openscreen ScreenWidth,ScreenHeight,32,1


Dim Ptr as pointer

if GetScreenDepth()=32
Lockbuffer
Ptr =getimageptr(0)
Pitch =getimagepitch(0)
Depth =getimagedepth(0)

For ylp=0 to ScreenHeight-1
Dim LinePtr as integer pointer
LinePtr =Ptr+Ylp*Pitch
For xlp=0 to ScreenWidth-1
*LinePtr=rgb(ylp,xlp*ylp,xlp)
LinePtr=LInePtr+1
next
next
UnLockbuffer
endif
print int(ptr)
print Pitch
print depth

sync
waitkey