OpenGLを使うためのライブラリ。
前回まで
- http://ytyaru.hatenablog.com/entry/2018/06/11/000000
- http://ytyaru.hatenablog.com/entry/2018/06/12/000000
- http://ytyaru.hatenablog.com/entry/2018/06/14/000000
背景
前回入手したコードのうちOpenGLを使ったものが動かなかった。事前にOpenGLライブラリの入手が必要らしい。
参考
PyOpenGL -- The Python OpenGL Binding
結論
apt-getで依存ソフトウェアも一緒に入手できる。
$ sudo apt-get install python-opengl
(game) $ pip install PyOpenGL PyOpenGL_accelerate
(game) $ pip install PyOpenGL_Demo
インストール
(game) $ pip install PyOpenGL PyOpenGL_accelerate
(game) $ pip install PyOpenGL PyOpenGL_accelerate Collecting PyOpenGL Downloading PyOpenGL-3.1.0.tar.gz (1.2MB) 100% |████████████████████████████████| 1.2MB 237kB/s Collecting PyOpenGL_accelerate Downloading PyOpenGL-accelerate-3.1.0.zip (340kB) 100% |████████████████████████████████| 348kB 416kB/s Installing collected packages: PyOpenGL, PyOpenGL-accelerate Running setup.py install for PyOpenGL ... done Running setup.py install for PyOpenGL-accelerate ... done Successfully installed PyOpenGL-3.1.0 PyOpenGL-accelerate-3.1.0
起動できなかった
前回のコードpyopengl/gl_window
を実行してみた所、エラーになった。
$ python gl_window.py Traceback (most recent call last): File "gl_window.py", line 26, in <module> main() File "gl_window.py", line 8, in main glutInit(sys.argv) File "/media/mint/85f78c06-a96e-4020-ac36-9419b7e456db/mint/root/tools/pyenv/3.6.1/venv/game/lib/python3.6/site-packages/OpenGL/GLUT/special.py", line 333, in glutInit _base_glutInit( ctypes.byref(count), holder ) File "/media/mint/85f78c06-a96e-4020-ac36-9419b7e456db/mint/root/tools/pyenv/3.6.1/venv/game/lib/python3.6/site-packages/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
たぶんGPUがないとか古いとかだろう。
Glut
「OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling」でググった。
どうやらGlutというものが必要らしい。linuxでのインストール方法不明。
依存ソフトウェア
http://pyopengl.sourceforge.net/documentation/installation.html
参考
- http://blawat2015.no-ip.com/~mieki256/diary/201506185.html
- http://minaraiengineer.blogspot.jp/2016/02/pyopengl.html
apt-get
apt-getで入手すると、必要なライブラリも一緒に入手してくれる。
$ sudo apt-get install python-opengl
$ sudo apt-get install python-opengl パッケージリストを読み込んでいます... 完了 依存関係ツリーを作成しています 状態情報を読み取っています... 完了 以下のパッケージが自動でインストールされましたが、もう必要とされていません: libc-ares2 libv8-3.14.5 これを削除するには 'apt-get autoremove' を利用してください。 以下の特別パッケージがインストールされます: freeglut3 提案パッケージ: python-tk python-numpy 以下のパッケージが新たにインストールされます: freeglut3 python-opengl アップグレード: 0 個、新規インストール: 2 個、削除: 0 個、保留: 418 個。 452 kB のアーカイブを取得する必要があります。 この操作後に追加で 3,066 kB のディスク容量が消費されます。 続行しますか? [Y/n] y 取得:1 http://ftp.tsukuba.wide.ad.jp/Linux/ubuntu/ trusty/main freeglut3 i386 2.8.1-1 [88.2 kB] 取得:2 http://ftp.tsukuba.wide.ad.jp/Linux/ubuntu/ trusty/universe python-opengl all 3.0.2-1 [364 kB] 452 kB を 1秒 で取得しました (277 kB/s) 以前に未選択のパッケージ freeglut3:i386 を選択しています。 (データベースを読み込んでいます ... 現在 198339 個のファイルとディレクトリがインストールされています。) .../freeglut3_2.8.1-1_i386.deb を展開する準備をしています ... freeglut3:i386 (2.8.1-1) を展開しています... 以前に未選択のパッケージ python-opengl を選択しています。 .../python-opengl_3.0.2-1_all.deb を展開する準備をしています ... python-opengl (3.0.2-1) を展開しています... freeglut3:i386 (2.8.1-1) を設定しています ... python-opengl (3.0.2-1) を設定しています ... libc-bin (2.19-0ubuntu6.6) のトリガを処理しています ...
起動確認
文字化けしているが。
所感
とりあえずOpenGLの起動ができた。