Other languages > GLBasic - fr

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

(1/3) > >>

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) ---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

--- End code ---

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) ---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

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version