[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Sync with vertical refresh does not work(?)



I tried out changing the graphics settings, but they had no effect.
The tearing occurs both in fullscreen and windowed mode, btw.

The core routine is this one:

-------------------
# Flash elements ON
groups[current_flash].clear(screen, background)
groups[current_flash].update()      # change state
rects = groups[current_flash].draw(screen)
#pygame.display.flip()
pygame.display.update(rects)

# Wait flash duration
for t in range(self.flash_duration): clock.tick(self.fps)

# Flash elements OFF
groups[current_flash].clear(screen, background)
groups[current_flash].update(-1)      # change state back
rects = groups[current_flash].draw(screen)
#pygame.display.flip()
pygame.display.update(rects)
-------------------

For completeness, some extra info:
* groups is a list of instances of pygame.sprite.RenderUpdates
* screen = pygame.display.set_mode(...)
* background is created in the following way:
self.background = pygame.Surface( (self.screenWidth,self.screenHeight) )
self.background.fill(self.bgcolor)

It may be (or may be not) relevant that each sprite has two graphical
'states' (for instance, two sizes or colors).
The two according images and rectangles are stored in lists. Upon
calling the update() method, self.image and self.rect are assigned the
appropriate image and rectangle form the list, as follows

self.image = self.images[current_state]
self.rect = self.rects[current_state]

Honestly, I didn't play any game before. I couldn't find aliens.py,
but I just tried out 50 Bouncy Balls (because there are so many
objects) and Invasion of the blobs (great 80's shooter :D ). I didn't
see any tearing, but then again these games feature only small
objects.

Cheers,
Matthias


2009/1/30 Brian Fisher <brian@xxxxxxxxxxxxxxxxxxx>:
> Can you share the code or some minimal sample that exhibits the problem for
> you? It would probably help if others could confirm they see the issue, and
> if it's a code issue, it would be easiest to see and solve having code.
>
> if you can't, do you get the tearing in both windowed and fullscreen or just
> fullsccreen? do you get tearing with any/all of the examples? (like
> aliens.py)
>