Re: 2D drawing slow as hell
Posted: Mon Sep 26, 2011 7:44 pm
Write to the "windowoutput" rather than screenoutput. The first example gives me 305fps on a 2.4ghz Core2Duo using the onboard intel G31 vga. The code below gives me 850fps but the text has a slight flicker.
Code: Select all
#screenwidth = 640
#screenheight = 480
InitSprite()
OpenWindow(0, 0, 0, #screenwidth, #screenheight, "PB Drawing", #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget)
OpenWindowedScreen(WindowID(0), 0, 0, #screenwidth, #screenheight, 0, 0, 0, #PB_Screen_NoSynchronization)
fpscounter.i = 0
timer.i = 0
fps.i = 0
frames.i = 0
totalTime.l = 0
curTime.l = ElapsedMilliseconds()
Repeat
lastTime = curTime
curTime = ElapsedMilliseconds()
totalTime + (curTime-lastTime)
If(totalTime>1000)
totalTime-1000
fps = frames
frames = 0
EndIf
frames + 1
StartDrawing(WindowOutput(0))
For i = 0 To 20
Box(Random(320), Random(240), Random(320), Random(240), Random($FFFFFF) )
Next i
DrawText(20, 430, Str(fps))
StopDrawing()
FlipBuffers()
Until WindowEvent() = #PB_Event_CloseWindow