I was hoping for equivalent terrain performance by using the SDK with BlitzMax vs Blitz3D but it seems approximately 50% slower in any mode (debug/non-debug, windowed/fullscreen)
Example code:
BlitzMax:
Blitz3D:
I’m achieving 190fps in BlitzMax vs 360fps in Blitz3D. Can anyone else test on their system?
My system: Athlon 3200+, 256MB ATI X800GT.
Example code:
BlitzMax:
SuperStrict Import blitz3d.blitz3dsdk bbBeginBlitz3D() bbGraphics3D 800, 600, 32, 1 bbSetBuffer bbBackBuffer() bbAmbientLight 255, 255, 255 Local Camera:Int = bbCreateCamera() bbCameraClsColor Camera, 128, 128, 255 Local hmap_url:String = AppDir + "\temp_hmap.png" CreateSampleHeightMap 256, 256, 1000, 32, False, hmap_url Local scale:Float = 10.0 Local Terrain:Int = bbLoadTerrain(hmap_url) bbTerrainDetail Terrain, 4000, True bbScaleEntity Terrain, scale, 100.0, scale Local ts:Float = bbTerrainSize(Terrain) Local Ground:Int = bbLoadTexture(hmap_url) bbScaleTexture Ground, ts, ts bbEntityTexture Terrain, Ground bbPositionEntity Camera, ((ts * scale) / 2.0), 0.0, ((ts * scale) / 2.0) Local mxs:Int, mys:Int Local renders:Int, old_ms:Int, fps:Int While Not bbKeyHit(1) mxs :+ (bbMouseXSpeed() / 3.0) mys :+ (bbMouseYSpeed() / 3.0) bbRotateEntity Camera, mys, -mxs, 0.0 bbMoveMouse bbGraphicsWidth() / 2, bbGraphicsHeight() / 2 bbMouseXSpeed() bbMouseYSpeed() If bbKeyDown(200) Or bbKeyDown(17) Or bbMouseDown(2) Then bbMoveEntity Camera, 0.0, 0.0, 0.1 If bbKeyDown(208) Or bbKeyDown(31) Then bbMoveEntity Camera, 0.0, 0.0, -0.1 If bbKeyDown(32) Then bbMoveEntity Camera, 0.1, 0.0, 0.0 If bbKeyDown(30) Then bbMoveEntity Camera, -0.1, 0.0, 0.0 Local x:Float = bbEntityX(Camera) Local y:Float = bbEntityY(Camera) Local z:Float = bbEntityZ(Camera) Local terra_y:Float = bbTerrainY(Terrain, x, y , z) + 2.5 bbPositionEntity Camera, x, terra_y, z bbRenderWorld renders :+ 1 If MilliSecs() -old_ms >= 1000 old_ms = MilliSecs() fps = renders renders = 0 EndIf bbText 5, 5, "FPS: " + fps bbFlip False Wend bbEndBlitz3D() End Function createSampleHeightMap:Float[,](width:Int = 128, height:Int = 128, numhills:Int = 1000, maxhsize:Int = 32, island:Int = True, fname:String = "") 'Generate Local Map:Float[width, height] SeedRnd(MilliSecs()) If island numhills :* 0.2 maxhsize :* 0.5 EndIf For Local n:Int = 1 To numhills Local radius:Int = Rand(0, maxhsize) Local centrex:Int = Rand(0, Width - 1) Local centrez:Int = Rand(0, Height - 1) If island Local theta:Int = Rand(0, 359) Local distx:Int = Rand(0, (Width * 0.5) - radius) Local distz:Int = Rand(0, (Height * 0.5) - radius) centrex = (Width * 0.5) + (Cos(theta) * distx) centrez = (Height * 0.5) + (Sin(theta) * distz) EndIf Local startx:Int = centrex - radius If startx < 0 startx = 0 Local endx:Int = centrex + radius If endx > Width endx = Width Local startz:Int = centrez - radius If startz < 0 startz = 0 Local endz:Int = centrez + radius If endz > Height endz = Height For Local x:Int = startx To (endx - 1) For Local z:Int = startz To (endz - 1) Local y:Float = (radius * radius) - (((x - centrex) * (x - centrex)) + ((z - centrez) * (z - centrez))) If y > 0.0 Map[x, z] :+ y Next Next Next 'Normalise Local minv:Float = 10^38, maxv:Float = 10^-38 For Local x:Int = 0 To (Width - 1) For Local z:Int = 0 To (Height - 1) If Map[x, z] < minv minv = Map[x, z] Else If Map[x, z] > maxv maxv = Map[x, z] Next Next For Local x:Int = 0 To (Width - 1) For Local z:Int = 0 To (Height - 1) Map[x, z] = (Map[x, z] - minv) / (maxv - minv) Next Next 'Convert to byte Array Local arr:Byte[,] = New Byte[width, height] For Local x:Int = 0 To (Width - 1) For Local z:Int = 0 To (Height - 1) Local v:Int = Floor(Map[x, z] * 255) arr[x, z] = Byte(v) Next Next 'Render to pixmap and save to file Local pm:TPixmap = CreatePixmap(width, height, PF_RGB888) For Local x:Int = 0 To (Width - 1) For Local z:Int = 0 To (Height - 1) WritePixel(pm, x, z, arr[x, z] Shl 16 | arr[x, z] Shl 8 | arr[x, z]) Next Next If fname Then SavePixmapPNG(pm, fname, 9) Return Map End Function
Blitz3D:
Graphics3D 800, 600, 32, 1 SetBuffer BackBuffer() AmbientLight 255, 255, 255 Local camera = CreateCamera() CameraClsColor Camera, 128, 128, 255 Local hmap_url$ = "temp_hmap.png" Local scale# = 10.0 Local Terrain = LoadTerrain(hmap_url$) TerrainDetail Terrain, 4000, True ScaleEntity Terrain, scale, 100.0, scale Local ts# = TerrainSize(Terrain) Local Ground = LoadTexture(hmap_url$) ScaleTexture Ground, ts, ts EntityTexture Terrain, Ground PositionEntity Camera, ((ts * scale) / 2.0), 0.0, ((ts * scale) / 2.0) Local mxs, mys Local renders, old_ms, fps While Not KeyHit(1) mxs = mxs + (MouseXSpeed() / 3.0) mys = mys + (MouseYSpeed() / 3.0) RotateEntity camera, mys, -mxs, 0.0 MoveMouse GraphicsWidth() / 2, GraphicsHeight() / 2 MouseXSpeed() MouseYSpeed() If KeyDown(200) Or KeyDown(17) Or MouseDown(2) Then MoveEntity Camera, 0.0, 0.0, 0.1 If KeyDown(208) Or KeyDown(31) Then MoveEntity Camera, 0.0, 0.0, -0.1 If KeyDown(32) Then MoveEntity Camera, 0.1, 0.0, 0.0 If KeyDown(30) Then MoveEntity Camera, -0.1, 0.0, 0.0 Local x# = EntityX(Camera) Local y# = EntityY(Camera) Local z# = EntityZ(Camera) Local terra_y# = TerrainY(Terrain, x, y, z) + 2.5 PositionEntity Camera, x, terra_y, z RenderWorld renders = renders + 1 If MilliSecs() -old_ms >= 1000 old_ms = MilliSecs() fps = renders renders = 0 EndIf Text 5, 5, "FPS: " + fps Flip False Wend End
I’m achieving 190fps in BlitzMax vs 360fps in Blitz3D. Can anyone else test on their system?
My system: Athlon 3200+, 256MB ATI X800GT.