Chapter 5. Pygame and 3D
In our previous chapters, we developed our 2D games with Python modules that are built on top of a graphical user interface library, such as Tkinter
and Pyglet
. This allowed us to start coding our games without worrying about the lower-level details.
Now we will develop our first 3D game with Python, which will require an understanding of some basic principles of OpenGL, a popular multiplatform API for building 2D and 3D applications. You will learn how to integrate these programs with Pygame, a Python library commonly used to create sprite-based games.
In this chapter, we will cover the following topics:
- A steady approach to PyOpenGL and Pygame
- Initializing an OpenGL context
- Understanding the different modes that can be enabled with OpenGL
- How to render lights and simple shapes
- Integrating OpenGL with Pygame
- Drawing primitives and performance improvements