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