Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyGame slower on macOS than on Ubuntu or Raspbian

I use PyGame for creating games, but I noticed that the programs ran a lot slower on macOS than on my Raspberry Pi. My original solution was to install Ubuntu alongside macOS on my computer, and that worked. However, I would rather only have one operating system on my computer. Does anyone know why PyGame is so much slower on my mac when running macOS?

If it would help, I can send code. However, I have multiple PyGame programs and they all do the exact same thing, so I figured that it was most likely not the fault of the code, but I could be wrong.

Any help is appreciated, thanks.

P.S. When I say slower, I mean that it is running at about 30% of the speed on macOS than it would on Ubuntu.

like image 393
CircuitSacul Avatar asked May 20 '20 22:05

CircuitSacul


2 Answers

Pygame is based on the SDL library. It supports using various rendering backends, such as OpenGL and metal. According to this answer (and the comment), it seems that the metal renderer might perform poorly on mac. Sadly, according to this issue, it seems that in most versions of pygame, it uses metal as the SDL backend for mac, and provides no way to change that.

There is the pygame.OPENGL flag you could pass to pygame.display.set_mode(), but I'm not sure exactly how it would affect anything. It might be a good idea to play with the other flags listed here.

I'd recommend you to open an issue on pygame's official github repo with the necessary details. Also, as a workaround, you could clone pygame, change the default renderer on mac to OpenGL, compile, and see if it improves anything. You can use the issue I mentioned above to understand where you should start.

like image 171
kmaork Avatar answered Nov 10 '22 06:11

kmaork


Try running your game in full screen mode

pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
like image 27
omar-h-omar Avatar answered Nov 10 '22 06:11

omar-h-omar