Merge branch '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, 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")
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")
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 aarch64 and armhf.
299 '("-Dgallium-drivers=etnaviv,freedreno,kmsro,lima,nouveau,panfrost,r300,r600,swrast,tegra,v3d,vc4,virgl"))
300 (_
301 '("-Dgallium-drivers=iris,nouveau,r300,r600,radeonsi,svga,swrast,virgl")))
302 ;; Enable various optional features. TODO: opencl requires libclc,
303 ;; omx requires libomxil-bellagio
304 "-Dplatforms=x11,drm,surfaceless,wayland"
305 "-Dglx=dri" ;Thread Local Storage, improves performance
306 ;; "-Dopencl=true"
307 ;; "-Domx=true"
308 "-Dosmesa=gallium"
309 "-Dgallium-xa=true"
310
311 ;; features required by wayland
312 "-Dgles2=true"
313 "-Dgbm=true"
314 "-Dshared-glapi=true"
315
316 ;; Enable Vulkan on i686-linux and x86-64-linux.
317 ,@(match (%current-system)
318 ((or "i686-linux" "x86_64-linux")
319 '("-Dvulkan-drivers=intel,amd"))
320 (_
321 '("-Dvulkan-drivers=auto")))
322
323 ;; Enable the Vulkan overlay layer on i686-linux and x86-64-linux.
324 ,@(match (%current-system)
325 ((or "x86_64-linux" "i686-linux")
326 '("-Dvulkan-overlay-layer=true"))
327 (_
328 '()))
329
330 ;; Also enable the tests.
331 "-Dbuild-tests=true"
332
333 ;; on non-intel systems, drop i915 and i965
334 ;; from the default dri drivers
335 ,@(match (%current-system)
336 ((or "x86_64-linux" "i686-linux")
337 '("-Ddri-drivers=i915,i965,nouveau,r200,r100"
338 "-Dllvm=true")) ; default is x86/x86_64 only
339 (_
340 '("-Ddri-drivers=nouveau,r200,r100"))))
341
342 ;; XXX: 'debugoptimized' causes LTO link failures on some drivers. The
343 ;; documentation recommends using 'release' for performance anyway.
344 #:build-type "release"
345
346 #:modules ((ice-9 match)
347 (srfi srfi-1)
348 (guix build utils)
349 (guix build meson-build-system))
350 #:phases
351 (modify-phases %standard-phases
352 ,@(if (string-prefix? "i686" (or (%current-target-system)
353 (%current-system)))
354 ;; Disable new test from Mesa 19 that fails on i686. Upstream
355 ;; report: <https://bugs.freedesktop.org/show_bug.cgi?id=110612>.
356 `((add-after 'unpack 'disable-failing-test
357 (lambda _
358 (substitute* "src/util/tests/format/meson.build"
359 (("'u_format_test',") ""))
360 #t)))
361 '())
362 (add-before 'configure 'fix-dlopen-libnames
363 (lambda* (#:key inputs outputs #:allow-other-keys)
364 (let ((out (assoc-ref outputs "out")))
365 ;; Remain agnostic to .so.X.Y.Z versions while doing
366 ;; the substitutions so we're future-safe.
367 (substitute* "src/glx/meson.build"
368 (("-DGL_LIB_NAME=\"lib@0@\\.so\\.@1@\"")
369 (string-append "-DGL_LIB_NAME=\"" out
370 "/lib/lib@0@.so.@1@\"")))
371 (substitute* "src/gbm/backends/dri/gbm_dri.c"
372 (("\"libglapi\\.so")
373 (string-append "\"" out "/lib/libglapi.so")))
374 (substitute* "src/gbm/main/backend.c"
375 ;; No need to patch the gbm_gallium_drm.so reference;
376 ;; it's never installed since Mesa removed its
377 ;; egl_gallium support.
378 (("\"gbm_dri\\.so")
379 (string-append "\"" out "/lib/dri/gbm_dri.so")))
380 #t)))
381 (add-after 'install 'split-outputs
382 (lambda* (#:key outputs #:allow-other-keys)
383 (let ((out (assoc-ref outputs "out"))
384 (bin (assoc-ref outputs "bin")))
385 ,@(match (%current-system)
386 ((or "i686-linux" "x86_64-linux")
387 ;; Install the Vulkan overlay control script to a separate
388 ;; output to prevent a reference on Python, saving ~70 MiB
389 ;; on the closure size.
390 '((copy-recursively (string-append out "/bin")
391 (string-append bin "/bin"))
392 (delete-file-recursively (string-append out "/bin"))))
393 (_
394 ;; XXX: On architectures without the Vulkan overlay layer
395 ;; just create an empty file because outputs can not be
396 ;; added conditionally.
397 '((mkdir-p (string-append bin "/bin"))
398 (call-with-output-file (string-append bin "/bin/.empty")
399 (const #t)))))
400 #t)))
401 (add-after 'install 'symlinks-instead-of-hard-links
402 (lambda* (#:key outputs #:allow-other-keys)
403 ;; All the drivers and gallium targets create hard links upon
404 ;; installation (search for "hardlink each megadriver instance"
405 ;; in the makefiles). This is no good for us since we'd produce
406 ;; nars that contain several copies of these files. Thus, turn
407 ;; them into symlinks, which saves ~124 MiB.
408 (let* ((out (assoc-ref outputs "out"))
409 (lib (string-append out "/lib"))
410 (files (find-files lib
411 (lambda (file stat)
412 (and (string-contains file ".so")
413 (eq? 'regular
414 (stat:type stat))))))
415 (inodes (map (compose stat:ino stat) files)))
416 (for-each (lambda (inode)
417 (match (filter-map (match-lambda
418 ((file ino)
419 (and (= ino inode) file)))
420 (zip files inodes))
421 ((_)
422 #f)
423 ((reference others ..1)
424 (format #t "creating ~a symlinks to '~a'~%"
425 (length others) reference)
426 (for-each delete-file others)
427 (for-each (lambda (file)
428 (if (string=? (dirname file)
429 (dirname reference))
430 (symlink (basename reference)
431 file)
432 (symlink reference file)))
433 others))))
434 (delete-duplicates inodes))
435 #t))))))
436 (home-page "https://mesa3d.org/")
437 (synopsis "OpenGL and Vulkan implementations")
438 (description "Mesa is a free implementation of the OpenGL and Vulkan
439 specifications - systems for rendering interactive 3D graphics. A variety of
440 device drivers allows Mesa to be used in many different environments ranging
441 from software emulation to complete hardware acceleration for modern GPUs.")
442 (license license:x11)))
443
444 (define-public mesa-opencl
445 (package/inherit mesa
446 (name "mesa-opencl")
447 (arguments
448 (substitute-keyword-arguments (package-arguments mesa)
449 ((#:configure-flags flags)
450 `(cons "-Dgallium-opencl=standalone" ,flags))))
451 (inputs
452 `(("libclc" ,libclc)
453 ,@(package-inputs mesa)))
454 (native-inputs
455 `(("clang" ,clang-11)
456 ,@(package-native-inputs mesa)))))
457
458 (define-public mesa-opencl-icd
459 (package/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/inherit mesa
469 (name "mesa-headers")
470 (propagated-inputs '())
471 (inputs '())
472 (native-inputs '())
473 (outputs '("out"))
474 (arguments
475 '(#:phases
476 (modify-phases %standard-phases
477 (delete 'configure)
478 (delete 'build)
479 (delete 'check)
480 (replace 'install
481 (lambda* (#:key outputs #:allow-other-keys)
482 (copy-recursively "include" (string-append
483 (assoc-ref outputs "out")
484 "/include"))
485 #t)))))))
486
487 ;;; The mesa-demos distribution contains non-free files, many files with no
488 ;;; clear license information, and many demos that aren't useful for most
489 ;;; people, so we just use this for the mesa-utils package below, and possibly
490 ;;; other packages in the future. This is modeled after Debian's solution.
491 (define (mesa-demos-source version)
492 (origin
493 (method url-fetch)
494 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/demos"
495 "/mesa-demos-" version ".tar.bz2"))
496 (sha256 (base32 "0zgzbz55a14hz83gbmm0n9gpjnf5zadzi2kjjvkn6khql2a9rs81"))))
497
498 (define-public mesa-utils
499 (package
500 (name "mesa-utils")
501 (version "8.4.0")
502 (source (mesa-demos-source version))
503 (build-system gnu-build-system)
504 (inputs
505 `(("mesa" ,mesa)
506 ("glut" ,freeglut)
507 ("glew" ,glew)))
508 (native-inputs
509 `(("pkg-config" ,pkg-config)))
510 (arguments
511 '(#:phases
512 (modify-phases %standard-phases
513 (replace
514 'install
515 (lambda* (#:key outputs #:allow-other-keys)
516 (let ((out (assoc-ref outputs "out")))
517 (mkdir-p (string-append out "/bin"))
518 (for-each
519 (lambda (file)
520 (copy-file file (string-append out "/bin/" (basename file))))
521 '("src/xdemos/glxdemo" "src/xdemos/glxgears"
522 "src/xdemos/glxinfo" "src/xdemos/glxheads"))
523 #t))))))
524 (home-page "https://mesa3d.org/")
525 (synopsis "Utility tools for Mesa")
526 (description
527 "The mesa-utils package contains several utility tools for Mesa: glxdemo,
528 glxgears, glxheads, and glxinfo.")
529 ;; glxdemo is public domain; others expat.
530 (license (list license:expat license:public-domain))))
531
532 (define-public glew
533 (package
534 (name "glew")
535 (version "2.1.0")
536 (source (origin
537 (method url-fetch)
538 (uri (string-append "mirror://sourceforge/glew/glew/" version
539 "/glew-" version ".tgz"))
540 (sha256
541 (base32
542 "159wk5dc0ykjbxvag5i1m2mhp23zkk6ra04l26y3jc3nwvkr3ph4"))
543 (modules '((guix build utils)))
544 (snippet
545 '(begin
546 (substitute* "config/Makefile.linux"
547 (("= cc") "= gcc")
548 (("/lib64") "/lib"))
549 #t))))
550 (build-system gnu-build-system)
551 (arguments
552 '(#:phases (modify-phases %standard-phases (delete 'configure))
553 #:make-flags (list (string-append "GLEW_PREFIX="
554 (assoc-ref %outputs "out"))
555 (string-append "GLEW_DEST="
556 (assoc-ref %outputs "out")))
557 #:tests? #f)) ;no 'check' target
558 (inputs
559 `(("libxi" ,libxi)
560 ("libxmu" ,libxmu)
561 ("libx11" ,libx11)
562 ("mesa" ,mesa)))
563
564 ;; <GL/glew.h> includes <GL/glu.h>.
565 (propagated-inputs `(("glu" ,glu)))
566
567 (home-page "http://glew.sourceforge.net/")
568 (synopsis "OpenGL extension loading library for C and C++")
569 (description
570 "The OpenGL Extension Wrangler Library (GLEW) is a C/C++ extension
571 loading library. GLEW provides efficient run-time mechanisms for determining
572 which OpenGL extensions are supported on the target platform. OpenGL core and
573 extension functionality is exposed in a single header file.")
574 (license license:bsd-3)))
575
576 (define-public guile-opengl
577 (package
578 (name "guile-opengl")
579 (version "0.1.0")
580 (source (origin
581 (method url-fetch)
582 (uri (string-append "mirror://gnu/guile-opengl/guile-opengl-"
583 version ".tar.gz"))
584 (sha256
585 (base32
586 "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim"))))
587 (build-system gnu-build-system)
588 (native-inputs `(("pkg-config" ,pkg-config)))
589 (inputs `(("guile" ,guile-2.2)
590 ("mesa" ,mesa)
591 ("glu" ,glu)
592 ("freeglut" ,freeglut)))
593 (arguments
594 '(#:phases (modify-phases %standard-phases
595 (add-after 'configure 'patch-makefile
596 (lambda _
597 ;; Install compiled Guile files in the expected place.
598 (substitute* '("Makefile")
599 (("^godir = .*$")
600 "godir = $(moddir)\n"))))
601 (add-before 'build 'patch-dynamic-link
602 (lambda* (#:key inputs outputs #:allow-other-keys)
603 (define (dynamic-link-substitute file lib input)
604 (substitute* file
605 (("dynamic-link \"lib([a-zA-Z]+)\"" _ lib)
606 (string-append "dynamic-link \""
607 (assoc-ref inputs input)
608 "/lib/lib" lib "\""))))
609 ;; Replace dynamic-link calls for libGL, libGLU, and
610 ;; libglut with absolute paths to the store.
611 (dynamic-link-substitute "glx/runtime.scm" "GL" "mesa")
612 (dynamic-link-substitute "glu/runtime.scm" "GLU" "glu")
613 (dynamic-link-substitute "glut/runtime.scm" "glut"
614 "freeglut"))))))
615 (home-page "https://gnu.org/s/guile-opengl")
616 (synopsis "Guile binding for the OpenGL graphics API")
617 (description
618 "Guile-OpenGL is a library for Guile that provides bindings to the
619 OpenGL graphics API.")
620 (license license:lgpl3+)))
621
622 (define-public guile3.0-opengl
623 (package
624 (inherit guile-opengl)
625 (name "guile3.0-opengl")
626 (arguments
627 (substitute-keyword-arguments (package-arguments guile-opengl)
628 ((#:phases phases)
629 `(modify-phases ,phases
630 (add-after 'unpack 'build-with-guile-3.0
631 (lambda _
632 (substitute* "configure"
633 (("_guile_versions_to_search=\"")
634 "_guile_versions_to_search=\"3.0 "))
635 #t))))))
636 (inputs
637 `(("guile" ,guile-3.0)
638 ("mesa" ,mesa)
639 ("glu" ,glu)
640 ("freeglut" ,freeglut)))))
641
642 (define-public libepoxy
643 (package
644 (name "libepoxy")
645 (version "1.5.4")
646 (source (origin
647 (method url-fetch)
648 (uri (string-append
649 "https://github.com/anholt/libepoxy/releases/download/"
650 version "/libepoxy-" version ".tar.xz"))
651 (sha256
652 (base32
653 "1ll9fach4v30dsyd47s5ial4gaiwihzr2afb77vxxzzy3mlcrlhb"))))
654 (arguments
655 `(#:phases
656 (modify-phases %standard-phases
657 (delete 'bootstrap)
658 (add-before
659 'configure 'patch-paths
660 (lambda* (#:key inputs #:allow-other-keys)
661 (let ((python (assoc-ref inputs "python"))
662 (mesa (assoc-ref inputs "mesa")))
663 (substitute* "src/gen_dispatch.py"
664 (("/usr/bin/env python") python))
665 (substitute* (find-files "." "\\.[ch]$")
666 (("libGL.so.1") (string-append mesa "/lib/libGL.so.1"))
667 (("libEGL.so.1") (string-append mesa "/lib/libEGL.so.1")))
668 #t))))))
669 (build-system meson-build-system)
670 (native-inputs
671 `(("pkg-config" ,pkg-config)
672 ("python" ,python)))
673 (inputs
674 `(("mesa" ,mesa)))
675 (home-page "https://github.com/anholt/libepoxy/")
676 (synopsis "A library for handling OpenGL function pointer management")
677 (description
678 "A library for handling OpenGL function pointer management.")
679 (license license:x11)))
680
681 (define-public libglvnd
682 (package
683 (name "libglvnd")
684 (version "1.3.2")
685 (home-page "https://gitlab.freedesktop.org/glvnd/libglvnd")
686 (source (origin
687 (method git-fetch)
688 (uri (git-reference
689 (url home-page)
690 (commit (string-append "v" version))))
691 (file-name (git-file-name name version))
692 (sha256
693 (base32
694 "10x7fgb114r4gikdg6flszl3kwzcb9y5qa7sj9936mk0zxhjaylz"))))
695 (build-system meson-build-system)
696 (arguments
697 '(#:configure-flags '("-Dx11=enabled")
698 #:phases (modify-phases %standard-phases
699 (add-after 'unpack 'disable-glx-tests
700 (lambda _
701 ;; This package is meant to be used alongside Mesa.
702 ;; To avoid a circular dependency, disable tests that
703 ;; require a running Xorg server.
704 (substitute* "tests/meson.build"
705 (("if with_glx")
706 "if false"))
707 #t)))))
708 (native-inputs
709 `(("pkg-config" ,pkg-config)))
710 (inputs
711 `(("libx11" ,libx11)
712 ("libxext" ,libxext)
713 ("xorgproto" ,xorgproto)))
714 (synopsis "Vendor-neutral OpenGL dispatch library")
715 (description
716 "libglvnd is a vendor-neutral dispatch layer for arbitrating OpenGL
717 API calls between multiple vendors. It allows multiple drivers from
718 different vendors to coexist on the same filesystem, and determines which
719 vendor to dispatch each API call to at runtime.
720
721 Both GLX and EGL are supported, in any combination with OpenGL and OpenGL ES.")
722 ;; libglvnd is available under a custom X11-style license, and incorporates
723 ;; code with various other licenses. See README.md for details.
724 (license (list (license:x11-style "file://README.md")
725 license:x11
726 license:expat))))
727
728 (define-public soil
729 (package
730 (name "soil")
731 (version "1.0.7")
732 (source (origin
733 (method url-fetch)
734 ;; No versioned archive available.
735 (uri "http://www.lonesock.net/files/soil.zip")
736 (sha256
737 (base32
738 "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52"))))
739 (build-system gnu-build-system)
740 (arguments
741 '(#:tests? #f ; no tests
742 #:phases (modify-phases %standard-phases
743 (delete 'configure)
744 (add-before 'build 'init-build
745 (lambda* (#:key outputs #:allow-other-keys)
746 (let ((out (assoc-ref outputs "out")))
747 (setenv "CFLAGS" "-fPIC") ; needed for shared library
748 ;; Use alternate Makefile
749 (copy-file "projects/makefile/alternate Makefile.txt"
750 "src/Makefile")
751 (chdir "src")
752 (substitute* '("Makefile")
753 (("INCLUDEDIR = /usr/include/SOIL")
754 (string-append "INCLUDEDIR = " out "/include/SOIL"))
755 (("LIBDIR = /usr/lib")
756 (string-append "LIBDIR = " out "/lib"))
757 ;; Remove these flags from 'install' commands.
758 (("-o root -g root") ""))))))))
759 (native-inputs
760 `(("unzip" ,unzip)))
761 (inputs
762 `(("mesa" ,mesa)))
763 (home-page "https://www.lonesock.net/soil.html")
764 (synopsis "OpenGL texture loading library")
765 (description
766 "SOIL is a tiny C library used primarily for uploading textures into
767 OpenGL.")
768 (license license:public-domain)))
769
770 (define-public glfw
771 (package
772 (name "glfw")
773 (version "3.3.2")
774 (source (origin
775 (method url-fetch)
776 (uri (string-append "https://github.com/glfw/glfw"
777 "/releases/download/" version
778 "/glfw-" version ".zip"))
779 (sha256
780 (base32
781 "1izgc4r0ypxwwklfzj98ab4xqsjpb1wbsfdbivvxpmr95x8km8q8"))))
782 (build-system cmake-build-system)
783 (arguments
784 '(#:tests? #f ; no test target
785 #:configure-flags '("-DBUILD_SHARED_LIBS=ON")))
786 (native-inputs
787 `(("doxygen" ,doxygen)
788 ("unzip" ,unzip)))
789 (propagated-inputs
790 `(("mesa" ,mesa) ;included in public headers
791
792 ;; These are in 'Requires.private' of 'glfw3.pc'.
793 ("libx11" ,libx11)
794 ("libxrandr" ,libxrandr)
795 ("libxi" ,libxi)
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")
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")
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))))
1019
1020 (define-public glmark2
1021 (package
1022 (name "glmark2")
1023 (version "2020.04")
1024 (source (origin
1025 (method git-fetch)
1026 (uri (git-reference
1027 (url "https://github.com/glmark2/glmark2")
1028 (commit version)))
1029 (file-name (git-file-name name version))
1030 (sha256
1031 (base32
1032 "0ywpzp0imi3f8iyp7d1739576zx2nsr3db5hp2as4yhflfyq1as2"))
1033 (modules '((guix build utils)))
1034 ;; Fix Python 3 incompatibility.
1035 (snippet
1036 '(begin
1037 (substitute* "wscript"
1038 (("(sorted\\()FLAVORS\\.keys\\(\\)(.*)" _ beginning end)
1039 (string-append beginning "list(FLAVORS)" end)))
1040 #t))))
1041 (build-system waf-build-system)
1042 (arguments
1043 '(#:tests? #f ; no check target
1044 #:configure-flags
1045 (list (string-append "--with-flavors="
1046 (string-join '("x11-gl" "x11-glesv2"
1047 "drm-gl" "drm-glesv2"
1048 "wayland-gl" "wayland-glesv2")
1049 ",")))
1050 #:phases
1051 (modify-phases %standard-phases
1052 (add-after 'unpack 'patch-paths
1053 (lambda* (#:key inputs #:allow-other-keys)
1054 (let ((mesa (assoc-ref inputs "mesa")))
1055 (substitute* (find-files "src" "gl-state-.*\\.cpp$")
1056 (("libGL.so") (string-append mesa "/lib/libGL.so"))
1057 (("libEGL.so") (string-append mesa "/lib/libEGL.so"))
1058 (("libGLESv2.so") (string-append mesa "/lib/libGLESv2.so")))
1059 #t))))))
1060 (native-inputs
1061 `(("pkg-config" ,pkg-config)))
1062 (inputs
1063 `(("eudev" ,eudev)
1064 ("libdrm" ,libdrm)
1065 ("libjpeg-turbo" ,libjpeg-turbo)
1066 ("libpng" ,libpng)
1067 ("libx11" ,libx11)
1068 ("libxcb" ,libxcb)
1069 ("mesa" ,mesa)
1070 ("wayland" ,wayland)
1071 ("wayland-protocols" ,wayland-protocols)))
1072 (home-page "https://github.com/glmark2/glmark2")
1073 (synopsis "OpenGL 2.0 and OpenGL ES 2.0 benchmark")
1074 (description
1075 "glmark2 is an OpenGL 2.0 and OpenGL ES 2.0 benchmark based on the
1076 original glmark benchmark by Ben Smith.")
1077 (license license:gpl3+)))