PowerVR-sdk
PowerVRのグラフィックエミュレーターのライブラリーです。多分、MacOS上で唯一のOpenGLに対するEGLの実装だと思われます。
$ brew list powervr-sdk /usr/local/Cellar/powervr-sdk/4.3/include/EGL/ (3 files) /usr/local/Cellar/powervr-sdk/4.3/include/GLES/ (4 files) /usr/local/Cellar/powervr-sdk/4.3/include/GLES2/ (3 files) /usr/local/Cellar/powervr-sdk/4.3/include/GLES3/ (4 files) /usr/local/Cellar/powervr-sdk/4.3/include/KHR/khrplatform.h /usr/local/Cellar/powervr-sdk/4.3/include/vulkan/ (2 files) /usr/local/Cellar/powervr-sdk/4.3/include/ (3 files) /usr/local/Cellar/powervr-sdk/4.3/lib/libEGL.dylib /usr/local/Cellar/powervr-sdk/4.3/lib/libGLESv1_CM.dylib /usr/local/Cellar/powervr-sdk/4.3/lib/libGLESv2.dylib /usr/local/Cellar/powervr-sdk/4.3/lib/libPVRScopeDeveloper.a $ otool -L /usr/local/Cellar/powervr-sdk/4.3/lib/libEGL.dylib /usr/local/Cellar/powervr-sdk/4.3/lib/libEGL.dylib: /usr/local/opt/powervr-sdk/lib/libEGL.dylib (compatibility version 0.0.0, current version 0.0.0) /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 57.0.0) /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 19.0.0) /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 945.18.0) /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1187.39.0)
ただし、あくまでもエミュレーションであり、ハードウェアアクセラレーションはありません。
Vulkanのヘッダーもありますが、本当に使えるんでしょうか?
PowerVR-sdkの中には他にもMakefileが何個かあって、Linux用と書かれてはいるのですが、*.makというマクロファイルを読み込むようになっていて、この*.makファイルが実はWindows用のnmakeというプログラムでしか利用できない代物で、っていうことはWindows上で開発してクロスコンパイルしているのだろうか。どちらにせよ、Macではどうしようもない。
2017.11/15 追記
さらに、egl.pcを作成してしまうことにしました。
The following script installs PowerVR-sdk on OSX with Homebrew.
class PowervrSdk < Formula desc "C++ cross-platform 3D graphics SDK" homepage "https://powervr-graphics.github.io/Native_SDK/" url "https://github.com/powervr-graphics/Native_SDK.git", :tag => "4.3", :revision => "25f0463ec682139d3b9dca2bb0c8f89beb22cfbe" # depends_on "cmake" => :build keg_only :provided_by_macos def install lib.install Dir["Builds/OSX/x86/Lib/*"] include.install Dir["Builds/Include/*"] # Please use Homebrew's "glm". # cd "External/glm" do # cp "detail/glm.cpp", "." # inreplace "CMakeLists.txt", "#", "" # system "cmake", "." , *std_cmake_args # system "make" # lib.install Dir["libglm*"] # end (lib/"pkgconfig/egl.pc").write <<~EOS prefix=#{opt_prefix} exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include Name: egl Description: PowerVR OpenGL EGL Emulation library Version: #{version} Libs: -L${libdir} -lEGL Libs.private: -framework OpenGL -lc++ -lobjc -framework Cocoa Cflags: -I${includedir} EOS end end
ちなみにcarioにかませることが出来ましたが、動作保証はしかねます。
$ ls /usr/local/Cellar/cairo/1.14.10/lib/pkgconfig/ cairo-egl.pc cairo-png.pc cairo-tee.pc cairo-fc.pc cairo-ps.pc cairo-xcb-shm.pc cairo-ft.pc cairo-quartz-font.pc cairo-xcb.pc cairo-gl.pc cairo-quartz-image.pc cairo-xlib-xcb.pc cairo-glx.pc cairo-quartz.pc cairo-xlib-xrender.pc cairo-gobject.pc cairo-script.pc cairo-xlib.pc cairo-pdf.pc cairo-svg.pc cairo.pc $ cat /usr/local/Cellar/cairo/1.14.10/lib/pkgconfig/cairo-egl.pc prefix=/usr/local/Cellar/cairo/1.14.10 exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include Name: cairo-egl Description: EGL functions for cairo graphics library Version: 1.14.10 Requires: cairo egl Libs: Cflags: -I${includedir}/cairo
MoltenGL
個人的な使用感の問題で、MoltenVkとMoltenGLのインストール先を分けたかったので、分割しました。
MoltenVKはGLFWが次期versionでのサポートを表明していますが、MoltenGLは何の話も聞きませんねえ。
このEGLおよびGLESv2はMoltenGL専用であり、OpenGLでは使用できません。
The following script installs MoltenGL on OSX with Homebrew.
libEGL and libGLESv2 are the exclusive use of MoltenGL not OpenGL.
class Moltengl < Formula desc "Traial of Molten GL API on macOS" homepage "https://moltengl.com/moltenvk/" url "https://s3.amazonaws.com/moltengl/downloads/Molten-0.19.0.zip" sha256 "b87892e74faefd1d12b404b65e08b603bf2a3617b8a38f2ddd2560c93e1ed832" keg_only "Molten GL is still preview version" option "with-EGL", "Install with libEGL" resource "OGLES2" do url "https://s3.amazonaws.com/moltengl/downloads/OGLES2-OSX.zip" sha256 "0f3750766c1cab6b1a055d39d77cf1f3825431f649a0ae8fe83ffb4fd86305ef" end def install bin.install "Molten-#{version}/MoltenGLShaderConverter/Tools/MoltenGLShaderConverter" lib.install "Molten-#{version}/MoltenGLShaderConverter/macOS/MoltenGLShaderConverter.framework", "Molten-#{version}/MoltenGL/macOS/MoltenGL.framework" if build.with? "EGL" resource("OGLES2").stage do lib.install "libEGL.dylib", "libGLESv2.dylib" end include.install Dir["Molten-#{version}/MoltenGL/RedirectHeaders/include/*"] include.install Dir["Molten-#{version}/MoltenGL/Demos/Common/API/*"] end include.install_symlink "#{lib}/MoltenGL.framework/Headers" => "MoltenGL" end end
You may find script for MlotenVK in this page.
gle
今度こそほんまもんのgleである。
$ brew list gle /usr/local/Cellar/gle/3.1.1/include/GL/gle.h /usr/local/Cellar/gle/3.1.1/lib/libgle.2.dylib /usr/local/Cellar/gle/3.1.1/lib/libgle.a /usr/local/Cellar/gle/3.1.1/lib/libgle.dylib /usr/local/Cellar/gle/3.1.1/share/doc/ (81 files) /usr/local/Cellar/gle/3.1.1/share/man/ (14 files)
たまたまgleの official site をみたら Github にソースコードのレポジトリーを移動したとのことなので、早速 issue へクレームを書き込んだら、PR作ってくれと言われ、仕方なくPRを出したら、ものの2分も経たないうちに即効マージされたでござる。
「Win32でテストしてませんよ」って書いておいたのだが、「自分もWindowsのことはわからん。だが、だめだったら報告が来るだろうからその時に対応すればいい」とのこと。そんなヤバゲでアレゲな方針でいいのか。
さらにautoreconfした時のバグを教えてあげたら、キレ気味に「autotoolsなんか使っている人が何人居るんだ」と開き直ったので「じゃあ何でそんな機能作り込んであるんだよ」と言いたかったけど大人の対応したら、その日のうちに指摘した部分を直してやがった。もうあんまり関わらんでおこう。
2017.11/12 追記
OpenGL Frameworkとリンクしているのに、install nameにOpenGL Frameworkの名前がないという不具合を解消しました。
$ otool -L /usr/local/Cellar/gle/3.1.1/lib/libgle.2.dylib /usr/local/Cellar/gle/3.1.1/lib/libgle.2.dylib: /usr/local/opt/gle/lib/libgle.2.dylib (compatibility version 4.0.0, current version 4.1.0) /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
The following script installs GLE on OSX with Homebrew.
class Gle < Formula desc "OpenGL programming API" homepage "http://linas.org/gle/" url "https://github.com/linas/glextrusion.git", :revision => "4e0dcf8d8da8856ee50ebdaa15aeb69273ecb310" version "3.1.1" depends_on "autoconf" => :build depends_on "automake" => :build depends_on "libtool" => :build depends_on "pkg-config" => :build depends_on "swig" => :build resource "config" do url "https://opensource.apple.com/source/pyobjc/pyobjc-26/pyobjc/PyOpenGL-2.0.2.01/src/gle/config.h" sha256 "424025f7779b3d643c73e66c0c88d7562b43e00f0b1a36b41c403bf0c47b7a8b" end resource "Makein" do url "https://opensource.apple.com/source/pyobjc/pyobjc-26/pyobjc/PyOpenGL-2.0.2.01/src/gle/src/Makefile.in" sha256 "bf6bdba96cbd8fc28ddf5124f91bb9a8f588b1b92dde2092bf4c4f2665178a46" end resource "Makeam" do url "https://opensource.apple.com/source/pyobjc/pyobjc-26/pyobjc/PyOpenGL-2.0.2.01/src/gle/src/Makefile.am" sha256 "875ff384676499e13d877b18027a289de804d0c36c9f86b10b71f62413e47d2f" end resource "port" do url "https://opensource.apple.com/source/pyobjc/pyobjc-26/pyobjc/PyOpenGL-2.0.2.01/src/gle/src/port.h" sha256 "79be9aeb94e4923a0ddc4ba685bd903d5932bfdbb21e87615013c8fd83ecdeca" end def install cp "src/GL/gle.h", "src/" # Do not build exaamples. inreplace ["Makefile.am", "Makefile.in"], "SUBDIRS = src doc examples man ms-visual-c swig", "SUBDIRS = src doc man ms-visual-c swig" resource("port").stage do cp "port.h", "#{buildpath}/src/port.h" end resource("Makein").stage do cp "Makefile.in", "#{buildpath}/src/Makefile.in" end resource("Makeam").stage do cp "Makefile.am", "#{buildpath}/src/Makefile.am" end inreplace ["src/Makefile.in", "src/Makefile.am"], "3:2:0", "3:1:1" system "autoreconf", "-vi" ENV.append "CPPFLAGS", "-framework OpenGL" ENV.append "LDFLAGS", "-framework OpenGL" system "./configure", "--disable-debug", "--disable-dependency-tracking", "--disable-silent-rules", "--mandir=#{man}", "--prefix=#{prefix}" resource("config").stage do cp "config.h", "#{buildpath}/config.h" end system "make" system "make", "install" end end
libpthread-stubs
また新規のHomebrewのScriptを作ったのですが、テストを作るのが面倒でPRは出しません。
ていうか、実際にインストールされるファイルは1つだけというヘンテコで微妙なものだからです。
Project description
-------------------
Currently the project provides only a pkg-config [.pc] file, pthread-stubs.pc.
The latter contains the Cflags/Libs flags applicable to programs/libraries
that use only lightweight pthread API. See the next sections for the reasoning
and implementation details.
これのテストって言われても、何をすれば良いのやら。
ただし、効力はかなり強く、C++11を指定しないとbuild出来なかったいくつかのパッケージにおいて、stdを指定しなくともbuild出来るようになったパッケージがあります。あくまで、そのパッケージがあらかじめlibpthread-stubsに対応していた場合のみですが。
The following script installs libpthread-stubs on OSX with Homebrew.
class LibpthreadStubs < Formula desc "Weak aliases for pthread functions in libc" homepage "https://xcb.freedesktop.org/" url "https://xcb.freedesktop.org/dist/libpthread-stubs-0.4.tar.gz" sha256 "50d5686b79019ccea08bcbd7b02fe5a40634abcfd4146b6e75c6420cc170e9d9" depends_on "pkg-config" => :build def install system "./configure", "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=#{prefix}" system "make" system "make", "install" end end
OGRE
また新規のHomebrewのPRを作ったのですが、新規のFormulaでは inreplace を使ってはいけないという理由で却下されたでござる。
実際は当方としては、テストが通るかどうか確認できれば、正規に採用されなくてもPRのログに残るし、ここでも公開するので実はこだわってないんですけど。
The following script installs OGRE on OSX with Homebrew. This script passed official Jenkins's test on Github.
class Ogre < Formula desc "Scene-oriented, flexible 3D engine" homepage "http://www.ogre3d.org/" url "https://github.com/OGRECave/ogre/archive/v1.10.9.tar.gz" sha256 "85ba2cc6a35c67ff93a9a498af9f8f3113fd3a16e7cc43c18b9769d8bf1e9101" option "with-java-component", "Build with java component" option "with-python-component", "Build with python component" needs :cxx11 depends_on "cmake" => :build depends_on "pkg-config" => :build depends_on "boost" => [:optional, :cxx11] depends_on "freeimage" depends_on "freetype" depends_on "harfbuzz" depends_on "libpng" depends_on "libzzip" depends_on "openexr" depends_on "sdl" depends_on "sdl2" if build.with?("java-component") || build.with?("python-component") depends_on "swig" depends_on :java if build.with? "java-component" depends_on :python if build.with? "python-component" end def install # Trunk starts using "clang++ -x c" to select C compiler which breaks C++11 # handling using ENV.cxx11. Using "cxxflags" and "linkflags" still works. ENV.cxx11 ENV.append "CXXFLAGS", "-std=c++11" if ENV.compiler == :clang ENV.append "CXXFLAGS", "-stdlib=libc++" ENV.append "LINKFLAGS", "-stdlib=libc++" end # OGRE tends to use "/Library/Frameworks/SDL.framework" if exist. Because OGRE appends "-F/Library/Frameworks". ENV.prepend "CPPFLAGS", "-I#{Formula["sdl"].opt_include}/SDL" inreplace "CMake/Utils/OgreConfigTargets.cmake", "set(PLATFORM_NAME \"macosx\")", "" inreplace "CMake/CMakeLists.txt", "set(OGRE_CMAKE_DIR \"CMake\")", "set(OGRE_CMAKE_DIR \"lib/OGRE/cmake\")" inreplace ["Samples/Media/CMakeLists.txt", "CMake/InstallResources.cmake"], "set(OGRE_MEDIA_PATH \"Media\")", "set(OGRE_MEDIA_PATH \"share/ogre/Media\")" inreplace "CMake/InstallResources.cmake", "set(OGRE_CFG_INSTALL_PATH \"bin\")", "set(OGRE_CFG_INSTALL_PATH \"share/ogre/cfg\")" args = std_cmake_args args += %w[-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE -DOGRE_FULL_RPATH=TRUE -DOGRE_BUILD_DEPENDENCIES=FALSE -DOGRE_INSTALL_DEPENDENCIES=FALSE -DOGRE_COPY_DEPENDENCIES=FALSE -DOGRE_BUILD_RENDERSYSTEM_GL3PLUS=OFF -DOGRE_BUILD_SAMPLES=OFF -DOGRE_BUILD_PLUGIN_CG=OFF -DOGRE_BUILD_LIBS_AS_FRAMEWORKS=OFF] # "std" meands using c++11. args << "-DOGRE_CONFIG_THREAD_PROVIDER=" + (build.with?("boost") ? "boost" : "std") # See https://github.com/OGRECave/ogre/issues/563 if build.with?("python-component") inreplace "Components/Python/CMakeLists.txt", "set(CMAKE_SWIG_FLAGS -w401,314 -builtin)", "set(CMAKE_SWIG_FLAGS -w401,314 -builtin -D_LIBCPP_VERSION)" else args << "-DOGRE_BUILD_COMPONENT_PYTHON=OFF" end if build.with?("java-component") inreplace "Components/Java/CMakeLists.txt", "set(CMAKE_SWIG_FLAGS -w401,314 -package org.Ogre)", "set(CMAKE_SWIG_FLAGS -w401,314 -package org.Ogre -D_LIBCPP_VERSION)" else args << "-DOGRE_BUILD_COMPONENT_JAVA=OFF" end system "cmake", ".", *args system "make", "install" lib.install "java/libs/libOgreJNI.jnilib" if build.with? "java-component" MachO::Tools.change_install_name("#{lib}/OGRE/Plugin_OctreeZone.#{version}.dylib", "@rpath/Plugin_PCZSceneManager.#{version}.dylib", "#{lib}/OGRE/Plugin_PCZSceneManager.#{version}.dylib") end def caveats if build.with? "python-component" then <<~EOS You might add "#{HOMEBREW_PREFIX}/lib/python2.7/dist-packages" to PYTHONPATH as following. export PYTHONPATH="#{HOMEBREW_PREFIX}/lib/python2.7/dist-packages:$PYTHONPATH" EOS end end test do (testpath/"test.mesh.xml").write <<-EOS <mesh> <submeshes> <submesh material="BaseWhite" usesharedvertices="false" use32bitindexes="false" operationtype="triangle_list"> <faces count="1"> <face v1="0" v2="1" v3="2" /> </faces> <geometry vertexcount="3"> <vertexbuffer positions="true" normals="false" texture_coords="0"> <vertex> <position x="-50" y="-50" z="50" /> </vertex> <vertex> <position x="-50" y="-50" z="-50" /> </vertex> <vertex> <position x="50" y="-50" z="-50" /> </vertex> </vertexbuffer> </geometry> </submesh> </submeshes> <submeshnames> <submeshname name="submesh0" index="0" /> </submeshnames> </mesh> EOS system "#{bin}/OgreXMLConverter", "test.mesh.xml" system "du", "-h", "./test.mesh" end end
AmanithVG-sdk
OpenVGの商用ライブラリーの見本らしい。
現在わかっている問題は、これが存在している時にcairoを"--enable-vg=yes"を付けてビルドするとコンパイルエラーで止まってしまう。これはAmanithVG-sdkが悪い訳ではなく、本家(?)ShivavgのlibOpenVGを使っても同じこととなる。cairo側の問題。
masterのbranchしかないため、HEADを使う必要があります。
$ brew install -s amanithvg-sdk --HEAD
class AmanithvgSdk < Formula desc "A commercial implementation of OpenVG 1.1 and 1.0.1" homepage "http://www.amanithvg.com/" head "https://github.com/Mazatech/amanithvg-sdk.git" option "software-engine", "Build for using original software engine instead of OpenGL.frameworks" option "with-tutorials", "Build with \"tutorials-app\"s" depends_on "cmake" => :build keg_only "Beacuse this Formula has only HEAD" def install backend_type = (build.with?("software-engine") ? "sre" :"gle") if build.with? "tutorials" args = std_cmake_args args << (build.with?("software-engine") ? "-DENGINE_SRE=1" : "-DENGINE_GLE=1") args << "-DCMAKE_TOOLCHAIN_FILE=./CMake/toolchain/osx_ub.cmake" << "--no-warn-unused-cli" mkdir prefix/"share/tutorials" Pathname.glob("tutorials/*"){|subdir| cd subdir do system "cmake", ".", *args, "-G", "Unix Makefiles" system "make" end } mkdir_p prefix/"share/amanithvg-sdk/tutorials" (share/"amanithvg-sdk/tutorials").install Dir["bin/macosx/ub/#{backend_type}/standalone/*"] end lib.install Dir["lib/macosx/ub/#{backend_type}/standalone/*"] end end
binutils with GAS and GPROF
またもやHomebrewにPRが却下されたでござる。今回の却下理由は意味不明過ぎて、呆れてものも言えない。
そもそもの発端は、vulkan-sdkというものをビルドしようとしたところcmakeから「GASが見つからない。あったほうが良い」的なことを言われたため。それで、調べたところ本来GASはGNUのbinutilsというパッケージに含まれていることがわかったので、Homebrewでbinutilsを入れたところ、肝心なGASが入っていないため、binutilsのFormulaを、GASとついでにGPROFもインストールできるように改良して、HomebrewにPRを出したところ、「デフォルトでインストールされないものだから必要ない」という謎理由で却下された。お前が要らなくてもGASが必要な人は居るだろうに。
で、vulkan-sdkのほうはC++のヘッダーファイル(vk_loader_platform.h)を書き直さなければならないことが分かったので諦めました。
The following script installs GAS(from GNU binutils) on OSX with Homebrew. This script passed official Jenkins's test on Github.
Overwrite "binutils.rb" and do "brew install -s binutils".
class Binutils < Formula desc "FSF/GNU ld, ar, readelf, etc. for native development" homepage "https://www.gnu.org/software/binutils/binutils.html" url "https://ftp.gnu.org/gnu/binutils/binutils-2.29.1.tar.gz" mirror "https://ftpmirror.gnu.org/binutils/binutils-2.29.1.tar.gz" sha256 "0d9d2bbf71e17903f26a676e7fba7c200e581c84b8f2f43e72d875d0e638771c" revision 1 def install # No --default-names option as it interferes with Homebrew builds. system "./configure", "--disable-debug", "--disable-dependency-tracking", "--enable-deterministic-archives", "--program-prefix=g", "--prefix=#{prefix}", "--infodir=#{info}", "--mandir=#{man}", "--disable-werror", "--enable-interwork", "--enable-multilib", "--enable-64-bit-bfd", "--enable-targets=all" # Do "make" in buildpath at first. # See http://forum.osdev.org/viewtopic.php?p=262707&sid=8a5a5d70c93acab73c5325f629216a91 system "make" system "make", "install" cd "gprof" do system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}", "--infodir=#{info}", "--mandir=#{man}", "--enable-plugins", "--disable-werror" system "make", "install" end cd "gas" do system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}", "--infodir=#{info}", "--mandir=#{man}", "--enable-plugins", "--disable-werror", "--program-prefix=g", "--with-system-zlib" # Adjustment to install a original named binary into same directry of other original named binarys. inreplace "Makefile", "$(tooldir)", "#{prefix}/$(target)" system "make", "install" end end test do assert_match "main", shell_output("#{bin}/gnm #{bin}/gnm") end end