Real VSYNC? (not just fps limit or/and deltatime)

Previous topic - Next topic

SnooPI

in french:
Aurez-vous l'équivalent de cette fonction de glfw dans glbasic ?
Parce que l'animation (scrolling par exemple) n'est pas totalement lisse dans glbasic  :(

in english:
Will you have the equivalent of this glfw function in glbasic?
Because the animation (scrolling for example) are not totally smooth in glbasic  :(


void glfwSwapInterval( int interval )
Parameters : interval
Minimum number of monitor vertical retraces between each buffer swap performed by
glfwSwapBuffers. If interval is zero, buffer swaps will not be synchronized to the vertical
refresh of the monitor (also known as 'VSync off').



SHOWSCREENINTERVAL ?  ;)


SnooPI

in french:
Avec glfwSwapInterval (1) le programme est parfaitement synchronisé avec la carte vidéo.
Pas avec LIMITFPS -1 (et l'utilisation de deltaTime) :(

in english:
With glfwSwapInterval(1) the program is perfectly synchronised with the video card
Not with LIMITFPS -1 (and use of deltatime) :(

Kitty Hello

But it might be 50, 60 or 100. You cam change in gfx card options.

SnooPI

in french:
Non, je ne parle pas de cela.
Regarde cet exemple (dérivé de l'exemple WideScroller)
Le scrolling n'est pas complètement fluide.  :(

in english:
No, I'm not talking about that.
Look at this sample (derived of  the WideScroller sample)
The scrolling is not completely fluid.  :(

Code (glbasic) Select

WideScroller("Media/test.txt")

FUNCTION WideScroller: filename$
LOCAL text$[], a$, maxline, z, dz, dx, y, fx, fy
DIM text$[256]

GETFONTSIZE fx, fy
fy=fy+8

FOR i=0 TO 255
GETFILE filename$, i, a$
IF a$="NO_FILE" THEN RETURN
IF a$="NO_DATA" THEN GOTO skip
text$[i]=a$
maxline=maxline+1
NEXT

skip:
zt0=-maxline*fy
    zt1=480
LIMITFPS -1

    WHILE KEY(57)=FALSE AND KEY(28)=FALSE     
    dtime=GETTIMER()
       
    zt1=zt1-(dtime/8)
       
FOR z=0 TO maxline-1
dz=z*20+zt1
dx=(640-LEN(text$[z])*fx)/2
IF dz<480 AND dz>-20 THEN PRINT text$[z], dx, dz
NEXT

fps=((1000/dtime)+fps)/2
delay=delay+dtime
IF delay>1000
delay=0
ShowFPS=fps
ENDIF
PRINT "FPS: "+INTEGER(ShowFPS), 100, 100

SHOWSCREEN

    IF zt1<=zt0 THEN zt1=480
WEND
ENDFUNCTION



SnooPI

in french:
Il n'est pas bon dans un jeu de limiter le nombre d'images par seconde.
Par exemple, une limite de 60 fps sur un écran 100Hz donne une animation moins fluide.
C'est pourquoi nous utilisons un deltaTime. Mais pour cela, le VSYNC avec la carte vidéo doit être activé.
Ca marche dans glfw avec glfwSwapInterval (1), mais pas dans glbasic apparemment.

Ce deuxième code fonctionne mieux, mais ce n'est pas encore parfait :( (car je pense que le vsync n'est pas activé dans glbasic)

in english:
It's not good in a game to limit the number of frames per second.
For example, a limit of 60 fps on a 100Hz monitor gives a less fluid animation.
That is why we use a deltatime. But for that, the VSYNC with the video card must be enabled.
That is works in glfw with glfwSwapInterval(1) but not in glbasic apparently.

This second code works better, but it's not perfect yet  :( (because i think the vsync is not enabled in glbasic)

Code (glbasic) Select

WideScroller("Media/test.txt")

FUNCTION WideScroller: filename$
LOCAL text$[], a$, maxline, z, dz, dx, y, fx, fy
DIM text$[256]

GETFONTSIZE fx, fy
fy=fy+8

FOR i=0 TO 255
GETFILE filename$, i, a$
IF a$="NO_FILE" THEN RETURN
IF a$="NO_DATA" THEN GOTO skip
text$[i]=a$
maxline=maxline+1
NEXT

skip:
zt0=-maxline*fy
        zt1=480
LIMITFPS -1

ctime = ftime = GETTIMERALL() * 0.001
fps1 = fps2 = 0
ltime = 0

    WHILE KEY(57)=FALSE AND KEY(28)=FALSE     
    ctime=GETTIMERALL() * 0.001
    dtime=ctime-ftime
    ftime=ctime
    fps2=fps2+1
   
    IF ctime - ltime > 1
    ltime = ctime;
fps1 = fps2;
        fps2 = 0;
    ENDIF
   
    zt1=zt1-(50*dtime)
       
FOR z=0 TO maxline-1
dz=z*20+zt1
dx=(640-LEN(text$[z])*fx)/2
IF dz<480 AND dz>-20 THEN PRINT text$[z], dx, dz
NEXT

PRINT "FPS: "+INTEGER(fps1), 100, 100

SHOWSCREEN

    IF zt1<=zt0 THEN zt1=480
WEND
ENDFUNCTION



Kitty Hello

I'll fix it with the next version, so it uses the vsync for LIMITFPS >0.

SnooPI


Slydog

QuoteI'll fix it with the next version, so it uses the vsync for LIMITFPS >0.

Isn't he asking to do a vsync when LIMITFPS is -1?
For dynamic delta times?

Re:
QuoteWith glfwSwapInterval(1) the program is perfectly synchronised with the video card
Not with LIMITFPS -1 (and use of deltatime) :(
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

SnooPI

in french:
Oui effectivement Slydog.
Mais avec la LIMITFPS>0 le vsync n'est pas parfait non plus.  :(
Donc c'est important pour les deux.
J'espere que Kitty le fera aussi pour LIMITFPS -1   ;)

in english:
Yes indeed Slydog.
But with the LIMITFPS>0 the vsync is not perfect either.  :(
So it's important for both.
I hope that Kitty will do it also for LIMITFPS -1   ;)

spacefractal

I think I have seen that issue in Greedy Mouse as well. Something with LIMITFPS 60 its got choopy sometimes without any reason. Not sure its due frameskipping metod I use or LIMITFPS its self. I did believe LIMITFPS 50 was more stable for some reason than LIMITFPS 60.

On some machines I heard its can screen tear, while not on others (but just lag sometimes).

So yes we should have some real vsync option (howover I got it fixed to MacOS, which I reported the bug too, but can happens on Windows too).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

SnooPI

in french:
ce problème a été corrigé dans la version bêta 11. Merci Gernnot (alias kitty hello)  :booze:

in english:
this problem has been fixed in version 11 beta. Thanks Gernnot (aka kitty hello)  :booze: