Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
There are many graphics packages offered for Python. Many of these are broken or don't work in Python 3.5. OpenGL does work, and provides full 3D graphics capabilities.
You can install OpenGL and the Python bindings for it with just two shell commands:
$ apt-get install freeglut3 $ pip3 install PyOpenGL PyOpenGL_accelerate
Your Python program should contain these lines:
from OpenGL.GLUT import * from OpenGL.GL import * from OpenGL.GLU import *
You need two packages: PyOpenGL and PyOpenGL_accelerate. The windows versions on PyPI aren't good (as of March 2018). Instead, get the whl files from here:
Make sure to get the right size (64 bits) and version that matches your Python version. These wheels include the freeglut DLL file, so you don't need to install it separately.
If you're writing your own OpenGL code, not just running someone else's, note that on Windows PyOpenGL doesn't want Python string arguments 'foo', it wants bytes, which can be obtained from b'foo' or bytes('foo','utf-8').
OpenGL Programming book
- A readable, fairly comprehensive introduction to OpenGL.
- The pulldown menus along the top of the page offer a variety of tutorials demonstrating how to accomplish basic or intermediate effects, from opening a window to texture mapping and 3D rotations.
OpenGL Programming Guide
- Known informally as "the red book", this guide to OpenGL version 1.1 is still a good introduction to modern OpenGL.