خرید بک لینک

Vote count: 0

I come to this forum because I am stuck on a screen tearing problem for about a week now. First of all, I need to say that I have few knowledge and experience in raspberry and python.

Here is my problem : I would like to make a program that can display a sequence of png pictures really fast (at a rate of 30 fps or more). To do this I use the pygame library, especially pygame.display.blit and pygame.display.flip. Here is an example of the code (with a homemade delay function) :

import time
import pygame

screen=pygame.display.set_mode(size, pygame.FULLSCREEN)
nbPicturesToLoad=12
pictures=range(nbPicturesToLoad)
for i in range(nbPicturesToLoad):
    pictures[i]=pygame.image.load(pictureName).convert() //Here pictureName depends on the value of i

(...)

for i in range(nbPicturesToLoad):
    timer1=time.time()
    screen.blit(pictures[i], (0,0))
    pygame.display.flip()
    timer2=time.time()
    timer=timer2-timer1
    while(timer<0.03333):
        timer2=time.time()
        timer=timer2-timer1

The timer allows me to have the same refresh rate on the screen. My problem is that one can see with their own eyes that there is a screen tearing problem (https://en.wikipedia.org/wiki/Screen_tearing). On the pygame documentation they recommend to use other flags for the screen init (pygame.HWSURFACE and pygame.DOUBLEBUF, http://www.pygame.org/docs/ref/display. ... y.set_mode). Apparently these could help to correct the screen tearing problems. But when I use these flags I see no screen tearing correction. I've seen somewhere that pygame can't handle vsync on X11, which would explain why I see no difference with the HWSURFACE and DOUBLEBUF flags.

Has anyone ever encountered this vsync issue on the raspberry pi ? Is there a parameter to put in the "config.txt" file ? Does anyone have a way to get real vsync information to avoid these screen tearing effects ?

I've seen that pyglet could handle vsync in the created windows, but for unknown reasons I can't display images in the pyglet window and I'm really not sure if it would fix the problem, especially if raspberry can't handle vsync right now...

Any help would be appreciated :). Chumbucket

asked 4 mins ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 4 خرداد 1395 ساعت: 14:58

صفحه بندی