I just made this little tester, inspired by MGE and our research to figure out what funky things happen on different machines. Only very little differences can screw up performances on "perfect" machines, while running perfect on "crappy" machines, while the other way around is even more shocking and I'm dealing with that for the past few weeks or rather months since I've started with Bmax.
However, I got a little carried away and wrote this, which I think is gonna be fun for all of you. It contains creation routines for 3d looking balls, pretending volume by 3d shading and procedural normal creation. (very cheap, but cute!)
I've added even a fake highlight, which is particularely cute, while naturally nowhere near perfect. However, it performs brilliantly on my machine and offers a few different toggle modes...(I keep writing toogle, too weird?!).
So, yeah, have fun with this one... hopefully it may even inspire a little bit?
I never know how good my programming is, so I'm always a little hesitant to impose with this stuff, but here's a list of things I find neat in there:
- procedural ball creation with soft edge antialiasing and lighting
- useful little vector type
- vector to degree conversion
- nice and simple framework (I think it's a great starting point!)
- neat trick I figured out to toggle ( toggle:~1 )
...there maybe a few more curious things in there, good and bad...
As for the testing, I'd be already just happy to read whether it ran smooth or not. I realized that fps reports are not always enough of a clue. Let me know, if vertical blank [on] is true to your desktop framerate (ordinarily 60 nowadays], please.
You may just change the amount_of_sprites in there and let me know at what point it stops performing fine?!
Thanks in advance and have fun with it! 8)
However, I got a little carried away and wrote this, which I think is gonna be fun for all of you. It contains creation routines for 3d looking balls, pretending volume by 3d shading and procedural normal creation. (very cheap, but cute!)
I've added even a fake highlight, which is particularely cute, while naturally nowhere near perfect. However, it performs brilliantly on my machine and offers a few different toggle modes...(I keep writing toogle, too weird?!).
So, yeah, have fun with this one... hopefully it may even inspire a little bit?
I never know how good my programming is, so I'm always a little hesitant to impose with this stuff, but here's a list of things I find neat in there:
- procedural ball creation with soft edge antialiasing and lighting
- useful little vector type
- vector to degree conversion
- nice and simple framework (I think it's a great starting point!)
- neat trick I figured out to toggle ( toggle:~1 )
...there maybe a few more curious things in there, good and bad...
As for the testing, I'd be already just happy to read whether it ran smooth or not. I realized that fps reports are not always enough of a clue. Let me know, if vertical blank [on] is true to your desktop framerate (ordinarily 60 nowadays], please.
You may just change the amount_of_sprites in there and let me know at what point it stops performing fine?!
Thanks in advance and have fun with it! 8)
SuperStrict Framework brl.GLMax2D Import brl.StandardIO '--------------------------------------------------------------' '"Got Balls?" ' 'A little benchmark routine for smoothness and consistency of ' 'frames per second (fps) on any system... (www.taron.de) ' '--------------------------------------------------------------' '(feel free to use my balls any time you like!) '------------------------------- set graphics Graphics(800,600,0,60) SetGraphicsDriver GLMax2DDriver() AutoMidHandle(1) '------------------------------- create image of lit ball Local size:Int =64 Local half:Int = size Shr 1 Global blob:TImage = CreateImage(size,size,1,FILTEREDIMAGE) Local bpix:TPixmap = LockImage(blob,0) Local normal:vec = vec.Create() Local light:vec = vec.Create() light.x = 0.0;light.y = 0.5;light.z = +0.4;light.normalize3d() Local rgb:Int For Local y:Byte = 0 Until size For Local x:Byte = 0 Until size normal.x = x-half normal.y = y-half Local alpha:Int = $ff-(Int(normal.x*normal.x+normal.y*normal.y)Shr 2) If alpha<0 Then alpha = 0 Else alpha:*8 If alpha>255 Then alpha = 255 normal.x :/half normal.y :/half normal.z = (1.0-(normal.x*normal.x+normal.y*normal.y))^0.5 normal.normalize3d() rgb = normal.dot3d(light)*$ff If rgb <0 Then rgb = 0 rgb = rgb | (rgb Shl 8) | (rgb Shl $10) WritePixel(bpix,x,y,(alpha Shl $18)|rgb) Next Next UnlockImage(blob,0) '------------------------------- create image of funny highlight Global spec:TImage = CreateImage(16,16,1,FILTEREDIMAGE) bpix = LockImage(spec,0) For Local y:Byte = 0 Until 16 For Local x:Byte = 0 Until 16 normal.x = x-8 normal.y = y-8 Local alpha:Int = $ff-(Int(normal.x*normal.x+normal.y*normal.y)Shl 2) If alpha<0 Then alpha = 0 WritePixel(bpix,x,y,(alpha Shl $18)|$ffffff) Next Next UnlockImage(spec,0) bpix = Null GCCollect() '------------------------------- LITTLE (2d/3d) VECTOR TYPE Type vec Field x:Float Field y:Float Field z:Float Field length:Float Field dot:Float Method dot2d:Float(v:vec) dot = x*v.x + y*v.y Return dot End Method Method dot3d:Float(v:vec) dot = x*v.x+ y*v.y + z*v.z Return dot End Method Method normalize2d:Float() length = x*x+y*y If length length = Sqr(length) x:/length y:/length End If Return length End Method Method normalize3d() length = x*x+y*y+z*z If length length = Sqr(length) x:/length y:/length z:/length End If End Method Function Create:vec() Return New vec End Function End Type '------------------------------- SPRITE TYPE Type sprite Global splist:TList = CreateList() Field pos:vec Field loc:vec Field col:vec Field rot:Float Method draw() pos.x:+ loc.x pos.y:+loc.y Local dir:vec = vec.Create() dir.x = center.x-pos.x dir.y = center.y-pos.y Local dist:Float = dir.normalize2d() rot = ACos(dir.y) If dir.x>0 Then rot = ACos(-dir.y)+180 SetRotation rot dir.length= $ff - dir.length/8 Local fade:Float = dir.length/$ff SetColor col.x*dir.length,col.y*dir.length*fade,col.z*dir.length*fade^2 SetBlend ALPHABLEND DrawImage(blob,0.5*pos.x,0.5*pos.y,0) SetColor $ff,$ff,$ff SetBlend LIGHTBLEND SetAlpha 0.4*dir.length/$ff SetScale 1.0,1.0-(dist/800) DrawImage(spec,0.5*pos.x+dir.x*dist*0.025,0.5*pos.y+dir.y*dist*0.025,0) SetScale 1,1 SetAlpha 1.0 End Method Function Create:sprite(l:vec) Local s:sprite = New sprite s.pos = vec.Create() s.loc = vec.Create() s.loc.x = l.x s.loc.y = l.y s.rot = 0 s.col = vec.Create() s.col.x = (l.x *0.3) Mod 1 s.col.y = (l.y *0.733) Mod 1 s.col.z = (l.y+l.x *1.33) Mod 1 ListAddLast splist,s Return s EndFunction EndType '------------------------------- create & distribute sprites Const amount_of_sprites:Int = 500 Local rep:Int = Sqr(amount_of_sprites) Local location:vec = vec.Create() For Local y:Int = 0 Until rep For Local x:Int = 0 Until rep location.x=32+x*32 location.y=32+y*32 sprite.Create(location) Next Next '------------------------------- main loop Local onoff:String[]=["off","on"] Global center:vec = vec.Create() Local sp:sprite Local fs:Byte = 0 Local vb:Byte = 1 Local fps:Int = 0 Local frames:Int = 0 Local dt:Int = 0 Local t:Int = MilliSecs() Local acc:Int = 0 Repeat dt:+ MilliSecs()-t t = MilliSecs() frames:+1 If dt>1000 fps = frames frames = 0 dt = 0 End If SetBlend ALPHABLEND SetAlpha 0.5 SetColor 0,0,0 DrawRect (0,0,800,600) SetAlpha 1.0 center.x=400+Sin(acc)*200 center.y=300+Cos(acc)*200 Local i:Int = 0 For sp = EachIn sp.splist sp.pos.x:*Sin(acc+i*13)*Cos(i) sp.pos.y:*Cos(acc+i*13)*Sin(acc) sp.draw() i:+1 Next acc:+2 SetColor $ff,$ff,$ff SetRotation 0 DrawText "FPS: "+fps,530,500 SetAlpha 0.2 DrawText "'v' toggles vertical blank ["+onoff[vb]+"]",530,520 DrawText "'f' toggles fullscreen",530,540 If KeyHit(KEY_V) Then vb:~1 If KeyHit(KEY_F) fs:~1 If fs Then Graphics(800,600,32,60) Else Graphics(800,600,0,60) EndIf Flip vb Until KeyHit(KEY_ESCAPE) EndGraphics() End