Code archives/Graphics/Smooth Fullscreen win8

This code has been declared by its author to be Public Domain code.

Download source code

Smooth Fullscreen win8 by jfk EO-111102013
As reported by win8 users, Flip and Vwait seem to be "broken" in that you only get 30 Hz and a jittering mess of a "Vsync". Here are two functions to replace the original ones. Basicly, bufferflipping is replaced by copying from back to front buffer, takes about 1ms here. Secnd, Vwait is replaced by observing the scanline directly to detect the vsync in a homebrew way. You can compare the result by renaming the function to fliip and back to flip..,
w=800:h=600
Graphics3D w,h,32,1
SetBuffer BackBuffer()
;SetBuffer FrontBuffer()

While KeyHit(1)<>1
 x=x+1
 If x >w Then x=0
 Color 0,0,0
 Rect 0,0,800,100,1
 Color 255,0,0
 Text 10,10,(MilliSecs()-t)
 ;Plot x,40
 ;Line x,0,x,100
 Rect x,0,w,100,1
 t=MilliSecs()
 Flip 1 
Wend
End

Function Flip(wait_sync)
 Local w=GraphicsWidth()
 Local h=GraphicsHeight()
 Local sc, old_sc
 If wait_sync<>0
  Repeat
   old_sc=sc
   Delay 1
   sc=ScanLine()
  Until (sc<old_sc) Or (KeyDown(1)=1)
 EndIf
 CopyRect 0,0,w,h,0,0,BackBuffer(),FrontBuffer()
End Function


Function VWait()
 Local sc, old_sc
 Repeat
  old_sc=sc
  Delay 1
  sc=ScanLine()
 Until (sc<old_sc) Or (KeyDown(1)=1)
End Function

Comments

SLotman2013
CopyRect solves the problem on Windows 8, but on Windows 7 and before, it makes things much, much slower and prone to bugs... so it's not a reliable solution.


jfk EO-111102013
that's true, it's only a work around. Additonally you may involve some os check and use it only in win8 fullscreen mode. more important is the substitute for vwait, since without a synced rate you can't do anything imho.


Code Archives Forum