I have created several simple games with PyGame, but until now, I have focused on mechanics rather than graphics. The graphics in my games have been extremely rudimentary, consisting of basic shapes on black backgrounds.

I've recently decided to change that and create a 2D graphics engine supporting proper texturing, some animation, and most importantly: lighting. While researching these, especially the last, I've started doubting whether PyGame is the right tool for this. Many tutorials concering implementation of lighting, shadows, et cetera recommend using techniques such as GPU shaders and pixel-level manipulation.

Looking at the documentation of PyGame, I don't see anything that would let me implement such things with any degree of efficiency. I can access bitmaps directly with PixelArray, but doing any significant processing this way seems like it would be a performance nightmare.

How can I get hardware accelerated graphics, vertex and pixel shaders when making a game with PyGame?

  • \$\begingroup\$ My problem isn't quite what technology to use in my specific case, but rather understanding the capabilities and applications of the technologies I mentioned. I honestly can't tell if that is within the guidelines. \$\endgroup\$
    – user44535
    Apr 12, 2014 at 22:58
  • \$\begingroup\$ I edited your question to focus on getting hardware/GPU access with PyGame. For your original, more broad questions, you may want to read the help center and look for the list of other sites you can ask those broad discussion-oriented questions on. \$\endgroup\$
    – user1430
    Apr 12, 2014 at 23:06
  • \$\begingroup\$ Thank you, that's better than I could have done. I'm very confused about this topic as a whole, so knowing how to ask a specific question is difficult for me. \$\endgroup\$
    – user44535
    Apr 12, 2014 at 23:21

1 Answer 1


PyGame itself, being a wrapper around SDL, is unable to directly use hardware acceleration. You can, however, use PyGame to create an OpenGL context and then render into that via an OpenGL library like pyglet or PyOpenGL, which will let you then also use GLSL vertex and fragment shaders.

This blog post does a good job of explaining the basics of using PyGame in conjunction with each other (domain now not working but archive available on archive.org).


You must log in to answer this question.