[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Options for smooth-scrolling in X-Windows
- To: pygame-users@xxxxxxxx
- Subject: [pygame] Options for smooth-scrolling in X-Windows
- From: Weeble <clockworksaint@xxxxxxxxx>
- Date: Mon, 23 Feb 2009 18:02:58 +0000
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Mon, 23 Feb 2009 13:03:01 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=Edmkj/2nhB5g5pxcUtY9tfO/wa8xr0g0scA3D0gA77Q=; b=HaNs6OyJlmEMxE6NYsM8Cve64qQz8zoH9Phkqnc/O2rhnZ73Ja/o681QrkutW1o9/U r8V++L+UL6XWzSLiH74+5kLwnDsi7YFWzjTVRCF9e9oySCa+kL/A7M2EuCxBX4da0+pf HUs7hWOD4IInYWs5h2YtcCRas0+4a9qgQkp9Y=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=iExpUj7V2MyWcARTwvilipFkHzfad9IrFIJgsN8eyfa8WrNO9uPeQZ4Ttz664j3yOf DKAxnaDzHYmeb2YSakZZcknSsRCeF3MSeHzuzGNMm+jBlayOkytUyUmNSL90VfOUkt4z cmjuz6yTspUkqVyeOy5JpHFwSZBie8N3dtXoE=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
I'm trying to do full-screen scrolling, using pygame in X-Windows. As
far as I can tell, there's no way around the problem of tearing. Is
that true? Here's a simple example that gives me problems:
import pygame
from pygame.locals import *
from random import randint
pygame.init()
opts = pygame.FULLSCREEN|pygame.DOUBLEBUF|pygame.HWSURFACE
screen = pygame.display.set_mode((640,480),opts)
rectangles=[Rect(randint(0,1200),randint(0,1200),64,64) for i in xrange(200)]
clock = pygame.time.Clock()
for i in xrange(300):
screen.fill( (0,0,0) )
for r in rectangles:
screen.fill( (255,0,0), r.move(-4*i,-4*i) )
pygame.display.flip()
clock.tick_busy_loop(60)
The problem is that the scrolling isn't smooth. There's a noticeable
flicker, resulting from the flip() being unsynchronised with the
screen refresh. (I've experimented with other settings for "opts"
above and I've used both tick and tick_busy_loop with similar
results.) Am I right in thinking that there's no way around this using
the x11 driver? Is there an alternative to this if I want people to be
able to play my game smoothly on Linux? I understand vsync is possible
in OpenGL, but I think that means I'd need to completely change my
rendering code and might have difficulty doing some of the stuff I do
at the moment. (I render between several intermediate surfaces using
various blend modes to do some effects.) Is that also the case? What
approach do people generally take? I can see a number of alternatives:
1. Don't use/support Linux.
2. Avoid scrolling backgrounds, so tearing isn't such a big deal.
3. Use OpenGL for all rendering, abandoning easy to use surfaces.
4. Super magic solution to get working VSYNC under X-windows.
Any advice would be much appreciated.
Regards,
Weeble.