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