OpenGLは、オープン標準として公開されているクロスプラットフォームなグラフィックスライブラリ。
OpenGL - The Industry Standard for High Performance Graphics
はじめての OpenGL
GLUTによる「手抜き」OpenGL入門
Ubuntu ,Fedora ,Raspberry Pi への GLUT のインストール方法 | Iwao Dev
GLUT を使える様に - Iwao MISH
構成としては、OpenGL本体と、サポートライブラリのGLUTがあるが、今回は簡単に始めたいので、まずはGLUT(正確にはfreeglut)を扱っていく。
今回は、ウィンドウを表示するのみ。
$ yum search opengl メタデータの期限切れの最終確認: x days, x:xx:xx 時間前の xxxx年xx月xx日 xx時xx分xx秒 に実施しました。 =========================== 名前 & 概要 一致: opengl =========================== perl-OpenGL.x86_64 : Perl OpenGL bindings ghc-OpenGL.x86_64 : Haskell OpenGL library ghc-OpenGLRaw.x86_64 : Haskell OpenGLRaw library hugs98-opengl.x86_64 : OpenGL package for Hugs98 rubygem-opengl.x86_64 : An OpenGL wrapper for Ruby libglvnd-opengl.x86_64 : OpenGL support for libglvnd libglvnd-opengl.i686 : OpenGL support for libglvnd libglvnd-opengl.x86_64 : OpenGL support for libglvnd fifechan-opengl.i686 : OpenGL extension for fifechan fifechan-opengl.x86_64 : OpenGL extension for fifechan python2-pyopengl.x86_64 : Python 2 bindings for OpenGL python3-pyopengl.x86_64 : Python 3 bindings for OpenGL rubygem-ruby-opengl.noarch : OpenGL Interface for Ruby python3-pyopengl-tk.noarch : PyOpenGL Python 3.x Tk widget rubygem-opengl-doc.noarch : Documentation for rubygem-opengl gambas3-gb-opengl.x86_64 : Gambas3 component package for opengl android-opengl-api-javadoc.noarch : Javadoc for android-opengl-api ghc-OpenGL-devel.x86_64 : Haskell OpenGL library development files gambas3-gb-gtk-opengl.x86_64 : Gambas3 component package for gtk-opengl gambas3-gb-opengl-glu.x86_64 : Gambas3 component package for opengl-glu gambas3-gb-opengl-sge.x86_64 : Gambas3 component package for opengl-sge gambas3-gb-qt4-opengl.x86_64 : Gambas3 component package for qt4-opengl gambas3-gb-qt5-opengl.x86_64 : Gambas3 component package for qt5-opengl ghc-OpenGLRaw-devel.x86_64 : Haskell OpenGLRaw library development files gambas3-gb-opengl-glsl.x86_64 : Gambas3 component package for opengl-glsl fifechan-opengl-devel.i686 : Development files for OpenGL extension for fifechan fifechan-opengl-devel.x86_64 : Development files for OpenGL extension for : fifechan nvidia-query-resource-opengl-lib.x86_64 : Library for : nvidia-query-resource-opengl nvidia-query-resource-opengl.x86_64 : Querying OpenGL resource usage of ...: applications using the NVIDIA OpenGL driver ============================== 名前 一致: opengl =============================== android-opengl-api.noarch : Google Android Java ME Library (Khronos) opengl-games-utils.noarch : Utilities to check proper 3d support before : launching 3d games ============================== 概要 一致: opengl =============================== gl-manpages.noarch : OpenGL manpages pcb-rnd-hid-gtk2-gl.x86_64 : GUI: gtk2, opengl tcl-togl.i686 : A Tk OpenGL widget tcl-togl.x86_64 : A Tk OpenGL widget foobillard.x86_64 : OpenGL billard game glaxium.x86_64 : An OpenGL space shooter gtkglext-libs.i686 : OpenGL Extension to GTK gtkglext-libs.x86_64 : OpenGL Extension to GTK apitrace.x86_64 : Tools for tracing OpenGL glmark2.x86_64 : Benchmark for OpenGL 2.0 gauche-gl.x86_64 : OpenGL binding for Gauche liboglappth.i686 : An OpenGL wrapper library liboglappth.x86_64 : An OpenGL wrapper library mesa-libGLw.i686 : Xt / Motif OpenGL widgets mesa-libGLw.x86_64 : Xt / Motif OpenGL widgets GtkAda-gl.x86_64 : GTKada 2 binding to OpenGL GtkAda3-gl.x86_64 : GTKada 3 binding to OpenGL tempest.x86_64 : Tempest OpenGL screensaver SOIL.i686 : Simple OpenGL Image Library SOIL.x86_64 : Simple OpenGL Image Library libmml-qt4.i686 : Qt4/OpenGL-based MML Widget libmml-qt4.x86_64 : Qt4/OpenGL-based MML Widget libmml-qt5.i686 : Qt5/OpenGL-based MML Widget libmml-qt5.x86_64 : Qt5/OpenGL-based MML Widget ftgl.i686 : OpenGL frontend to Freetype 2 ftgl.x86_64 : OpenGL frontend to Freetype 2 quesoglc.i686 : The OpenGL Character Renderer quesoglc.x86_64 : The OpenGL Character Renderer rubygem-glu.x86_64 : Glu bindings for the opengl gem vegastrike.x86_64 : 3D OpenGL spaceflight simulator glava.x86_64 : OpenGL audio spectrum visualizer jogl2.x86_64 : Java bindings for the OpenGL API rubygem-glut.x86_64 : Glut bindings for the OpenGL gem alleggl.i686 : OpenGL support library for Allegro alleggl.x86_64 : OpenGL support library for Allegro erlang-esdl.x86_64 : Erlang OpenGL/SDL API and utilities gl3n.i686 : An OpenGL Mathematics library for D gl3n.x86_64 : An OpenGL Mathematics library for D sage.i686 : OpenGL extensions library using SDL sage.x86_64 : OpenGL extensions library using SDL compiz.i686 : OpenGL window and compositing manager compiz.x86_64 : OpenGL window and compositing manager glew.x86_64 : The OpenGL Extension Wrangler Library perl-Wx-GLCanvas.x86_64 : Interface to wxWidgets' OpenGL canvas libvdpau-va-gl.i686 : VDPAU driver with OpenGL/VAAPI back-end libvdpau-va-gl.x86_64 : VDPAU driver with OpenGL/VAAPI back-end compat-wxGTK3-gtk2-gl.i686 : OpenGL add-on for the wxWidgets library compat-wxGTK3-gtk2-gl.x86_64 : OpenGL add-on for the wxWidgets library wxGTK-gl.i686 : OpenGL add-on for the wxWidgets library wxGTK-gl.x86_64 : OpenGL add-on for the wxWidgets library wxGTK3-gl.i686 : OpenGL add-on for the wxWidgets library wxGTK3-gl.x86_64 : OpenGL add-on for the wxWidgets library celestia.x86_64 : OpenGL real-time visual space simulation gl2ps.i686 : An OpenGL to PostScript printing library gl2ps.x86_64 : An OpenGL to PostScript printing library pcb-rnd-lib-gl.x86_64 : Support library for rendering with opengl glglobe.x86_64 : OpenGl Globe - Earth simulation for linux libQGLViewer.i686 : Qt based OpenGL generic 3D viewer library libQGLViewer.x86_64 : Qt based OpenGL generic 3D viewer library libgle.i686 : A Tubing and Extrusion Library for OpenGL libgle.x86_64 : A Tubing and Extrusion Library for OpenGL libreoffice-ogltrans.x86_64 : 3D OpenGL slide transitions for LibreOffice mingw32-gtkglext.noarch : OpenGL Extension to GTK+ for the Win32 target mingw64-gtkglext.noarch : OpenGL Extension to GTK+ for the Win64 target OpenTK.x86_64 : C# library that wraps OpenGL, OpenCL and OpenAL mednafen.x86_64 : A multi-system emulator utilizing OpenGL and SDL ocaml-lablgl.x86_64 : LablGL is an OpenGL interface for Objective Caml libglpng.i686 : Toolkit for loading PNG images as OpenGL textures libglpng.x86_64 : Toolkit for loading PNG images as OpenGL textures openuniverse.x86_64 : OpenGL space simulator focused on the Solar System xscreensaver-gl-base.x86_64 : A base package for screensavers that require : OpenGL xscreensaver-gl-extras.x86_64 : An enhanced set of screensavers that require : OpenGL glslang.i686 : OpenGL and OpenGL ES shader front end and validator glslang.x86_64 : OpenGL and OpenGL ES shader front end and validator gtkglext-devel.i686 : Development tools for GTK-based OpenGL applications gtkglext-devel.x86_64 : Development tools for GTK-based OpenGL applications opencsg.i686 : Library for Constructive Solid Geometry using OpenGL opencsg.x86_64 : Library for Constructive Solid Geometry using OpenGL zhu3d.x86_64 : Interactive OpenGL-based mathematical function viewer GLC_lib.i686 : C++ class library for OpenGL application based on Qt 4 GLC_lib.x86_64 : C++ class library for OpenGL application based on Qt 4 CriticalMass.x86_64 : SDL/OpenGL space shoot'em up game also known as critter piglit.x86_64 : Collection of automated tests for OpenGL implementations qwtplot3d.i686 : Qt/OpenGL-based C++ library providing a bunch of 3D-widgets qwtplot3d.x86_64 : Qt/OpenGL-based C++ library providing a bunch of 3D-widgets VirtualGL.i686 : A toolkit for displaying OpenGL applications to thin clients VirtualGL.x86_64 : A toolkit for displaying OpenGL applications to thin clients qwtplot3d-qt4.i686 : Qt4/OpenGL-based C++ library providing a bunch of : 3D-widgets qwtplot3d-qt4.x86_64 : Qt4/OpenGL-based C++ library providing a bunch of : 3D-widgets mingw32-freeglut.noarch : Fedora MinGW alternative to the OpenGL Utility Toolkit : (GLUT) mingw64-freeglut.noarch : Fedora MinGW alternative to the OpenGL Utility Toolkit : (GLUT) guichan.i686 : Portable C++ GUI library for games using Allegro, SDL and OpenGL guichan.x86_64 : Portable C++ GUI library for games using Allegro, SDL and : OpenGL tachyon-gl.x86_64 : Parallel / Multiprocessor Ray Tracing System with OpenGL : display mingw32-gtkglext-static.noarch : Static version of gtkglext, OpenGL Extension to : GTK+ for the Win32 target mingw64-gtkglext-static.noarch : Static version of gtkglext, OpenGL Extension to : GTK+ for the Win64 target $
こんだけいっぱいあって何がなんだかである。
"glut"で探すと、
$ yum search glut ============================ 名前 & 概要 一致: glut ============================ ghc-GLUT.x86_64 : Haskell GLUT library hugs98-glut.x86_64 : GLUT package for Hugs98 rubygem-glut.x86_64 : Glut bindings for the OpenGL gem rubygem-glut-doc.noarch : Documentation for rubygem-glut ghc-GLUT-devel.x86_64 : Haskell GLUT library development files freeglut.i686 : A freely licensed alternative to the GLUT library freeglut.x86_64 : A freely licensed alternative to the GLUT library freeglut-devel.i686 : Freeglut developmental libraries and header files freeglut-devel.x86_64 : Freeglut developmental libraries and header files mingw32-freeglut.noarch : Fedora MinGW alternative to the OpenGL Utility Toolkit : (GLUT) mingw64-freeglut.noarch : Fedora MinGW alternative to the OpenGL Utility Toolkit : (GLUT) =============================== 概要 一致: glut ================================ glui.i686 : A GLUT-Based User Interface Library glui.x86_64 : A GLUT-Based User Interface Library $
絞れてきた。
今回は、freeglutを使うので、
[bg1@localhost Sample]$ sudo yum install freeglut freeglut-devel [sudo] bg1 のパスワード: Waiting for process with pid 3162 to finish. Fedora Modular 29 - x86_64 4.5 kB/s | 7.4 kB 00:01 Fedora Modular 29 - x86_64 - Updates 4.4 kB/s | 7.0 kB 00:01 Fedora 29 - x86_64 - Updates 4.3 kB/s | 7.1 kB 00:01 Fedora 29 - x86_64 4.3 kB/s | 7.6 kB 00:01 依存関係が解決しました。 ================================================================================ パッケージ アーキテクチャー バージョン リポジトリ サイズ ================================================================================ インストール: freeglut x86_64 3.0.0-9.fc29 fedora 183 k freeglut-devel x86_64 3.0.0-9.fc29 fedora 112 k 依存関係をインストール中: gl-manpages noarch 1.1-16.20161227.fc29 fedora 1.2 M mesa-libGLU x86_64 9.0.0-16.fc29 fedora 182 k mesa-libGLU-devel x86_64 9.0.0-16.fc29 fedora 13 k トランザクションの概要 ================================================================================ インストール 5 パッケージ ダウンロードサイズの合計: 1.6 M インストール済みのサイズ: 2.3 M これでよろしいですか? [y/N]: y パッケージのダウンロード中です: (1/5): freeglut-devel-3.0.0-9.fc29.x86_64.rpm 51 kB/s | 112 kB 00:02 (2/5): freeglut-3.0.0-9.fc29.x86_64.rpm 68 kB/s | 183 kB 00:02 (3/5): mesa-libGLU-9.0.0-16.fc29.x86_64.rpm 196 kB/s | 182 kB 00:00 (4/5): gl-manpages-1.1-16.20161227.fc29.noarch. 342 kB/s | 1.2 MB 00:03 (5/5): mesa-libGLU-devel-9.0.0-16.fc29.x86_64.r 17 kB/s | 13 kB 00:00 -------------------------------------------------------------------------------- 合計 176 kB/s | 1.6 MB 00:09 トランザクションの確認を実行中 トランザクションの確認に成功しました。 トランザクションのテストを実行中 トランザクションのテストに成功しました。 トランザクションを実行中 準備 : 1/1 Installed: mesa-libGLU-9.0.0-16.fc29.x86_64 インストール中 : mesa-libGLU-9.0.0-16.fc29.x86_64 1/5 Installed: mesa-libGLU-9.0.0-16.fc29.x86_64 Installed: gl-manpages-1.1-16.20161227.fc29.noarch インストール中 : gl-manpages-1.1-16.20161227.fc29.noarch 2/5 Installed: gl-manpages-1.1-16.20161227.fc29.noarch Installed: mesa-libGLU-devel-9.0.0-16.fc29.x86_64 インストール中 : mesa-libGLU-devel-9.0.0-16.fc29.x86_64 3/5 Installed: mesa-libGLU-devel-9.0.0-16.fc29.x86_64 Installed: freeglut-3.0.0-9.fc29.x86_64 インストール中 : freeglut-3.0.0-9.fc29.x86_64 4/5 scriptletの実行中: freeglut-3.0.0-9.fc29.x86_64 4/5 Installed: freeglut-3.0.0-9.fc29.x86_64 Installed: freeglut-devel-3.0.0-9.fc29.x86_64 インストール中 : freeglut-devel-3.0.0-9.fc29.x86_64 5/5 Installed: freeglut-devel-3.0.0-9.fc29.x86_64 scriptletの実行中: freeglut-devel-3.0.0-9.fc29.x86_64 5/5 検証 : freeglut-3.0.0-9.fc29.x86_64 1/5 検証 : freeglut-devel-3.0.0-9.fc29.x86_64 2/5 検証 : gl-manpages-1.1-16.20161227.fc29.noarch 3/5 検証 : mesa-libGLU-9.0.0-16.fc29.x86_64 4/5 検証 : mesa-libGLU-devel-9.0.0-16.fc29.x86_64 5/5 インストール済み: freeglut-3.0.0-9.fc29.x86_64 freeglut-devel-3.0.0-9.fc29.x86_64 gl-manpages-1.1-16.20161227.fc29.noarch mesa-libGLU-9.0.0-16.fc29.x86_64 mesa-libGLU-devel-9.0.0-16.fc29.x86_64 完了しました! $
とインストール。
main.cで、
とする。
いろいろあるが、
glutMainLoopがメインループで、ウィンドウを閉じるまで抜けない。
実行すると、こんな感じでウィンドウ表示される。
閉じるとglutMainLoopから抜けて終了する。
Sample/opengl/glutMainLoop/glutMainLoop/src/glutMainLoop at master · bg1bgst333/Sample · GitHub