Lag Fix ... Back to the drawing board

BlitzMax Forums/BlitzMax Programming/Lag Fix ... Back to the drawing board

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Yeah locking and unlocking does the job nicely
Strict

Graphics 800,600,0

AutoMidHandle True
Local fix = 0

Local mx = 300
Local my = 200

Local info:DDSURFACEDESC2=New DDSURFACEDESC2

While Not KeyHit(KEY_ESCAPE)
  Cls
  
  If KeyHit(KEY_SPACE) Then fix = 1 - fix
  
  If KeyDown(KEY_Z) Then mx = mx - 10
  If KeyDown(KEY_X) Then mx = mx + 10
  
  For Local i = 0 To 2000
	DrawRect mx,my,200,200
  Next
  
  SetScale 1, 1
  DrawText "Fix = " + fix, 12, 12

  Flip

  If fix
    If TD3D7Max2DDriver(_max2dDriver)
		DoLock()
    EndIf
  EndIf
Wend


Function DoLock()
	Local sdesc:DDSurfaceDesc2=New DDSurfaceDesc2
	sdesc.dwSize=SizeOf(sdesc)
	Local res=PrimaryDevice.backbuffer.Lock(Null,sdesc,DDLOCK_WAIT|DDLOCK_READONLY,Null)
	PrimaryDevice.backbuffer.unlock(Null)
	Return res
End Function