Edit: SetBlend - set to solid when images are surely having no alpha (mainly rectangles) brings a slight improvement... but not everytime usable for my game being modifyable when it comes to data and images... but worth a try to optimizing it a bit.
The code below shows nearly no difference on my pcs - either the big-image is drawn or smaller parts (with 256x256).
bye
MB
The code below shows nearly no difference on my pcs - either the big-image is drawn or smaller parts (with 256x256).
SuperStrict Framework brl.GLMax2D Import brl.Max2D Import brl.d3d7max2d Import brl.glmax2d Import BRL.StandardIO Import brl.Random 'SetGraphicsDriver D3D7Max2DDriver(),0 SetGraphicsDriver GLMax2DDriver() Global g:TGraphics = Graphics(800, 600, 0, 60, 0) SetBlend ALPHABLEND Global ExitGame:Int = 0 Global GrafikFPS:Int = 0 Global tempGrafikFPS:Int = 0 Global LastSecondTime:Int = 0 Global FlipTime:Int =0 Global FlipTimeSum:Int =0 Global FlipCount:Int =0 Global AvgFlipTime:Int =0 Global DrawTime:Int =0 Global DrawTimeSum:Int =0 Global DrawCount:Int =0 Global AvgDrawTime:Int =0 'creating images '=============================================== Global gfx_building_house:TImage = CreateImage(512,1080) Local Pix:TPixmap = LockImage(gfx_building_house) For Local i:Int = 0 To 512 -1 For Local j:Int = 0 To 1080 -1 WritePixel(Pix, i, j, (Int(255*$1000000)+Int(0*$10000)+Int(Rand(255)*$100)+Int(0))) Next Next UnlockImage(gfx_building_house) Global gfx_building_houseA:TImage[8] For Local i:Int = 0 To 7 gfx_building_houseA[i] = CreateImage(256,256) Pix = LockImage(gfx_building_houseA[i]) For Local i:Int = 0 To 255 For Local j:Int = 0 To 255 WritePixel(Pix, i, j, (Int(255*$1000000)+Int(0*$10000)+Int(Rand(255)*$100)+Int(0))) Next Next UnlockImage(gfx_building_houseA[i]) Next '=============================================== Global UseBigImage:Byte =0 Function DrawMain() Cls SetColor 255,255,255 'try increasing the loop-amount here... it affects the FlipTime-value DrawTime = MilliSecs() For Local i:Int = 0 To 100 SetViewport(10,10,780,373) If UseBigImage DrawImage(gfx_building_house, 127, -420) Else DrawImage(gfx_building_houseA[0], 127 , -420) DrawImage(gfx_building_houseA[1], 127+256, -420) DrawImage(gfx_building_houseA[2], 127 , -420+1*256) DrawImage(gfx_building_houseA[3], 127+256, -420+1*256) DrawImage(gfx_building_houseA[4], 127 , -420+2*256) DrawImage(gfx_building_houseA[5], 127+256, -420+2*256) DrawImage(gfx_building_houseA[6], 127 , -420+3*256) DrawImage(gfx_building_houseA[7], 127+256, -420+3*256) EndIf SetViewport(0,0,800,600) Next DrawTime = MilliSecs()-DrawTime DrawTimeSum:+ DrawTime DrawCount:+1 SetColor 0,0,0; DrawRect(10,15,170,120); SetColor 255,255,255 DrawText ("FlipTime: "+FlipTime + "ms", 15,20) DrawText ("AvgFlipTime: "+AvgFlipTime + "ms", 15,35) DrawText ("DrawTime: "+DrawTime + "ms", 15,50) DrawText ("AvgDrawTime: "+AvgDrawTime + "ms", 15,65) DrawText ("FPS: "+GrafikFPS, 15,80) DrawText ("<b> to switch", 15,110) If UseBigImage Then DrawText ("using: big Image", 15,95) Else DrawText ("using: 256x256", 15,95) FlipTime = MilliSecs() Flip 0 FlipTime = MilliSecs()-FlipTime FlipTimeSum:+ FlipTime FlipCount:+1 Delay(1) EndFunction Repeat Local NowSecondTime:Int = MilliSecs() If KeyHit(KEY_ESCAPE) ExitGame = 1;Exit If KeyHit(KEY_B) UseBigImage = 1-UseBigImage DrawMain() tempGrafikFPS:+1 'calculating FPS and average FlipTime If NowSecondTime-LastSecondTime > 1000 Then GrafikFPS = Ceil((tempGrafikFPS*1000) / (NowSecondTime-LastSecondTime-tempGrafikFPS)) LastSecondTime = NowSecondTime If FlipCount > 0 Then AvgFlipTime = Ceil(FlipTimeSum*100 / FlipCount)/100 FlipTimeSum = 0 FlipCount = 0 If DrawCount > 0 Then AvgDrawTime = Ceil(DrawTimeSum*100 / DrawCount)/100 DrawTimeSum = 0 DrawCount = 0 tempGrafikFPS = 0 EndIf Until AppTerminate() Or ExitGame = 1
bye
MB