gl.scm 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
  3. ;;; Copyright © 2013 Joshua Grant <tadni@riseup.net>
  4. ;;; Copyright © 2014, 2016 David Thompson <davet@gnu.org>
  5. ;;; Copyright © 2014, 2015, 2016, 2017 Mark H Weaver <mhw@netris.org>
  6. ;;; Copyright © 2016 Nils Gillmann <ng0@n0.is>
  7. ;;; Copyright © 2016, 2017, 2018 Ricardo Wurmus <rekado@elephly.net>
  8. ;;; Copyright © 2016 David Thompson <davet@gnu.org>
  9. ;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
  10. ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
  11. ;;; Copyright © 2017, 2018 Rutger Helling <rhelling@mykolab.com>
  12. ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
  13. ;;;
  14. ;;; This file is part of GNU Guix.
  15. ;;;
  16. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  17. ;;; under the terms of the GNU General Public License as published by
  18. ;;; the Free Software Foundation; either version 3 of the License, or (at
  19. ;;; your option) any later version.
  20. ;;;
  21. ;;; GNU Guix is distributed in the hope that it will be useful, but
  22. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  23. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. ;;; GNU General Public License for more details.
  25. ;;;
  26. ;;; You should have received a copy of the GNU General Public License
  27. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  28. (define-module (gnu packages gl)
  29. #:use-module (gnu packages)
  30. #:use-module (gnu packages autotools)
  31. #:use-module (gnu packages bison)
  32. #:use-module (gnu packages compression)
  33. #:use-module (gnu packages documentation)
  34. #:use-module (gnu packages elf)
  35. #:use-module (gnu packages flex)
  36. #:use-module (gnu packages fontutils)
  37. #:use-module (gnu packages freedesktop)
  38. #:use-module (gnu packages gettext)
  39. #:use-module (gnu packages guile)
  40. #:use-module (gnu packages image)
  41. #:use-module (gnu packages linux)
  42. #:use-module (gnu packages llvm)
  43. #:use-module (gnu packages pkg-config)
  44. #:use-module (gnu packages python)
  45. #:use-module (gnu packages python-xyz)
  46. #:use-module (gnu packages tls)
  47. #:use-module (gnu packages video)
  48. #:use-module (gnu packages xdisorg)
  49. #:use-module (gnu packages xml)
  50. #:use-module (gnu packages xorg)
  51. #:use-module (guix download)
  52. #:use-module (guix git-download)
  53. #:use-module (guix build-system gnu)
  54. #:use-module (guix build-system cmake)
  55. #:use-module (guix build-system meson)
  56. #:use-module ((guix licenses) #:prefix license:)
  57. #:use-module (guix packages)
  58. #:use-module (guix utils)
  59. #:use-module (ice-9 match)
  60. #:use-module ((srfi srfi-1) #:hide (zip)))
  61. (define-public glu
  62. (package
  63. (name "glu")
  64. (version "9.0.0")
  65. (source (origin
  66. (method url-fetch)
  67. (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/glu/glu-"
  68. version ".tar.gz"))
  69. (sha256
  70. (base32
  71. "0r72yyhj09x3krn3kn629jqbwyq50ji8w5ri2pn6zwrk35m4g1s3"))))
  72. (build-system gnu-build-system)
  73. (propagated-inputs
  74. `(("mesa" ,mesa))) ; according to glu.pc
  75. (home-page "http://www.opengl.org/archives/resources/faq/technical/glu.htm")
  76. (synopsis "Mesa OpenGL Utility library")
  77. (description
  78. "GLU, or OpenGL Utility Library provides some higher-level functionality
  79. not provided by just OpenGL itself. Some of GLU's Features
  80. include: Scaling of 2D images and creation of mipmap pyramids,
  81. Transformation of object coordinates into device coordinates and
  82. vice versa, Support for NURBS surfaces, Support for tessellation
  83. of concave or bow tie polygonal primitives, Specialty transformation
  84. matrices for creating perspective and orthographic projections,
  85. positioning a camera, and selection/picking, Rendering of disk,
  86. cylinder, and sphere primitives, Interpreting OpenGL error values
  87. as ASCII text.")
  88. (license (license:x11-style "http://directory.fsf.org/wiki/License:SGIFreeBv2"))))
  89. (define-public freeglut
  90. (package
  91. (name "freeglut")
  92. (version "3.0.0")
  93. (source (origin
  94. (method url-fetch)
  95. (uri (string-append
  96. "mirror://sourceforge/freeglut/freeglut/"
  97. version "/freeglut-" version ".tar.gz"))
  98. (sha256
  99. (base32
  100. "18knkyczzwbmyg8hr4zh8a1i5ga01np2jzd1rwmsh7mh2n2vwhra"))))
  101. (build-system cmake-build-system)
  102. (arguments '(#:tests? #f)) ; no test target
  103. (inputs `(("mesa" ,mesa)
  104. ("libx11" ,libx11)
  105. ("libxi" ,libxi)
  106. ("libxrandr" ,libxrandr)
  107. ("libxxf86vm" ,libxxf86vm)
  108. ("xorgproto" ,xorgproto)
  109. ("xinput" ,xinput)))
  110. (propagated-inputs
  111. ;; Headers from Mesa and GLU are needed.
  112. `(("glu" ,glu)
  113. ("mesa" ,mesa)))
  114. (home-page "http://freeglut.sourceforge.net/")
  115. (synopsis "Alternative to the OpenGL Utility Toolkit (GLUT)")
  116. (description
  117. "Freeglut is a completely Free/OpenSourced alternative to
  118. the OpenGL Utility Toolkit (GLUT) library. GLUT was originally
  119. written by Mark Kilgard to support the sample programs in the
  120. second edition OpenGL 'RedBook'. Since then, GLUT has been used
  121. in a wide variety of practical applications because it is simple,
  122. widely available and highly portable.
  123. GLUT (and hence freeglut) allows the user to create and manage windows
  124. containing OpenGL contexts on a wide range of platforms and also read
  125. the mouse, keyboard and joystick functions. Freeglut is released under
  126. the X-Consortium license.")
  127. (license license:x11)))
  128. ;; Needed for "kiki".
  129. (define-public freeglut-2.8
  130. (package (inherit freeglut)
  131. (name "freeglut")
  132. (version "2.8.1")
  133. (source (origin
  134. (method url-fetch)
  135. (uri (string-append
  136. "mirror://sourceforge/freeglut/freeglut/"
  137. version "/freeglut-" version ".tar.gz"))
  138. (sha256
  139. (base32
  140. "16lrxxxd9ps9l69y3zsw6iy0drwjsp6m26d1937xj71alqk6dr6x"))))
  141. (build-system gnu-build-system)))
  142. (define-public ftgl
  143. (package
  144. (name "ftgl")
  145. (version "2.1.3-rc5")
  146. (source (origin
  147. (method url-fetch)
  148. (uri (string-append
  149. "mirror://sourceforge/ftgl/FTGL%20Source/2.1.3~rc5/"
  150. "ftgl-" version ".tar.gz"))
  151. (sha256
  152. (base32
  153. "0nsn4s6vnv5xcgxcw6q031amvh2zfj2smy1r5mbnjj2548hxcn2l"))))
  154. (build-system gnu-build-system)
  155. ;; The pkg-config file lists "freetype2" as Requires.private.
  156. (propagated-inputs `(("freetype" ,freetype)))
  157. (inputs `(("libx11" ,libx11)
  158. ("mesa" ,mesa)
  159. ("glu" ,glu)))
  160. (native-inputs
  161. `(("pkg-config" ,pkg-config)))
  162. (home-page "http://ftgl.sourceforge.net")
  163. (synopsis "Font rendering library for OpenGL applications")
  164. (description
  165. "FTGL is a font rendering library for OpenGL applications. Supported
  166. rendering modes are: Bitmaps, Anti-aliased pixmaps, Texture maps, Outlines,
  167. Polygon meshes, and Extruded polygon meshes.")
  168. (license license:x11)))
  169. (define-public s2tc
  170. (package
  171. (name "s2tc")
  172. (version "1.0")
  173. (source
  174. (origin
  175. (method git-fetch)
  176. (uri (git-reference
  177. (url "https://github.com/divVerent/s2tc.git")
  178. (commit (string-append "v" version))))
  179. (file-name (git-file-name name version))
  180. (sha256
  181. (base32 "1fg323fk7wlv2xh6lw66wswgcv6qi8aaadk7c28h2f2lj1s7njnf"))))
  182. (build-system gnu-build-system)
  183. (native-inputs
  184. `(("autoconf" ,autoconf)
  185. ("automake" ,automake)
  186. ("libtool" ,libtool)))
  187. (inputs
  188. `(("mesa-headers" ,mesa-headers)))
  189. (home-page "https://github.com/divVerent/s2tc")
  190. (synopsis "S3 Texture Compression implementation")
  191. (description
  192. "S2TC is a patent-free implementation of S3 Texture Compression (S3TC,
  193. also known as DXTn or DXTC) for Mesa.")
  194. (license license:expat)))
  195. ;;; Mesa needs LibVA headers to build its Gallium-based VA API implementation;
  196. ;;; LibVA itself depends on Mesa. We use the following to solve the circular
  197. ;;; dependency.
  198. (define libva-without-mesa
  199. ;; Delay to work around circular import problem.
  200. (delay
  201. (package
  202. (inherit libva)
  203. (name "libva-without-mesa")
  204. (inputs `(,@(fold alist-delete (package-inputs libva)
  205. '("mesa" "wayland"))))
  206. (arguments
  207. (strip-keyword-arguments
  208. '(#:make-flags)
  209. (substitute-keyword-arguments (package-arguments libva)
  210. ((#:configure-flags flags)
  211. '(list "--disable-glx" "--disable-egl"))))))))
  212. (define-public mesa
  213. (package
  214. (name "mesa")
  215. (version "18.3.1")
  216. (source
  217. (origin
  218. (method url-fetch)
  219. (uri (list (string-append "https://mesa.freedesktop.org/archive/"
  220. "mesa-" version ".tar.xz")
  221. (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
  222. "mesa-" version ".tar.xz")
  223. (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
  224. version "/mesa-" version ".tar.xz")))
  225. (sha256
  226. (base32
  227. "0qyw9dj2p9n91qzc4ylck2an7ibssjvzi2bjcpv2ajk851yq47sv"))
  228. (patches
  229. (search-patches "mesa-skip-disk-cache-test.patch"))))
  230. (build-system gnu-build-system)
  231. (propagated-inputs
  232. `(;; The following are in the Requires.private field of gl.pc.
  233. ("libdrm" ,libdrm)
  234. ("libvdpau" ,libvdpau)
  235. ("libx11" ,libx11)
  236. ("libxdamage" ,libxdamage)
  237. ("libxfixes" ,libxfixes)
  238. ("libxshmfence" ,libxshmfence)
  239. ("libxxf86vm" ,libxxf86vm)
  240. ("xorgproto" ,xorgproto)))
  241. (inputs
  242. `(("expat" ,expat)
  243. ("libelf" ,elfutils) ;required for r600 when using llvm
  244. ("libva" ,(force libva-without-mesa))
  245. ("libxml2" ,libxml2)
  246. ;; TODO: Add 'libxml2-python' for OpenGL ES 1.1 and 2.0 support
  247. ("libxrandr" ,libxrandr)
  248. ("libxvmc" ,libxvmc)
  249. ,@(match (%current-system)
  250. ((or "x86_64-linux" "i686-linux")
  251. `(("llvm" ,llvm-6))) ;TODO: Change to LLVM in the next rebuild cycle.
  252. (_
  253. `()))
  254. ("makedepend" ,makedepend)
  255. ("wayland" ,wayland)
  256. ("wayland-protocols" ,wayland-protocols)))
  257. (native-inputs
  258. `(("pkg-config" ,pkg-config)
  259. ("python" ,python)
  260. ("python-mako" ,python-mako)
  261. ("which" ,(@ (gnu packages base) which))))
  262. (arguments
  263. `(#:configure-flags
  264. '(,@(match (%current-system)
  265. ((or "armhf-linux" "aarch64-linux")
  266. ;; TODO: Fix svga driver for aarch64 and armhf.
  267. '("--with-gallium-drivers=etnaviv,freedreno,imx,nouveau,pl111,r300,r600,swrast,tegra,v3d,vc4,virgl"))
  268. (_
  269. '("--with-gallium-drivers=i915,nouveau,r300,r600,radeonsi,svga,swrast,virgl")))
  270. ;; Enable various optional features. TODO: opencl requires libclc,
  271. ;; omx requires libomxil-bellagio
  272. "--with-platforms=x11,drm,surfaceless,wayland"
  273. "--enable-glx-tls" ;Thread Local Storage, improves performance
  274. ;; "--enable-opencl"
  275. ;; "--enable-omx"
  276. "--enable-osmesa"
  277. "--enable-xa"
  278. ;; features required by wayland
  279. "--enable-gles2"
  280. "--enable-gbm"
  281. "--enable-shared-glapi"
  282. ;; Enable Vulkan on i686-linux and x86-64-linux.
  283. ,@(match (%current-system)
  284. ("x86_64-linux"
  285. '("--with-vulkan-drivers=intel,radeon"))
  286. ;; TODO: Fix intel driver on i686-linux.
  287. ("i686-linux"
  288. '("--with-vulkan-drivers=radeon"))
  289. (_
  290. '("")))
  291. ;; Also enable the tests.
  292. "--enable-gallium-tests"
  293. ;; on non-intel systems, drop i915 and i965
  294. ;; from the default dri drivers
  295. ,@(match (%current-system)
  296. ((or "x86_64-linux" "i686-linux")
  297. '("--with-dri-drivers=i915,i965,nouveau,r200,radeon,swrast"
  298. "--enable-llvm")) ; default is x86/x86_64 only
  299. (_
  300. '("--with-dri-drivers=nouveau,r200,radeon,swrast"))))
  301. #:modules ((ice-9 match)
  302. (srfi srfi-1)
  303. (guix build utils)
  304. (guix build gnu-build-system))
  305. #:phases
  306. (modify-phases %standard-phases
  307. (add-after
  308. 'unpack 'patch-create_test_cases
  309. (lambda _
  310. (substitute* "src/intel/genxml/gen_pack_header.py"
  311. (("/usr/bin/env python2") (which "python")))
  312. #t))
  313. (add-before
  314. 'build 'fix-dlopen-libnames
  315. (lambda* (#:key inputs outputs #:allow-other-keys)
  316. (let ((out (assoc-ref outputs "out")))
  317. ;; Remain agnostic to .so.X.Y.Z versions while doing
  318. ;; the substitutions so we're future-safe.
  319. (substitute* "src/glx/dri_common.c"
  320. (("dlopen\\(\"libGL\\.so")
  321. (string-append "dlopen(\"" out "/lib/libGL.so")))
  322. (substitute* "src/egl/drivers/dri2/egl_dri2.c"
  323. (("\"libglapi\\.so")
  324. (string-append "\"" out "/lib/libglapi.so")))
  325. (substitute* "src/gbm/main/backend.c"
  326. ;; No need to patch the gbm_gallium_drm.so reference;
  327. ;; it's never installed since Mesa removed its
  328. ;; egl_gallium support.
  329. (("\"gbm_dri\\.so")
  330. (string-append "\"" out "/lib/dri/gbm_dri.so")))
  331. #t)))
  332. (add-after 'install 'symlinks-instead-of-hard-links
  333. (lambda* (#:key outputs #:allow-other-keys)
  334. ;; All the drivers and gallium targets create hard links upon
  335. ;; installation (search for "hardlink each megadriver instance"
  336. ;; in the makefiles). This is no good for us since we'd produce
  337. ;; nars that contain several copies of these files. Thus, turn
  338. ;; them into symlinks, which saves ~124 MiB.
  339. (let* ((out (assoc-ref outputs "out"))
  340. (lib (string-append out "/lib"))
  341. (files (find-files lib
  342. (lambda (file stat)
  343. (and (string-contains file ".so")
  344. (eq? 'regular
  345. (stat:type stat))))))
  346. (inodes (map (compose stat:ino stat) files)))
  347. (for-each (lambda (inode)
  348. (match (filter-map (match-lambda
  349. ((file ino)
  350. (and (= ino inode) file)))
  351. (zip files inodes))
  352. ((_)
  353. #f)
  354. ((reference others ..1)
  355. (format #t "creating ~a symlinks to '~a'~%"
  356. (length others) reference)
  357. (for-each delete-file others)
  358. (for-each (lambda (file)
  359. (if (string=? (dirname file)
  360. (dirname reference))
  361. (symlink (basename reference)
  362. file)
  363. (symlink reference file)))
  364. others))))
  365. (delete-duplicates inodes))
  366. #t))))))
  367. (home-page "https://mesa3d.org/")
  368. (synopsis "OpenGL and Vulkan implementations")
  369. (description "Mesa is a free implementation of the OpenGL and Vulkan
  370. specifications - systems for rendering interactive 3D graphics. A variety of
  371. device drivers allows Mesa to be used in many different environments ranging
  372. from software emulation to complete hardware acceleration for modern GPUs.")
  373. (license license:x11)))
  374. (define-public mesa-headers
  375. (package
  376. (inherit mesa)
  377. (name "mesa-headers")
  378. (propagated-inputs '())
  379. (inputs '())
  380. (native-inputs '())
  381. (arguments
  382. '(#:phases
  383. (modify-phases %standard-phases
  384. (delete 'configure)
  385. (delete 'build)
  386. (delete 'check)
  387. (replace 'install
  388. (lambda* (#:key outputs #:allow-other-keys)
  389. (copy-recursively "include" (string-append
  390. (assoc-ref outputs "out")
  391. "/include"))
  392. #t)))))))
  393. ;;; The mesa-demos distribution contains non-free files, many files with no
  394. ;;; clear license information, and many demos that aren't useful for most
  395. ;;; people, so we just use this for the mesa-utils package below, and possibly
  396. ;;; other packages in the future. This is modeled after Debian's solution.
  397. (define (mesa-demos-source version)
  398. (origin
  399. (method url-fetch)
  400. (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/demos"
  401. "/mesa-demos-" version ".tar.bz2"))
  402. (sha256 (base32 "0zgzbz55a14hz83gbmm0n9gpjnf5zadzi2kjjvkn6khql2a9rs81"))))
  403. (define-public mesa-utils
  404. (package
  405. (name "mesa-utils")
  406. (version "8.4.0")
  407. (source (mesa-demos-source version))
  408. (build-system gnu-build-system)
  409. (inputs
  410. `(("mesa" ,mesa)
  411. ("glut" ,freeglut)
  412. ("glew" ,glew)))
  413. (native-inputs
  414. `(("pkg-config" ,pkg-config)))
  415. (arguments
  416. '(#:phases
  417. (modify-phases %standard-phases
  418. (replace
  419. 'install
  420. (lambda* (#:key outputs #:allow-other-keys)
  421. (let ((out (assoc-ref outputs "out")))
  422. (mkdir-p (string-append out "/bin"))
  423. (for-each
  424. (lambda (file)
  425. (copy-file file (string-append out "/bin/" (basename file))))
  426. '("src/xdemos/glxdemo" "src/xdemos/glxgears"
  427. "src/xdemos/glxinfo" "src/xdemos/glxheads"))
  428. #t))))))
  429. (home-page "http://mesa3d.org/")
  430. (synopsis "Utility tools for Mesa")
  431. (description
  432. "The mesa-utils package contains several utility tools for Mesa: glxdemo,
  433. glxgears, glxheads, and glxinfo.")
  434. ;; glxdemo is public domain; others expat.
  435. (license (list license:expat license:public-domain))))
  436. (define-public glew
  437. (package
  438. (name "glew")
  439. (version "2.1.0")
  440. (source (origin
  441. (method url-fetch)
  442. (uri (string-append "mirror://sourceforge/glew/glew/" version
  443. "/glew-" version ".tgz"))
  444. (sha256
  445. (base32
  446. "159wk5dc0ykjbxvag5i1m2mhp23zkk6ra04l26y3jc3nwvkr3ph4"))
  447. (modules '((guix build utils)))
  448. (snippet
  449. '(begin
  450. (substitute* "config/Makefile.linux"
  451. (("= cc") "= gcc")
  452. (("/lib64") "/lib"))
  453. #t))))
  454. (build-system gnu-build-system)
  455. (arguments
  456. '(#:phases (modify-phases %standard-phases (delete 'configure))
  457. #:make-flags (list (string-append "GLEW_PREFIX="
  458. (assoc-ref %outputs "out"))
  459. (string-append "GLEW_DEST="
  460. (assoc-ref %outputs "out")))
  461. #:tests? #f)) ;no 'check' target
  462. (inputs
  463. `(("libxi" ,libxi)
  464. ("libxmu" ,libxmu)
  465. ("libx11" ,libx11)
  466. ("mesa" ,mesa)))
  467. ;; <GL/glew.h> includes <GL/glu.h>.
  468. (propagated-inputs `(("glu" ,glu)))
  469. (home-page "http://glew.sourceforge.net/")
  470. (synopsis "OpenGL extension loading library for C and C++")
  471. (description
  472. "The OpenGL Extension Wrangler Library (GLEW) is a C/C++ extension
  473. loading library. GLEW provides efficient run-time mechanisms for determining
  474. which OpenGL extensions are supported on the target platform. OpenGL core and
  475. extension functionality is exposed in a single header file.")
  476. (license license:bsd-3)))
  477. (define-public guile-opengl
  478. (package
  479. (name "guile-opengl")
  480. (version "0.1.0")
  481. (source (origin
  482. (method url-fetch)
  483. (uri (string-append "mirror://gnu/guile-opengl/guile-opengl-"
  484. version ".tar.gz"))
  485. (sha256
  486. (base32
  487. "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim"))))
  488. (build-system gnu-build-system)
  489. (native-inputs `(("pkg-config" ,pkg-config)))
  490. (inputs `(("guile" ,guile-2.2)
  491. ("mesa" ,mesa)
  492. ("glu" ,glu)
  493. ("freeglut" ,freeglut)))
  494. (arguments
  495. '(#:phases (modify-phases %standard-phases
  496. (add-after 'configure 'patch-makefile
  497. (lambda _
  498. ;; Install compiled Guile files in the expected place.
  499. (substitute* '("Makefile")
  500. (("^godir = .*$")
  501. "godir = $(moddir)\n"))))
  502. (add-before 'build 'patch-dynamic-link
  503. (lambda* (#:key inputs outputs #:allow-other-keys)
  504. (define (dynamic-link-substitute file lib input)
  505. (substitute* file
  506. (("dynamic-link \"lib([a-zA-Z]+)\"" _ lib)
  507. (string-append "dynamic-link \""
  508. (assoc-ref inputs input)
  509. "/lib/lib" lib "\""))))
  510. ;; Replace dynamic-link calls for libGL, libGLU, and
  511. ;; libglut with absolute paths to the store.
  512. (dynamic-link-substitute "glx/runtime.scm" "GL" "mesa")
  513. (dynamic-link-substitute "glu/runtime.scm" "GLU" "glu")
  514. (dynamic-link-substitute "glut/runtime.scm" "glut"
  515. "freeglut"))))))
  516. (home-page "https://gnu.org/s/guile-opengl")
  517. (synopsis "Guile binding for the OpenGL graphics API")
  518. (description
  519. "Guile-OpenGL is a library for Guile that provides bindings to the
  520. OpenGL graphics API.")
  521. (license license:lgpl3+)))
  522. (define-public libepoxy
  523. (package
  524. (name "libepoxy")
  525. (version "1.5.3")
  526. (source (origin
  527. (method url-fetch)
  528. (uri (string-append
  529. "https://github.com/anholt/libepoxy/releases/download/"
  530. version "/libepoxy-" version ".tar.xz"))
  531. (sha256
  532. (base32
  533. "0ga3qjv50x37my6pw5xr14g5n6z78hy5s8s06kays8c3ab2mha80"))))
  534. (arguments
  535. `(#:phases
  536. (modify-phases %standard-phases
  537. (delete 'bootstrap)
  538. (add-before
  539. 'configure 'patch-paths
  540. (lambda* (#:key inputs #:allow-other-keys)
  541. (let ((python (assoc-ref inputs "python"))
  542. (mesa (assoc-ref inputs "mesa")))
  543. (substitute* "src/gen_dispatch.py"
  544. (("/usr/bin/env python") python))
  545. (substitute* (find-files "." "\\.[ch]$")
  546. (("libGL.so.1") (string-append mesa "/lib/libGL.so.1"))
  547. (("libEGL.so.1") (string-append mesa "/lib/libEGL.so.1")))
  548. #t))))))
  549. (build-system meson-build-system)
  550. (native-inputs
  551. `(("pkg-config" ,pkg-config)
  552. ("python" ,python)))
  553. (inputs
  554. `(("mesa" ,mesa)))
  555. (home-page "https://github.com/anholt/libepoxy/")
  556. (synopsis "A library for handling OpenGL function pointer management")
  557. (description
  558. "A library for handling OpenGL function pointer management.")
  559. (license license:x11)))
  560. (define-public soil
  561. (package
  562. (name "soil")
  563. (version "1.0.7")
  564. (source (origin
  565. (method url-fetch)
  566. ;; No versioned archive available.
  567. (uri "http://www.lonesock.net/files/soil.zip")
  568. (sha256
  569. (base32
  570. "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52"))))
  571. (build-system gnu-build-system)
  572. (arguments
  573. '(#:tests? #f ; no tests
  574. #:phases (modify-phases %standard-phases
  575. (delete 'configure)
  576. (add-before 'build 'init-build
  577. (lambda* (#:key outputs #:allow-other-keys)
  578. (let ((out (assoc-ref outputs "out")))
  579. (setenv "CFLAGS" "-fPIC") ; needed for shared library
  580. ;; Use alternate Makefile
  581. (copy-file "projects/makefile/alternate Makefile.txt"
  582. "src/Makefile")
  583. (chdir "src")
  584. (substitute* '("Makefile")
  585. (("INCLUDEDIR = /usr/include/SOIL")
  586. (string-append "INCLUDEDIR = " out "/include/SOIL"))
  587. (("LIBDIR = /usr/lib")
  588. (string-append "LIBDIR = " out "/lib"))
  589. ;; Remove these flags from 'install' commands.
  590. (("-o root -g root") ""))))))))
  591. (native-inputs
  592. `(("unzip" ,unzip)))
  593. (inputs
  594. `(("mesa" ,mesa)))
  595. (home-page "http://www.lonesock.net/soil.html")
  596. (synopsis "OpenGL texture loading library")
  597. (description
  598. "SOIL is a tiny C library used primarily for uploading textures into
  599. OpenGL.")
  600. (license license:public-domain)))
  601. (define-public glfw
  602. (package
  603. (name "glfw")
  604. (version "3.2.1")
  605. (source (origin
  606. (method url-fetch)
  607. (uri (string-append "https://github.com/glfw/glfw"
  608. "/releases/download/" version
  609. "/glfw-" version ".zip"))
  610. (sha256
  611. (base32
  612. "09kk5yc1zhss9add8ryqrngrr16hdmc94rszgng135bhw09mxmdp"))))
  613. (build-system cmake-build-system)
  614. (arguments
  615. '(#:tests? #f ; no test target
  616. #:configure-flags '("-DBUILD_SHARED_LIBS=ON")))
  617. (native-inputs
  618. `(("doxygen" ,doxygen)
  619. ("unzip" ,unzip)))
  620. (propagated-inputs
  621. `(("mesa" ,mesa) ;included in public headers
  622. ;; These are in 'Requires.private' of 'glfw3.pc'.
  623. ("libx11" ,libx11)
  624. ("libxrandr" ,libxrandr)
  625. ("libxinerama" ,libxinerama)
  626. ("libxcursor" ,libxcursor)
  627. ("libxxf86vm" ,libxxf86vm)))
  628. (home-page "http://www.glfw.org")
  629. (synopsis "OpenGL application development library")
  630. (description
  631. "GLFW is a library for OpenGL, OpenGL ES and Vulkan development for
  632. desktop computers. It provides a simple API for creating windows, contexts
  633. and surfaces, receiving input and events.")
  634. (license license:zlib)))
  635. (define-public nanovg-for-extempore
  636. (package
  637. (name "nanovg-for-extempore")
  638. (version "0.7.1")
  639. (source (origin
  640. (method url-fetch)
  641. (uri (string-append "https://github.com/extemporelang/nanovg/"
  642. "archive/" version ".tar.gz"))
  643. (file-name (string-append name "-" version ".tar.gz"))
  644. (sha256
  645. (base32
  646. "0ivs1sagq19xiw8jxd9f8w2b39svi0n9hrbmdvckwvqg95r8701g"))))
  647. (build-system cmake-build-system)
  648. (arguments `(#:tests? #f)) ; no tests included
  649. (inputs
  650. `(("mesa" ,mesa)))
  651. ;; Extempore refuses to build on architectures other than x86_64
  652. (supported-systems '("x86_64-linux"))
  653. (home-page "https://github.com/extemporelang/nanovg")
  654. (synopsis "2D vector drawing library on top of OpenGL")
  655. (description "NanoVG is small antialiased vector graphics rendering
  656. library for OpenGL. It has lean API modeled after HTML5 canvas API. It is
  657. aimed to be a practical and fun toolset for building scalable user interfaces
  658. and visualizations.")
  659. (license license:zlib)))
  660. (define-public gl2ps
  661. (package
  662. (name "gl2ps")
  663. (version "1.4.0")
  664. (source
  665. (origin
  666. (method url-fetch)
  667. (uri (string-append
  668. "http://geuz.org/gl2ps/src/gl2ps-"
  669. version ".tgz"))
  670. (sha256
  671. (base32
  672. "1qpidkz8x3bxqf69hlhyz1m0jmfi9kq24fxsp7rq6wfqzinmxjq3"))))
  673. (build-system cmake-build-system)
  674. (inputs
  675. `(("libpng" ,libpng)
  676. ("mesa" ,mesa)
  677. ("zlib" ,zlib)))
  678. (arguments
  679. `(#:tests? #f)) ;; no tests
  680. (home-page "http://www.geuz.org/gl2ps/")
  681. (synopsis "OpenGL to PostScript printing library")
  682. (description "GL2PS is a C library providing high quality vector
  683. output for any OpenGL application. GL2PS uses sorting algorithms
  684. capable of handling intersecting and stretched polygons, as well as
  685. non-manifold objects. GL2PS provides many features including advanced
  686. smooth shading and text rendering, culling of invisible primitives and
  687. mixed vector/bitmap output.")
  688. ;; GL2PS is dual-licenced and can be used under the terms of either.
  689. (license (list license:lgpl2.0+
  690. (license:fsf-free "http://www.geuz.org/gl2ps/COPYING.GL2PS"
  691. "GPL-incompatible copyleft license")))))
  692. (define-public virtualgl
  693. (package
  694. (name "virtualgl")
  695. (version "2.6")
  696. (source
  697. (origin
  698. (method git-fetch)
  699. (uri (git-reference
  700. (url "https://github.com/VirtualGL/virtualgl.git")
  701. (commit version)))
  702. (file-name (git-file-name name version))
  703. (sha256
  704. (base32
  705. "0di2igj2bhwb153fndgxks7y57pyhp0gj31n47j93gb7lxc9qcck"))))
  706. (arguments
  707. `(#:tests? #f ; no tests are available
  708. #:configure-flags (list
  709. (string-append "-DCMAKE_INSTALL_LIBDIR="
  710. (assoc-ref %outputs "out") "/lib")
  711. "-DVGL_USESSL=1"))) ; use OpenSSL
  712. (build-system cmake-build-system)
  713. (inputs `(("glu" ,glu)
  714. ("libjpeg-turbo" ,libjpeg-turbo)
  715. ("libxtst" ,libxtst)
  716. ("mesa" ,mesa)
  717. ("openssl" ,openssl)))
  718. (native-inputs `(("pkg-config" ,pkg-config)))
  719. (home-page "https://www.virtualgl.org")
  720. (synopsis "Redirects 3D commands from an OpenGL application onto a 3D
  721. graphics card")
  722. (description "VirtualGL redirects the 3D rendering commands from OpenGL
  723. applications to 3D accelerator hardware in a dedicated server and displays the
  724. rendered output interactively to a thin client located elsewhere on the
  725. network.")
  726. (license license:wxwindows3.1+)))