sudo apt-get install python-opengl
pip install pyopengl
If you want to put Pillow because you want to display an image
sudo apt-get install libjpeg-dev
pip install Pillow
Also keep
Try running the code at http://tomosoft.jp/design/?p=9152
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
import sys
def display():
glClear(GL_COLOR_BUFFER_BIT)
glFlush()
def main():
glutInit(sys.argv)
glutInitWindowSize(300, 300)
glutInitDisplayMode(GLUT_RGBA)
glutCreateWindow(b"OpenGL")
glutDisplayFunc(display)
glClearColor(0.0, 0.0, 0.0, 1.0)
glutMainLoop()
return 0
if __name__ == "__main__":
main()
OK if the window comes up
pip install pyopengl
If only, the following error will occur when executing the above sample
Traceback (most recent call last):
File "gltest.py", line 25, in <module>
main()
File "gltest.py", line 12, in main
glutInit(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/PyOpenGL-3.1.1a1-py2.7.egg/OpenGL/GLUT/special.py", line 333, in glutInit
_base_glutInit( ctypes.byref(count), holder )
File "/usr/local/lib/python2.7/dist-packages/PyOpenGL-3.1.1a1-py2.7.egg/OpenGL/platform/baseplatform.py", line 407, in __call__
self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling
It is said that OpenGL originally included in Raspberry Pi is OpenGL ES2, and I imagine that this is the case because OpenGL ES2 cannot use GLUT.
Solved by putting python-opengl with apt-get like setup
.
Recommended Posts