Quote: "Purbasic <> DBPro"
Your analogy isn't exactly correct. PureBasic is not DBP but with PureGDK it gains all of the functionality of DBP. So in a sense it can still be used to illustrate a point.
Quote: "But that's besides the point, that is not a voxel demo."
The example I converted to PureGDK is a voxel landscape but it's a very simple representation with limited functionality. Its purpose was to illustrate that you could make one if you really wanted to.
You can inspect the code for yourself. It is a voxel demo (it's just not a very good one):
;/ Simple Voxel engine
;/
;/ done by TheWanderer on Amiga
;/ converted to TLib by jhd
;/ converted/speedup to PureBasic by jhd
;/ converted to Purebasic/PureGDK by Mistrel
Declare voxel_show(winkel.f, hoehe.f)
Declare pDot(x, y, color)
#gXd=400;512
#gYd=400;512
Global blickhoehe.f, blickwinkel.f,blickwinkel_grad.f
Global grwh.f: grwh=#gXd/2
Global grhh.f: grhh=#gYd/2
Global px.f,pz.f
Global Dim pic(255,255)
LoadImage(0,"height5.bmp")
StartDrawing(ImageOutput(0))
For y=0 To 255
For x=0 To 255
col=Point(x,y)
pic(x,y)=Red(col)
Next
Next
StopDrawing()
Global Dim piccol(255,255)
LoadImage(0,"color5.bmp")
StartDrawing(ImageOutput(0))
For y=0 To 255
For x=0 To 255
piccol(x,y)=Point(x,y)
Next
Next
StopDrawing()
;/ Very simple voxel routine
Procedure voxel_show(winkel.f, hoehe.f)
dbLockPixels()
Pitch=dbGetPixelsPitch()
BitsPerPixel=dbBitmapDepth()/8
*BackBuffer=dbGetPixelsPointer()+(48*Pitch)
For i=-grwh To grwh ;/ Step 2
row.f=#gYd
grwh_mi.f=(grwh-i)
rayx.f=px.f
rayz.f=pz.f
stepx.f=Sin(winkel+0.00255*i)
stepz.f=Cos(winkel+0.00255*i)
count.f=1
While count<200 ;/ Sichtweite
rayx=rayx+stepx
rayz=rayz+stepz
If rayx>-grwh And rayx<grwh
If rayz>-grhh And rayz<grhh
xx=rayx+grwh
If xx<0
xx+255
ElseIf xx>255
xx-255
EndIf
yy=rayz+grhh
If yy<0
yy+255
ElseIf yy>255
yy-255
EndIf
c=pic(xx,yy)
h.f=((24000.0-hoehe*100)/count)-((0.15*hoehe+40)*c)/count
col =piccol(xx,yy)
If h<row
;/ Paint vertical voxel
x.f=grwh_mi
If x<620 And row<420
For y=h To row-1 ;/ Step 2
pDot(x, y, col)
;dbDot(x,y,col)
Next y
EndIf
row=h
EndIf
EndIf
EndIf
count+0.5
Wend
Next
dbUnlockpixels()
EndProcedure
Procedure pDot(x, y, color)
Static *PixelsPointer,Pitch,Bpp,SceenWidth,ScreenHeight
If Not *PixelsPointer
*PixelsPointer=dbGetPixelsPointer()
Pitch=dbGetPixelsPitch()
Bpp=dbBitmapDepth()/8
SceenWidth=dbScreenWidth()
SceenHeight=dbScreenHeight()
EndIf
If x>0 And x<400 And y>0 And y<400
PokeI(*PixelsPointer+y*Pitch+x*Bpp,color)
EndIf
EndProcedure
;/ Open a PureBasic window
OpenWindow(0,0,0,400,400,"DarkBasic Professional-PureGDK",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
;/ Initialize the PureGDK screen as a child of window ID 0
hDBWnd=OpenDBWnd(WindowID(0),0,0,400,400)
Repeat
dbCLSFill(dbRGB(200,180,190))
blickhoehe.f=dbMouseY()
If blickhoehe>100: blickhoehe=100:EndIf
demo_counter.f=(demo_counter+0.5)
demo_winkel.f=(demo_counter*#PI/180)
blickwinkel=Sin(demo_winkel) -Cos(demo_winkel)
px.f+(Sin(demo_winkel)/4-Cos(demo_winkel))
pz.f+(Cos(demo_winkel)/4-Sin(demo_winkel))
voxel_show(blickwinkel, blickhoehe)
dbSync()
Until WindowEvent()=#WM_CLOSE Or dbKeyState(#VK_ESCAPE)
End
