1

When programming in Python 3, using Pygame, there is a problem with updating portions of the screen on Mac OS.

For example:

import pygame
screen=pygame.display.set_mode((200,200))
screen.fill((100,100,100))
pygame.display.update(0,0,100,200)

This should display a screen half grey and half white, however, on Mac OS it updates the whole screen, making it all grey, as if I had written:

pygame.display.update(0,0,200,200)

Or

pygame.display.update()

Or

pygame.display.flip()

This can be a huge problem in developing optimised programs. If all I need to do is update one pixel, Pygame will update the whole screen and waste too much time doing it.

This has been a problem for years, as far as I can tell. I feel it has never been recognised and due to it many programs are poorly optimised or never finished.

I know this is a problem with Pygame itself, so does anyone know of any kind of fix or way around this?

Thanks!

  • i suspect if there was a fix it would have been mainlined already, do you know if this is a generic pygame bug or a platform specific one? i.e. does it only affect macos? or windows and linux too? – James Kent Jan 03 '18 at 16:20
  • note, just tested this under python3.4 on winxp with the result described above – James Kent Jan 03 '18 at 16:22
  • having had a quick look at the pygame source, it looks to me like it's expecting a single argument containing the rect to be updated. on windows changing `pygame.display.update(0,0,100,200)` to `pygame.display.update((0,0,100,200))` gave me a window with half grey and half black... – James Kent Jan 03 '18 at 16:27
  • @JamesKent Just tried pygame.display.update((0,0,100,200)) and the window is still all grey :'(. I think this is specific to MacOS, but it may also affect linux too. I appreciate your tests. – PatrickHume31 Jan 03 '18 at 17:53
  • on Linux I get half grey and half black screen – furas Jan 03 '18 at 19:00
  • I encountered the same presumed bug and found a work-around that works for me on MacOS Mojave (10.14) on a Macbook Air from 2014: After the update(), simply add "pygame.event.get()" Don't ask me why, but for me it triggers the update; without it: light grey screen. – Job Stancil Apr 30 '20 at 17:41
  • @PatrixHume31 The window is still all grey on Windows 10 too. – D_00 Aug 10 '20 at 08:04

0 Answers0