Merge branch 'master' into staging
[jackhill/guix/guix.git] / gnu / packages / gl.scm
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 ng0 <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, 2019 Efraim Flashner <efraim@flashner.co.il>
10 ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
11 ;;; Copyright © 2017, 2018, 2019 Rutger Helling <rhelling@mykolab.com>
12 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
13 ;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
14 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
15 ;;;
16 ;;; This file is part of GNU Guix.
17 ;;;
18 ;;; GNU Guix is free software; you can redistribute it and/or modify it
19 ;;; under the terms of the GNU General Public License as published by
20 ;;; the Free Software Foundation; either version 3 of the License, or (at
21 ;;; your option) any later version.
22 ;;;
23 ;;; GNU Guix is distributed in the hope that it will be useful, but
24 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
25 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 ;;; GNU General Public License for more details.
27 ;;;
28 ;;; You should have received a copy of the GNU General Public License
29 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
30
31 (define-module (gnu packages gl)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages autotools)
34 #:use-module (gnu packages bison)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages documentation)
37 #:use-module (gnu packages elf)
38 #:use-module (gnu packages flex)
39 #:use-module (gnu packages fontutils)
40 #:use-module (gnu packages freedesktop)
41 #:use-module (gnu packages gettext)
42 #:use-module (gnu packages guile)
43 #:use-module (gnu packages image)
44 #:use-module (gnu packages linux)
45 #:use-module (gnu packages llvm)
46 #:use-module (gnu packages mono)
47 #:use-module (gnu packages pkg-config)
48 #:use-module (gnu packages python)
49 #:use-module (gnu packages python-xyz)
50 #:use-module (gnu packages tls)
51 #:use-module (gnu packages video)
52 #:use-module (gnu packages vulkan)
53 #:use-module (gnu packages xdisorg)
54 #:use-module (gnu packages xml)
55 #:use-module (gnu packages xorg)
56 #:use-module (guix download)
57 #:use-module (guix git-download)
58 #:use-module (guix hg-download)
59 #:use-module (guix build-system gnu)
60 #:use-module (guix build-system cmake)
61 #:use-module (guix build-system meson)
62 #:use-module ((guix licenses) #:prefix license:)
63 #:use-module (guix packages)
64 #:use-module (guix utils)
65 #:use-module (ice-9 match)
66 #:use-module ((srfi srfi-1) #:hide (zip)))
67
68 (define-public glu
69 (package
70 (name "glu")
71 (version "9.0.1")
72 (source (origin
73 (method url-fetch)
74 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/glu/glu-"
75 version ".tar.gz"))
76 (sha256
77 (base32
78 "1xqhk9bn10nbvffw3r4p4rjslwz1l7gaycc0x2pqkr2irp7q9x7n"))))
79 (build-system gnu-build-system)
80 (propagated-inputs
81 `(("mesa" ,mesa))) ; according to glu.pc
82 (home-page "http://www.opengl.org/archives/resources/faq/technical/glu.htm")
83 (synopsis "Mesa OpenGL Utility library")
84 (description
85 "GLU, or OpenGL Utility Library provides some higher-level functionality
86 not provided by just OpenGL itself. Some of GLU's Features
87 include: Scaling of 2D images and creation of mipmap pyramids,
88 Transformation of object coordinates into device coordinates and
89 vice versa, Support for NURBS surfaces, Support for tessellation
90 of concave or bow tie polygonal primitives, Specialty transformation
91 matrices for creating perspective and orthographic projections,
92 positioning a camera, and selection/picking, Rendering of disk,
93 cylinder, and sphere primitives, Interpreting OpenGL error values
94 as ASCII text.")
95 (license (license:x11-style "http://directory.fsf.org/wiki/License:SGIFreeBv2"))))
96
97 (define-public freeglut
98 (package
99 (name "freeglut")
100 (version "3.2.1")
101 (source (origin
102 (method url-fetch)
103 (uri (string-append
104 "mirror://sourceforge/freeglut/freeglut/"
105 version "/freeglut-" version ".tar.gz"))
106 (sha256
107 (base32
108 "0s6sk49q8ijgbsrrryb7dzqx2fa744jhx1wck5cz5jia2010w06l"))))
109 (build-system cmake-build-system)
110 (arguments
111 '(#:tests? #f ;no test target
112 #:configure-flags '("-DFREEGLUT_BUILD_STATIC_LIBS=OFF")))
113 (inputs `(("libx11" ,libx11)
114 ("libxi" ,libxi)
115 ("libxrandr" ,libxrandr)
116 ("libxxf86vm" ,libxxf86vm)))
117 (propagated-inputs
118 ;; Headers from Mesa and GLU are needed.
119 `(("glu" ,glu)
120 ("mesa" ,mesa)))
121 (home-page "http://freeglut.sourceforge.net/")
122 (synopsis "Alternative to the OpenGL Utility Toolkit (GLUT)")
123 (description
124 "Freeglut is a completely Free/OpenSourced alternative to
125 the OpenGL Utility Toolkit (GLUT) library. GLUT was originally
126 written by Mark Kilgard to support the sample programs in the
127 second edition OpenGL @code{RedBook}. Since then, GLUT has been used
128 in a wide variety of practical applications because it is simple,
129 widely available and highly portable.
130
131 GLUT (and hence freeglut) allows the user to create and manage windows
132 containing OpenGL contexts on a wide range of platforms and also read
133 the mouse, keyboard and joystick functions. Freeglut is released under
134 the X-Consortium license.")
135 (license license:x11)))
136
137 ;; Needed for "kiki".
138 (define-public freeglut-2.8
139 (package (inherit freeglut)
140 (name "freeglut")
141 (version "2.8.1")
142 (source (origin
143 (method url-fetch)
144 (uri (string-append
145 "mirror://sourceforge/freeglut/freeglut/"
146 version "/freeglut-" version ".tar.gz"))
147 (sha256
148 (base32
149 "16lrxxxd9ps9l69y3zsw6iy0drwjsp6m26d1937xj71alqk6dr6x"))))
150 (build-system gnu-build-system)
151 (arguments
152 '(#:configure-flags '("--disable-static")))))
153
154 (define-public ftgl
155 (package
156 (name "ftgl")
157 (version "2.4.0")
158 (home-page "https://github.com/frankheckenbach/ftgl")
159 (source (origin
160 (method git-fetch)
161 (uri (git-reference (url home-page)
162 (commit (string-append "v" version))))
163 (file-name (git-file-name name version))
164 (sha256
165 (base32
166 "0zjs1h9w30gajq9lndzvjsa26rsmr1081lb1fbpbj10yhcdcsc79"))))
167 (build-system gnu-build-system)
168 (arguments
169 `(#:configure-flags '("--disable-static")))
170 ;; The pkg-config file lists "freetype2" as Requires.private.
171 (propagated-inputs `(("freetype" ,freetype)))
172 (inputs `(("libx11" ,libx11)
173 ("mesa" ,mesa)
174 ("glu" ,glu)))
175 (native-inputs
176 `(("pkg-config" ,pkg-config)
177 ("autoconf" ,autoconf)
178 ("automake" ,automake)
179 ("libtool" ,libtool)))
180 (synopsis "Font rendering library for OpenGL applications")
181 (description
182 "FTGL is a font rendering library for OpenGL applications. Supported
183 rendering modes are: Bitmaps, Anti-aliased pixmaps, Texture maps, Outlines,
184 Polygon meshes, and Extruded polygon meshes.")
185 (license license:x11)))
186
187 (define-public s2tc
188 (package
189 (name "s2tc")
190 (version "1.0")
191 (source
192 (origin
193 (method git-fetch)
194 (uri (git-reference
195 (url "https://github.com/divVerent/s2tc.git")
196 (commit (string-append "v" version))))
197 (file-name (git-file-name name version))
198 (sha256
199 (base32 "1fg323fk7wlv2xh6lw66wswgcv6qi8aaadk7c28h2f2lj1s7njnf"))))
200 (build-system gnu-build-system)
201 (native-inputs
202 `(("autoconf" ,autoconf)
203 ("automake" ,automake)
204 ("libtool" ,libtool)))
205 (inputs
206 `(("mesa-headers" ,mesa-headers)))
207 (home-page "https://github.com/divVerent/s2tc")
208 (synopsis "S3 Texture Compression implementation")
209 (description
210 "S2TC is a patent-free implementation of S3 Texture Compression (S3TC,
211 also known as DXTn or DXTC) for Mesa.")
212 (license license:expat)))
213
214 ;;; Mesa needs LibVA headers to build its Gallium-based VA API implementation;
215 ;;; LibVA itself depends on Mesa. We use the following to solve the circular
216 ;;; dependency.
217 (define libva-without-mesa
218 ;; Delay to work around circular import problem.
219 (delay
220 (package
221 (inherit libva)
222 (name "libva-without-mesa")
223 (inputs `(,@(fold alist-delete (package-inputs libva)
224 '("mesa" "wayland"))))
225 (arguments
226 (strip-keyword-arguments
227 '(#:make-flags)
228 (substitute-keyword-arguments (package-arguments libva)
229 ((#:configure-flags flags)
230 '(list "--disable-glx" "--disable-egl"))))))))
231
232 (define-public mesa
233 (package
234 (name "mesa")
235 (version "19.3.4")
236 (source
237 (origin
238 (method url-fetch)
239 (uri (list (string-append "https://mesa.freedesktop.org/archive/"
240 "mesa-" version ".tar.xz")
241 (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
242 "mesa-" version ".tar.xz")
243 (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
244 version "/mesa-" version ".tar.xz")))
245 (sha256
246 (base32
247 "1r4giqq7q7zqbn23lbw7v5vswagxx8qj6ij2w8bsb697mvk6g90x"))
248 (patches
249 (search-patches "mesa-skip-disk-cache-test.patch"))))
250 (build-system meson-build-system)
251 (propagated-inputs
252 `(;; The following are in the Requires.private field of gl.pc.
253 ("libdrm" ,libdrm)
254 ("libvdpau" ,libvdpau)
255 ("libx11" ,libx11)
256 ("libxdamage" ,libxdamage)
257 ("libxfixes" ,libxfixes)
258 ("libxshmfence" ,libxshmfence)
259 ("libxxf86vm" ,libxxf86vm)
260 ("xorgproto" ,xorgproto)))
261 (inputs
262 `(("expat" ,expat)
263 ("libelf" ,elfutils) ;required for r600 when using llvm
264 ("libva" ,(force libva-without-mesa))
265 ("libxml2" ,libxml2)
266 ;; TODO: Add 'libxml2-python' for OpenGL ES 1.1 and 2.0 support
267 ("libxrandr" ,libxrandr)
268 ("libxvmc" ,libxvmc)
269 ,@(match (%current-system)
270 ((or "x86_64-linux" "i686-linux")
271 `(("llvm" ,llvm-8)))
272 (_
273 `()))
274 ("makedepend" ,makedepend)
275 ("wayland" ,wayland)
276 ("wayland-protocols" ,wayland-protocols)))
277 (native-inputs
278 `(("bison" ,bison)
279 ("flex" ,flex)
280 ("gettext" ,gettext-minimal)
281 ,@(match (%current-system)
282 ((or "x86_64-linux" "i686-linux")
283 `(("glslang" ,glslang)))
284 (_
285 `()))
286 ("pkg-config" ,pkg-config)
287 ("python" ,python-wrapper)
288 ("python-mako" ,python-mako)
289 ("which" ,(@ (gnu packages base) which))))
290 (arguments
291 `(#:configure-flags
292 '(,@(match (%current-system)
293 ((or "armhf-linux" "aarch64-linux")
294 ;; TODO: Fix svga driver for aarch64 and armhf.
295 '("-Dgallium-drivers=etnaviv,freedreno,nouveau,r300,r600,swrast,tegra,v3d,vc4,virgl"))
296 (_
297 '("-Dgallium-drivers=iris,nouveau,r300,r600,radeonsi,svga,swrast,virgl")))
298 ;; Enable various optional features. TODO: opencl requires libclc,
299 ;; omx requires libomxil-bellagio
300 "-Dplatforms=x11,drm,surfaceless,wayland"
301 "-Dglx=dri" ;Thread Local Storage, improves performance
302 ;; "-Dopencl=true"
303 ;; "-Domx=true"
304 "-Dosmesa=gallium"
305 "-Dgallium-xa=true"
306
307 ;; features required by wayland
308 "-Dgles2=true"
309 "-Dgbm=true"
310 "-Dshared-glapi=true"
311
312 ;; Enable Vulkan on i686-linux and x86-64-linux.
313 ,@(match (%current-system)
314 ((or "i686-linux" "x86_64-linux")
315 '("-Dvulkan-drivers=intel,amd"))
316 (_
317 '("-Dvulkan-drivers=auto")))
318
319 ;; Enable the Vulkan overlay layer on i686-linux and x86-64-linux.
320 ,@(match (%current-system)
321 ((or "x86_64-linux" "i686-linux")
322 '("-Dvulkan-overlay-layer=true"))
323 (_
324 '()))
325
326 ;; Also enable the tests.
327 "-Dbuild-tests=true"
328
329 ;; on non-intel systems, drop i915 and i965
330 ;; from the default dri drivers
331 ,@(match (%current-system)
332 ((or "x86_64-linux" "i686-linux")
333 '("-Ddri-drivers=i915,i965,nouveau,r200,r100"
334 "-Dllvm=true")) ; default is x86/x86_64 only
335 (_
336 '("-Ddri-drivers=nouveau,r200,r100"))))
337
338 ;; XXX: 'debugoptimized' causes LTO link failures on some drivers. The
339 ;; documentation recommends using 'release' for performance anyway.
340 #:build-type "release"
341
342 #:modules ((ice-9 match)
343 (srfi srfi-1)
344 (guix build utils)
345 (guix build meson-build-system))
346 #:phases
347 (modify-phases %standard-phases
348 (add-after
349 'unpack 'patch-create_test_cases
350 (lambda _
351 (substitute* "src/intel/genxml/gen_pack_header.py"
352 (("/usr/bin/env python2") (which "python")))
353 #t))
354 ,@(if (string-prefix? "i686" (or (%current-target-system)
355 (%current-system)))
356 ;; Disable new test from Mesa 19 that fails on i686. Upstream
357 ;; report: <https://bugs.freedesktop.org/show_bug.cgi?id=110612>.
358 `((add-after 'unpack 'disable-failing-test
359 (lambda _
360 (substitute* "src/gallium/tests/unit/meson.build"
361 (("'u_format_test',") ""))
362 #t)))
363 '())
364 (add-before
365 'configure 'fix-dlopen-libnames
366 (lambda* (#:key inputs outputs #:allow-other-keys)
367 (let ((out (assoc-ref outputs "out")))
368 ;; Remain agnostic to .so.X.Y.Z versions while doing
369 ;; the substitutions so we're future-safe.
370 (substitute* "src/glx/dri_common.c"
371 (("dlopen\\(\"libGL\\.so")
372 (string-append "dlopen(\"" out "/lib/libGL.so")))
373 (substitute* "src/egl/drivers/dri2/egl_dri2.c"
374 (("\"libglapi\\.so")
375 (string-append "\"" out "/lib/libglapi.so")))
376 (substitute* "src/gbm/main/backend.c"
377 ;; No need to patch the gbm_gallium_drm.so reference;
378 ;; it's never installed since Mesa removed its
379 ;; egl_gallium support.
380 (("\"gbm_dri\\.so")
381 (string-append "\"" out "/lib/dri/gbm_dri.so")))
382 #t)))
383 (add-after 'install 'symlinks-instead-of-hard-links
384 (lambda* (#:key outputs #:allow-other-keys)
385 ;; All the drivers and gallium targets create hard links upon
386 ;; installation (search for "hardlink each megadriver instance"
387 ;; in the makefiles). This is no good for us since we'd produce
388 ;; nars that contain several copies of these files. Thus, turn
389 ;; them into symlinks, which saves ~124 MiB.
390 (let* ((out (assoc-ref outputs "out"))
391 (lib (string-append out "/lib"))
392 (files (find-files lib
393 (lambda (file stat)
394 (and (string-contains file ".so")
395 (eq? 'regular
396 (stat:type stat))))))
397 (inodes (map (compose stat:ino stat) files)))
398 (for-each (lambda (inode)
399 (match (filter-map (match-lambda
400 ((file ino)
401 (and (= ino inode) file)))
402 (zip files inodes))
403 ((_)
404 #f)
405 ((reference others ..1)
406 (format #t "creating ~a symlinks to '~a'~%"
407 (length others) reference)
408 (for-each delete-file others)
409 (for-each (lambda (file)
410 (if (string=? (dirname file)
411 (dirname reference))
412 (symlink (basename reference)
413 file)
414 (symlink reference file)))
415 others))))
416 (delete-duplicates inodes))
417 #t))))))
418 (home-page "https://mesa3d.org/")
419 (synopsis "OpenGL and Vulkan implementations")
420 (description "Mesa is a free implementation of the OpenGL and Vulkan
421 specifications - systems for rendering interactive 3D graphics. A variety of
422 device drivers allows Mesa to be used in many different environments ranging
423 from software emulation to complete hardware acceleration for modern GPUs.")
424 (license license:x11)))
425
426 (define-public mesa-opencl
427 (package
428 (inherit mesa)
429 (name "mesa-opencl")
430 (arguments
431 (substitute-keyword-arguments (package-arguments mesa)
432 ((#:configure-flags flags)
433 `(cons "-Dgallium-opencl=standalone" ,flags))))
434 (inputs
435 `(("libclc" ,libclc)
436 ,@(package-inputs mesa)))
437 (native-inputs
438 `(("clang" ,clang-8)
439 ,@(package-native-inputs mesa)))))
440
441 (define-public mesa-opencl-icd
442 (package
443 (inherit mesa-opencl)
444 (name "mesa-opencl-icd")
445 (arguments
446 (substitute-keyword-arguments (package-arguments mesa)
447 ((#:configure-flags flags)
448 `(cons "-Dgallium-opencl=icd"
449 ,(delete "-Dgallium-opencl=standalone" flags)))))))
450
451 (define-public mesa-headers
452 (package
453 (inherit mesa)
454 (name "mesa-headers")
455 (propagated-inputs '())
456 (inputs '())
457 (native-inputs '())
458 (arguments
459 '(#:phases
460 (modify-phases %standard-phases
461 (delete 'configure)
462 (delete 'build)
463 (delete 'check)
464 (replace 'install
465 (lambda* (#:key outputs #:allow-other-keys)
466 (copy-recursively "include" (string-append
467 (assoc-ref outputs "out")
468 "/include"))
469 #t)))))))
470
471 ;;; The mesa-demos distribution contains non-free files, many files with no
472 ;;; clear license information, and many demos that aren't useful for most
473 ;;; people, so we just use this for the mesa-utils package below, and possibly
474 ;;; other packages in the future. This is modeled after Debian's solution.
475 (define (mesa-demos-source version)
476 (origin
477 (method url-fetch)
478 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/demos"
479 "/mesa-demos-" version ".tar.bz2"))
480 (sha256 (base32 "0zgzbz55a14hz83gbmm0n9gpjnf5zadzi2kjjvkn6khql2a9rs81"))))
481
482 (define-public mesa-utils
483 (package
484 (name "mesa-utils")
485 (version "8.4.0")
486 (source (mesa-demos-source version))
487 (build-system gnu-build-system)
488 (inputs
489 `(("mesa" ,mesa)
490 ("glut" ,freeglut)
491 ("glew" ,glew)))
492 (native-inputs
493 `(("pkg-config" ,pkg-config)))
494 (arguments
495 '(#:phases
496 (modify-phases %standard-phases
497 (replace
498 'install
499 (lambda* (#:key outputs #:allow-other-keys)
500 (let ((out (assoc-ref outputs "out")))
501 (mkdir-p (string-append out "/bin"))
502 (for-each
503 (lambda (file)
504 (copy-file file (string-append out "/bin/" (basename file))))
505 '("src/xdemos/glxdemo" "src/xdemos/glxgears"
506 "src/xdemos/glxinfo" "src/xdemos/glxheads"))
507 #t))))))
508 (home-page "https://mesa3d.org/")
509 (synopsis "Utility tools for Mesa")
510 (description
511 "The mesa-utils package contains several utility tools for Mesa: glxdemo,
512 glxgears, glxheads, and glxinfo.")
513 ;; glxdemo is public domain; others expat.
514 (license (list license:expat license:public-domain))))
515
516 (define-public glew
517 (package
518 (name "glew")
519 (version "2.1.0")
520 (source (origin
521 (method url-fetch)
522 (uri (string-append "mirror://sourceforge/glew/glew/" version
523 "/glew-" version ".tgz"))
524 (sha256
525 (base32
526 "159wk5dc0ykjbxvag5i1m2mhp23zkk6ra04l26y3jc3nwvkr3ph4"))
527 (modules '((guix build utils)))
528 (snippet
529 '(begin
530 (substitute* "config/Makefile.linux"
531 (("= cc") "= gcc")
532 (("/lib64") "/lib"))
533 #t))))
534 (build-system gnu-build-system)
535 (arguments
536 '(#:phases (modify-phases %standard-phases (delete 'configure))
537 #:make-flags (list (string-append "GLEW_PREFIX="
538 (assoc-ref %outputs "out"))
539 (string-append "GLEW_DEST="
540 (assoc-ref %outputs "out")))
541 #:tests? #f)) ;no 'check' target
542 (inputs
543 `(("libxi" ,libxi)
544 ("libxmu" ,libxmu)
545 ("libx11" ,libx11)
546 ("mesa" ,mesa)))
547
548 ;; <GL/glew.h> includes <GL/glu.h>.
549 (propagated-inputs `(("glu" ,glu)))
550
551 (home-page "http://glew.sourceforge.net/")
552 (synopsis "OpenGL extension loading library for C and C++")
553 (description
554 "The OpenGL Extension Wrangler Library (GLEW) is a C/C++ extension
555 loading library. GLEW provides efficient run-time mechanisms for determining
556 which OpenGL extensions are supported on the target platform. OpenGL core and
557 extension functionality is exposed in a single header file.")
558 (license license:bsd-3)))
559
560 (define-public guile-opengl
561 (package
562 (name "guile-opengl")
563 (version "0.1.0")
564 (source (origin
565 (method url-fetch)
566 (uri (string-append "mirror://gnu/guile-opengl/guile-opengl-"
567 version ".tar.gz"))
568 (sha256
569 (base32
570 "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim"))))
571 (build-system gnu-build-system)
572 (native-inputs `(("pkg-config" ,pkg-config)))
573 (inputs `(("guile" ,guile-2.2)
574 ("mesa" ,mesa)
575 ("glu" ,glu)
576 ("freeglut" ,freeglut)))
577 (arguments
578 '(#:phases (modify-phases %standard-phases
579 (add-after 'configure 'patch-makefile
580 (lambda _
581 ;; Install compiled Guile files in the expected place.
582 (substitute* '("Makefile")
583 (("^godir = .*$")
584 "godir = $(moddir)\n"))))
585 (add-before 'build 'patch-dynamic-link
586 (lambda* (#:key inputs outputs #:allow-other-keys)
587 (define (dynamic-link-substitute file lib input)
588 (substitute* file
589 (("dynamic-link \"lib([a-zA-Z]+)\"" _ lib)
590 (string-append "dynamic-link \""
591 (assoc-ref inputs input)
592 "/lib/lib" lib "\""))))
593 ;; Replace dynamic-link calls for libGL, libGLU, and
594 ;; libglut with absolute paths to the store.
595 (dynamic-link-substitute "glx/runtime.scm" "GL" "mesa")
596 (dynamic-link-substitute "glu/runtime.scm" "GLU" "glu")
597 (dynamic-link-substitute "glut/runtime.scm" "glut"
598 "freeglut"))))))
599 (home-page "https://gnu.org/s/guile-opengl")
600 (synopsis "Guile binding for the OpenGL graphics API")
601 (description
602 "Guile-OpenGL is a library for Guile that provides bindings to the
603 OpenGL graphics API.")
604 (license license:lgpl3+)))
605
606 (define-public libepoxy
607 (package
608 (name "libepoxy")
609 (version "1.5.4")
610 (source (origin
611 (method url-fetch)
612 (uri (string-append
613 "https://github.com/anholt/libepoxy/releases/download/"
614 version "/libepoxy-" version ".tar.xz"))
615 (sha256
616 (base32
617 "1ll9fach4v30dsyd47s5ial4gaiwihzr2afb77vxxzzy3mlcrlhb"))))
618 (arguments
619 `(#:phases
620 (modify-phases %standard-phases
621 (delete 'bootstrap)
622 (add-before
623 'configure 'patch-paths
624 (lambda* (#:key inputs #:allow-other-keys)
625 (let ((python (assoc-ref inputs "python"))
626 (mesa (assoc-ref inputs "mesa")))
627 (substitute* "src/gen_dispatch.py"
628 (("/usr/bin/env python") python))
629 (substitute* (find-files "." "\\.[ch]$")
630 (("libGL.so.1") (string-append mesa "/lib/libGL.so.1"))
631 (("libEGL.so.1") (string-append mesa "/lib/libEGL.so.1")))
632 #t))))))
633 (build-system meson-build-system)
634 (native-inputs
635 `(("pkg-config" ,pkg-config)
636 ("python" ,python)))
637 (inputs
638 `(("mesa" ,mesa)))
639 (home-page "https://github.com/anholt/libepoxy/")
640 (synopsis "A library for handling OpenGL function pointer management")
641 (description
642 "A library for handling OpenGL function pointer management.")
643 (license license:x11)))
644
645 (define-public soil
646 (package
647 (name "soil")
648 (version "1.0.7")
649 (source (origin
650 (method url-fetch)
651 ;; No versioned archive available.
652 (uri "http://www.lonesock.net/files/soil.zip")
653 (sha256
654 (base32
655 "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52"))))
656 (build-system gnu-build-system)
657 (arguments
658 '(#:tests? #f ; no tests
659 #:phases (modify-phases %standard-phases
660 (delete 'configure)
661 (add-before 'build 'init-build
662 (lambda* (#:key outputs #:allow-other-keys)
663 (let ((out (assoc-ref outputs "out")))
664 (setenv "CFLAGS" "-fPIC") ; needed for shared library
665 ;; Use alternate Makefile
666 (copy-file "projects/makefile/alternate Makefile.txt"
667 "src/Makefile")
668 (chdir "src")
669 (substitute* '("Makefile")
670 (("INCLUDEDIR = /usr/include/SOIL")
671 (string-append "INCLUDEDIR = " out "/include/SOIL"))
672 (("LIBDIR = /usr/lib")
673 (string-append "LIBDIR = " out "/lib"))
674 ;; Remove these flags from 'install' commands.
675 (("-o root -g root") ""))))))))
676 (native-inputs
677 `(("unzip" ,unzip)))
678 (inputs
679 `(("mesa" ,mesa)))
680 (home-page "https://www.lonesock.net/soil.html")
681 (synopsis "OpenGL texture loading library")
682 (description
683 "SOIL is a tiny C library used primarily for uploading textures into
684 OpenGL.")
685 (license license:public-domain)))
686
687 (define-public glfw
688 (package
689 (name "glfw")
690 (version "3.2.1")
691 (source (origin
692 (method url-fetch)
693 (uri (string-append "https://github.com/glfw/glfw"
694 "/releases/download/" version
695 "/glfw-" version ".zip"))
696 (sha256
697 (base32
698 "09kk5yc1zhss9add8ryqrngrr16hdmc94rszgng135bhw09mxmdp"))))
699 (build-system cmake-build-system)
700 (arguments
701 '(#:tests? #f ; no test target
702 #:configure-flags '("-DBUILD_SHARED_LIBS=ON")))
703 (native-inputs
704 `(("doxygen" ,doxygen)
705 ("unzip" ,unzip)))
706 (propagated-inputs
707 `(("mesa" ,mesa) ;included in public headers
708
709 ;; These are in 'Requires.private' of 'glfw3.pc'.
710 ("libx11" ,libx11)
711 ("libxrandr" ,libxrandr)
712 ("libxinerama" ,libxinerama)
713 ("libxcursor" ,libxcursor)
714 ("libxxf86vm" ,libxxf86vm)))
715 (home-page "http://www.glfw.org")
716 (synopsis "OpenGL application development library")
717 (description
718 "GLFW is a library for OpenGL, OpenGL ES and Vulkan development for
719 desktop computers. It provides a simple API for creating windows, contexts
720 and surfaces, receiving input and events.")
721 (license license:zlib)))
722
723 (define-public nanovg-for-extempore
724 (package
725 (name "nanovg-for-extempore")
726 (version "0.7.1")
727 (source (origin
728 (method url-fetch)
729 (uri (string-append "https://github.com/extemporelang/nanovg/"
730 "archive/" version ".tar.gz"))
731 (file-name (string-append name "-" version ".tar.gz"))
732 (sha256
733 (base32
734 "0ivs1sagq19xiw8jxd9f8w2b39svi0n9hrbmdvckwvqg95r8701g"))))
735 (build-system cmake-build-system)
736 (arguments `(#:tests? #f)) ; no tests included
737 (inputs
738 `(("mesa" ,mesa)))
739 ;; Extempore refuses to build on architectures other than x86_64
740 (supported-systems '("x86_64-linux"))
741 (home-page "https://github.com/extemporelang/nanovg")
742 (synopsis "2D vector drawing library on top of OpenGL")
743 (description "NanoVG is small antialiased vector graphics rendering
744 library for OpenGL. It has lean API modeled after HTML5 canvas API. It is
745 aimed to be a practical and fun toolset for building scalable user interfaces
746 and visualizations.")
747 (license license:zlib)))
748
749 (define-public gl2ps
750 (package
751 (name "gl2ps")
752 (version "1.4.0")
753 (source
754 (origin
755 (method url-fetch)
756 (uri (string-append
757 "http://geuz.org/gl2ps/src/gl2ps-"
758 version ".tgz"))
759 (sha256
760 (base32
761 "1qpidkz8x3bxqf69hlhyz1m0jmfi9kq24fxsp7rq6wfqzinmxjq3"))))
762 (build-system cmake-build-system)
763 (inputs
764 `(("libpng" ,libpng)
765 ("mesa" ,mesa)
766 ("zlib" ,zlib)))
767 (arguments
768 `(#:tests? #f)) ;; no tests
769 (home-page "http://www.geuz.org/gl2ps/")
770 (synopsis "OpenGL to PostScript printing library")
771 (description "GL2PS is a C library providing high quality vector
772 output for any OpenGL application. GL2PS uses sorting algorithms
773 capable of handling intersecting and stretched polygons, as well as
774 non-manifold objects. GL2PS provides many features including advanced
775 smooth shading and text rendering, culling of invisible primitives and
776 mixed vector/bitmap output.")
777 ;; GL2PS is dual-licenced and can be used under the terms of either.
778 (license (list license:lgpl2.0+
779 (license:fsf-free "http://www.geuz.org/gl2ps/COPYING.GL2PS"
780 "GPL-incompatible copyleft license")))))
781
782 (define-public virtualgl
783 (package
784 (name "virtualgl")
785 (version "2.6.2")
786 (source
787 (origin
788 (method git-fetch)
789 (uri (git-reference
790 (url "https://github.com/VirtualGL/virtualgl.git")
791 (commit version)))
792 (file-name (git-file-name name version))
793 (sha256
794 (base32 "0yyc553xsb5n0rx7jp9p4wdbd7md07b3qrkf3ssyjavqqg908qg9"))))
795 (arguments
796 `(#:tests? #f ; no tests are available
797 #:configure-flags (list
798 (string-append "-DCMAKE_INSTALL_LIBDIR="
799 (assoc-ref %outputs "out") "/lib")
800 "-DVGL_USESSL=1"))) ; use OpenSSL
801 (build-system cmake-build-system)
802 (inputs `(("glu" ,glu)
803 ("libjpeg-turbo" ,libjpeg-turbo)
804 ("libxtst" ,libxtst)
805 ("mesa" ,mesa)
806 ("openssl" ,openssl)))
807 (native-inputs `(("pkg-config" ,pkg-config)))
808 (home-page "https://www.virtualgl.org")
809 (synopsis "Redirects 3D commands from an OpenGL application onto a 3D
810 graphics card")
811 (description "VirtualGL redirects the 3D rendering commands from OpenGL
812 applications to 3D accelerator hardware in a dedicated server and displays the
813 rendered output interactively to a thin client located elsewhere on the
814 network.")
815 (license license:wxwindows3.1+)))
816
817 (define-public mojoshader
818 (let ((changeset "5887634ea695"))
819 (package
820 (name "mojoshader")
821 (version (string-append "20190825" "-" changeset))
822 (source
823 (origin
824 (method hg-fetch)
825 (uri (hg-reference
826 (url "https://hg.icculus.org/icculus/mojoshader/")
827 (changeset changeset)))
828 (file-name (git-file-name name version))
829 (sha256
830 (base32 "0ibl4z1696jiifv9j5drir7jm0b5px0vwkwckbi7cfd46p7p6wcy"))))
831 (arguments
832 ;; Tests only for COMPILER_SUPPORT=ON.
833 `(#:tests? #f
834 #:configure-flags '("-DBUILD_SHARED=ON"
835 "-DFLIP_VIEWPORT=ON"
836 "-DDEPTH_CLIPPING=ON")
837 #:phases
838 (modify-phases %standard-phases
839 (replace 'install
840 (lambda* (#:key outputs #:allow-other-keys)
841 (let* ((out (assoc-ref outputs "out"))
842 (lib (string-append out "/lib"))
843 (header (string-append out "/include")))
844 (install-file "libmojoshader.so" lib)
845 (for-each (lambda (f)
846 (install-file f header))
847 (find-files "../source" "mojoshader.*\\.h$"))
848 (let ((profiles-header (string-append header "/profiles")))
849 (mkdir-p profiles-header)
850 (rename-file (string-append header "/mojoshader_profile.h")
851 (string-append profiles-header "/mojoshader_profile.h"))))
852 #t)))))
853 (build-system cmake-build-system)
854 (home-page "https://www.icculus.org/mojoshader/")
855 (synopsis "Work with Direct3D shaders on alternate 3D APIs")
856 (description "MojoShader is a library to work with Direct3D shaders on
857 alternate 3D APIs and non-Windows platforms. The primary motivation is moving
858 shaders to OpenGL languages on the fly. The developer deals with \"profiles\"
859 that represent various target languages, such as GLSL or ARB_*_program.
860
861 This allows a developer to manage one set of shaders, presumably written in
862 Direct3D HLSL, and use them across multiple rendering backends. This also
863 means that the developer only has to worry about one (offline) compiler to
864 manage program complexity, while MojoShader itself deals with the reduced
865 complexity of the bytecode at runtime.
866
867 MojoShader provides both a simple API to convert bytecode to various profiles,
868 and (optionally) basic glue to rendering APIs to abstract the management of
869 the shaders at runtime.")
870 (license license:zlib))))
871
872 (define-public mojoshader-with-viewport-flip
873 ;; Changeset c586d4590241 replaced glProgramViewportFlip with
874 ;; glProgramViewportInfo.
875 ;; https://hg.icculus.org/icculus/mojoshader/rev/c586d4590241
876 (let ((changeset "2e37299b13d8"))
877 (package
878 (inherit mojoshader)
879 (name "mojoshader-with-viewport-flip")
880 (version (string-append "20190725" "-" changeset))
881 (source
882 (origin
883 (method hg-fetch)
884 (uri (hg-reference
885 (url "https://hg.icculus.org/icculus/mojoshader/")
886 (changeset changeset)))
887 (file-name (git-file-name name version))
888 (sha256
889 (base32 "0ffws7cqbskxwc3hjsnnzq4r2bbf008kdr3b11pa3kr7dsi50y6i"))))
890 (synopsis "Work with Direct3D shaders on alternate 3D APIs (with viewport flip)")
891 (description "This is the last version of the mojoshader library with
892 the glProgramViewportFlip before it was replaced with glProgramViewportInfo.")
893 (license license:zlib))))
894
895 (define-public mojoshader-cs
896 (let ((commit "10d0dba21ff1cfe332eb7de328a2adce01286bd7"))
897 (package
898 (name "mojoshader-cs")
899 (version (git-version "20191205" "1" commit))
900 (source (origin
901 (method git-fetch)
902 (uri (git-reference
903 (url "https://github.com/FNA-XNA/MojoShader")
904 (commit commit)))
905 (file-name (git-file-name name version))
906 (sha256
907 (base32
908 "11mdhf3fmb9rsn2iv753gmb596j4dh5j2iipgw078vg0lj23rml7"))))
909 (build-system gnu-build-system)
910 (arguments
911 '(#:tests? #f ; No tests.
912 #:phases
913 (modify-phases %standard-phases
914 (delete 'configure)
915 (replace 'build
916 (lambda _
917 (invoke "make" "-C" "csharp")))
918 (replace 'install
919 (lambda* (#:key outputs #:allow-other-keys)
920 (let ((out (assoc-ref outputs "out")))
921 (install-file "csharp/bin/MojoShader-CS.dll" (string-append out "/lib"))
922 #t))))))
923 (native-inputs
924 `(("mono" ,mono)))
925 (home-page "https://github.com/FNA-XNA/MojoShader")
926 (synopsis "C# wrapper for MojoShader")
927 (description
928 "Mojoshader-CS provides C# bindings for the Mojoshader library.
929 The C# wrapper was written to be used for FNA's platform support. However, this
930 is written in a way that can be used for any general C# application.")
931 (license license:zlib))))