OpenGL - touretzkyds/cozmopedia GitHub Wiki
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:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl
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').
While MacOS comes with OpenGL, it does not include GLUT, which cozmo-tools requires. To install GLUT, you must have Homebrew installed. Assuming you have Homebrew, you can do:
brew install freeglut
You will also need to install the Python packages PyOpenGL and PyOpenGL_accelerate, which can be done with pip.
-
OpenGL Programming book
- A readable, fairly comprehensive introduction to OpenGL.
-
OpenGL tutorial
- 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.