I've finally learned how to use the pointers in DBP and have come up with a couple of cool-ish effects. First one is ASCII 3D and the second one is pixelisation.
3D ASCII:
set display mode 640,480,32
make object box 1,10,10,10
dim ASCII(640,480)
color backdrop 0
sync on
sync rate 0
do
x=x+2
y=y+3
z=z+1
rotate object 1,x,y,z
gosub RenderASCII
sync
loop
RenderASCII:
lock pixels
start=get pixels pointer()
repeatnumber=get pixels pitch()
bitsperpixel=bitmap depth()/8
for x=0 to 640 step 16
for y=0 to 480 step 16
pointer=start+y*repeatnumber+x*bitsperpixel
p=*pointer
c=(rgbr(p)+rgbg(p)+rgbb(p))
c=c/3
ASCII(x,y)=c
next y
next x
ink rgb(0,0,0),0
box 0,0,640,480
ink rgb(255,255,255),0
for x=0 to 640 step 16
for y=0 to 480 step 16
if ASCII(x,y)>200
center text x,y,"#"
else
if ASCII(x,y)>164
center text x,y,"+"
else
if ASCII(x,y)>84
center text x,y,"-"
else
if ASCII(x,y)>24
center text x,y,"."
`else
`center text x,y," "
endif
endif
endif
endif
next y
next x
unlock pixels
return
Pixelisation:
set display mode 640,480,32
make object box 1,10,10,10
dim Pixel(640,480,3)
color backdrop 0
sync on
sync rate 0
do
x=x+2
y=y+3
z=z+1
rotate object 1,x,y,z
gosub RenderPixels
sync
loop
RenderPixels:
lock pixels
start=get pixels pointer()
repeatnumber=get pixels pitch()
bitsperpixel=bitmap depth()/8
for x=0 to 640 step 16
for y=0 to 480 step 16
pointer=start+y*repeatnumber+x*bitsperpixel
p=*pointer
Pixel(x,y,0)=rgbr(p)
Pixel(x,y,1)=rgbg(p)
Pixel(x,y,2)=rgbb(p)
next y
next x
ink rgb(0,0,0),0
box 0,0,640,480
for x=0 to 640 step 16
for y=0 to 480 step 16
ink rgb(Pixel(x,y,0),Pixel(x,y,1),Pixel(x,y,2)),0
box x-8,y-8,x+8,y+8
next y
next x
unlock pixels
return