gnu: sbcl-cl-cffi-gtk: Update to 20200417.
[jackhill/guix/guix.git] / gnu / packages / gl.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2013 Joshua Grant <tadni@riseup.net>
4 ;;; Copyright © 2014, 2016 David Thompson <davet@gnu.org>
5 ;;; Copyright © 2014, 2015, 2016, 2017 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2016 ng0 <ng0@n0.is>
7 ;;; Copyright © 2016, 2017, 2018, 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 "19.3.4")
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 "1r4giqq7q7zqbn23lbw7v5vswagxx8qj6ij2w8bsb697mvk6g90x"))
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-9)))
274 (_
275 `()))
276 ("makedepend" ,makedepend)
277 ("wayland" ,wayland)
278 ("wayland-protocols" ,wayland-protocols)))
279 (native-inputs
280 `(("bison" ,bison)
281 ("flex" ,flex)
282 ("gettext" ,gettext-minimal)
283 ,@(match (%current-system)
284 ((or "x86_64-linux" "i686-linux")
285 `(("glslang" ,glslang)))
286 (_
287 `()))
288 ("pkg-config" ,pkg-config)
289 ("python" ,python-wrapper)
290 ("python-mako" ,python-mako)
291 ("which" ,(@ (gnu packages base) which))))
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,nouveau,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 (add-after
351 'unpack 'patch-create_test_cases
352 (lambda _
353 (substitute* "src/intel/genxml/gen_pack_header.py"
354 (("/usr/bin/env python2") (which "python")))
355 #t))
356 ,@(if (string-prefix? "i686" (or (%current-target-system)
357 (%current-system)))
358 ;; Disable new test from Mesa 19 that fails on i686. Upstream
359 ;; report: <https://bugs.freedesktop.org/show_bug.cgi?id=110612>.
360 `((add-after 'unpack 'disable-failing-test
361 (lambda _
362 (substitute* "src/gallium/tests/unit/meson.build"
363 (("'u_format_test',") ""))
364 #t)))
365 '())
366 (add-before
367 'configure 'fix-dlopen-libnames
368 (lambda* (#:key inputs outputs #:allow-other-keys)
369 (let ((out (assoc-ref outputs "out")))
370 ;; Remain agnostic to .so.X.Y.Z versions while doing
371 ;; the substitutions so we're future-safe.
372 (substitute* "src/glx/dri_common.c"
373 (("dlopen\\(\"libGL\\.so")
374 (string-append "dlopen(\"" out "/lib/libGL.so")))
375 (substitute* "src/egl/drivers/dri2/egl_dri2.c"
376 (("\"libglapi\\.so")
377 (string-append "\"" out "/lib/libglapi.so")))
378 (substitute* "src/gbm/main/backend.c"
379 ;; No need to patch the gbm_gallium_drm.so reference;
380 ;; it's never installed since Mesa removed its
381 ;; egl_gallium support.
382 (("\"gbm_dri\\.so")
383 (string-append "\"" out "/lib/dri/gbm_dri.so")))
384 #t)))
385 (add-after 'install 'symlinks-instead-of-hard-links
386 (lambda* (#:key outputs #:allow-other-keys)
387 ;; All the drivers and gallium targets create hard links upon
388 ;; installation (search for "hardlink each megadriver instance"
389 ;; in the makefiles). This is no good for us since we'd produce
390 ;; nars that contain several copies of these files. Thus, turn
391 ;; them into symlinks, which saves ~124 MiB.
392 (let* ((out (assoc-ref outputs "out"))
393 (lib (string-append out "/lib"))
394 (files (find-files lib
395 (lambda (file stat)
396 (and (string-contains file ".so")
397 (eq? 'regular
398 (stat:type stat))))))
399 (inodes (map (compose stat:ino stat) files)))
400 (for-each (lambda (inode)
401 (match (filter-map (match-lambda
402 ((file ino)
403 (and (= ino inode) file)))
404 (zip files inodes))
405 ((_)
406 #f)
407 ((reference others ..1)
408 (format #t "creating ~a symlinks to '~a'~%"
409 (length others) reference)
410 (for-each delete-file others)
411 (for-each (lambda (file)
412 (if (string=? (dirname file)
413 (dirname reference))
414 (symlink (basename reference)
415 file)
416 (symlink reference file)))
417 others))))
418 (delete-duplicates inodes))
419 #t))))))
420 (home-page "https://mesa3d.org/")
421 (synopsis "OpenGL and Vulkan implementations")
422 (description "Mesa is a free implementation of the OpenGL and Vulkan
423 specifications - systems for rendering interactive 3D graphics. A variety of
424 device drivers allows Mesa to be used in many different environments ranging
425 from software emulation to complete hardware acceleration for modern GPUs.")
426 (license license:x11)))
427
428 (define-public mesa-opencl
429 (package
430 (inherit mesa)
431 (name "mesa-opencl")
432 (arguments
433 (substitute-keyword-arguments (package-arguments mesa)
434 ((#:configure-flags flags)
435 `(cons "-Dgallium-opencl=standalone" ,flags))))
436 (inputs
437 `(("libclc" ,libclc)
438 ,@(package-inputs mesa)))
439 (native-inputs
440 `(("clang" ,clang-9)
441 ,@(package-native-inputs mesa)))))
442
443 (define-public mesa-opencl-icd
444 (package
445 (inherit mesa-opencl)
446 (name "mesa-opencl-icd")
447 (arguments
448 (substitute-keyword-arguments (package-arguments mesa)
449 ((#:configure-flags flags)
450 `(cons "-Dgallium-opencl=icd"
451 ,(delete "-Dgallium-opencl=standalone" flags)))))))
452
453 (define-public mesa-headers
454 (package
455 (inherit mesa)
456 (name "mesa-headers")
457 (propagated-inputs '())
458 (inputs '())
459 (native-inputs '())
460 (arguments
461 '(#:phases
462 (modify-phases %standard-phases
463 (delete 'configure)
464 (delete 'build)
465 (delete 'check)
466 (replace 'install
467 (lambda* (#:key outputs #:allow-other-keys)
468 (copy-recursively "include" (string-append
469 (assoc-ref outputs "out")
470 "/include"))
471 #t)))))))
472
473 ;;; The mesa-demos distribution contains non-free files, many files with no
474 ;;; clear license information, and many demos that aren't useful for most
475 ;;; people, so we just use this for the mesa-utils package below, and possibly
476 ;;; other packages in the future. This is modeled after Debian's solution.
477 (define (mesa-demos-source version)
478 (origin
479 (method url-fetch)
480 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/demos"
481 "/mesa-demos-" version ".tar.bz2"))
482 (sha256 (base32 "0zgzbz55a14hz83gbmm0n9gpjnf5zadzi2kjjvkn6khql2a9rs81"))))
483
484 (define-public mesa-utils
485 (package
486 (name "mesa-utils")
487 (version "8.4.0")
488 (source (mesa-demos-source version))
489 (build-system gnu-build-system)
490 (inputs
491 `(("mesa" ,mesa)
492 ("glut" ,freeglut)
493 ("glew" ,glew)))
494 (native-inputs
495 `(("pkg-config" ,pkg-config)))
496 (arguments
497 '(#:phases
498 (modify-phases %standard-phases
499 (replace
500 'install
501 (lambda* (#:key outputs #:allow-other-keys)
502 (let ((out (assoc-ref outputs "out")))
503 (mkdir-p (string-append out "/bin"))
504 (for-each
505 (lambda (file)
506 (copy-file file (string-append out "/bin/" (basename file))))
507 '("src/xdemos/glxdemo" "src/xdemos/glxgears"
508 "src/xdemos/glxinfo" "src/xdemos/glxheads"))
509 #t))))))
510 (home-page "https://mesa3d.org/")
511 (synopsis "Utility tools for Mesa")
512 (description
513 "The mesa-utils package contains several utility tools for Mesa: glxdemo,
514 glxgears, glxheads, and glxinfo.")
515 ;; glxdemo is public domain; others expat.
516 (license (list license:expat license:public-domain))))
517
518 (define-public glew
519 (package
520 (name "glew")
521 (version "2.1.0")
522 (source (origin
523 (method url-fetch)
524 (uri (string-append "mirror://sourceforge/glew/glew/" version
525 "/glew-" version ".tgz"))
526 (sha256
527 (base32
528 "159wk5dc0ykjbxvag5i1m2mhp23zkk6ra04l26y3jc3nwvkr3ph4"))
529 (modules '((guix build utils)))
530 (snippet
531 '(begin
532 (substitute* "config/Makefile.linux"
533 (("= cc") "= gcc")
534 (("/lib64") "/lib"))
535 #t))))
536 (build-system gnu-build-system)
537 (arguments
538 '(#:phases (modify-phases %standard-phases (delete 'configure))
539 #:make-flags (list (string-append "GLEW_PREFIX="
540 (assoc-ref %outputs "out"))
541 (string-append "GLEW_DEST="
542 (assoc-ref %outputs "out")))
543 #:tests? #f)) ;no 'check' target
544 (inputs
545 `(("libxi" ,libxi)
546 ("libxmu" ,libxmu)
547 ("libx11" ,libx11)
548 ("mesa" ,mesa)))
549
550 ;; <GL/glew.h> includes <GL/glu.h>.
551 (propagated-inputs `(("glu" ,glu)))
552
553 (home-page "http://glew.sourceforge.net/")
554 (synopsis "OpenGL extension loading library for C and C++")
555 (description
556 "The OpenGL Extension Wrangler Library (GLEW) is a C/C++ extension
557 loading library. GLEW provides efficient run-time mechanisms for determining
558 which OpenGL extensions are supported on the target platform. OpenGL core and
559 extension functionality is exposed in a single header file.")
560 (license license:bsd-3)))
561
562 (define-public guile-opengl
563 (package
564 (name "guile-opengl")
565 (version "0.1.0")
566 (source (origin
567 (method url-fetch)
568 (uri (string-append "mirror://gnu/guile-opengl/guile-opengl-"
569 version ".tar.gz"))
570 (sha256
571 (base32
572 "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim"))))
573 (build-system gnu-build-system)
574 (native-inputs `(("pkg-config" ,pkg-config)))
575 (inputs `(("guile" ,guile-2.2)
576 ("mesa" ,mesa)
577 ("glu" ,glu)
578 ("freeglut" ,freeglut)))
579 (arguments
580 '(#:phases (modify-phases %standard-phases
581 (add-after 'configure 'patch-makefile
582 (lambda _
583 ;; Install compiled Guile files in the expected place.
584 (substitute* '("Makefile")
585 (("^godir = .*$")
586 "godir = $(moddir)\n"))))
587 (add-before 'build 'patch-dynamic-link
588 (lambda* (#:key inputs outputs #:allow-other-keys)
589 (define (dynamic-link-substitute file lib input)
590 (substitute* file
591 (("dynamic-link \"lib([a-zA-Z]+)\"" _ lib)
592 (string-append "dynamic-link \""
593 (assoc-ref inputs input)
594 "/lib/lib" lib "\""))))
595 ;; Replace dynamic-link calls for libGL, libGLU, and
596 ;; libglut with absolute paths to the store.
597 (dynamic-link-substitute "glx/runtime.scm" "GL" "mesa")
598 (dynamic-link-substitute "glu/runtime.scm" "GLU" "glu")
599 (dynamic-link-substitute "glut/runtime.scm" "glut"
600 "freeglut"))))))
601 (home-page "https://gnu.org/s/guile-opengl")
602 (synopsis "Guile binding for the OpenGL graphics API")
603 (description
604 "Guile-OpenGL is a library for Guile that provides bindings to the
605 OpenGL graphics API.")
606 (license license:lgpl3+)))
607
608 (define-public guile3.0-opengl
609 (package
610 (inherit guile-opengl)
611 (name "guile3.0-opengl")
612 (arguments
613 (substitute-keyword-arguments (package-arguments guile-opengl)
614 ((#:phases phases)
615 `(modify-phases ,phases
616 (add-after 'unpack 'build-with-guile-3.0
617 (lambda _
618 (substitute* "configure"
619 (("_guile_versions_to_search=\"")
620 "_guile_versions_to_search=\"3.0 "))
621 #t))))))
622 (inputs
623 `(("guile" ,guile-3.0)
624 ("mesa" ,mesa)
625 ("glu" ,glu)
626 ("freeglut" ,freeglut)))))
627
628 (define-public libepoxy
629 (package
630 (name "libepoxy")
631 (version "1.5.4")
632 (source (origin
633 (method url-fetch)
634 (uri (string-append
635 "https://github.com/anholt/libepoxy/releases/download/"
636 version "/libepoxy-" version ".tar.xz"))
637 (sha256
638 (base32
639 "1ll9fach4v30dsyd47s5ial4gaiwihzr2afb77vxxzzy3mlcrlhb"))))
640 (arguments
641 `(#:phases
642 (modify-phases %standard-phases
643 (delete 'bootstrap)
644 (add-before
645 'configure 'patch-paths
646 (lambda* (#:key inputs #:allow-other-keys)
647 (let ((python (assoc-ref inputs "python"))
648 (mesa (assoc-ref inputs "mesa")))
649 (substitute* "src/gen_dispatch.py"
650 (("/usr/bin/env python") python))
651 (substitute* (find-files "." "\\.[ch]$")
652 (("libGL.so.1") (string-append mesa "/lib/libGL.so.1"))
653 (("libEGL.so.1") (string-append mesa "/lib/libEGL.so.1")))
654 #t))))))
655 (build-system meson-build-system)
656 (native-inputs
657 `(("pkg-config" ,pkg-config)
658 ("python" ,python)))
659 (inputs
660 `(("mesa" ,mesa)))
661 (home-page "https://github.com/anholt/libepoxy/")
662 (synopsis "A library for handling OpenGL function pointer management")
663 (description
664 "A library for handling OpenGL function pointer management.")
665 (license license:x11)))
666
667 (define-public soil
668 (package
669 (name "soil")
670 (version "1.0.7")
671 (source (origin
672 (method url-fetch)
673 ;; No versioned archive available.
674 (uri "http://www.lonesock.net/files/soil.zip")
675 (sha256
676 (base32
677 "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52"))))
678 (build-system gnu-build-system)
679 (arguments
680 '(#:tests? #f ; no tests
681 #:phases (modify-phases %standard-phases
682 (delete 'configure)
683 (add-before 'build 'init-build
684 (lambda* (#:key outputs #:allow-other-keys)
685 (let ((out (assoc-ref outputs "out")))
686 (setenv "CFLAGS" "-fPIC") ; needed for shared library
687 ;; Use alternate Makefile
688 (copy-file "projects/makefile/alternate Makefile.txt"
689 "src/Makefile")
690 (chdir "src")
691 (substitute* '("Makefile")
692 (("INCLUDEDIR = /usr/include/SOIL")
693 (string-append "INCLUDEDIR = " out "/include/SOIL"))
694 (("LIBDIR = /usr/lib")
695 (string-append "LIBDIR = " out "/lib"))
696 ;; Remove these flags from 'install' commands.
697 (("-o root -g root") ""))))))))
698 (native-inputs
699 `(("unzip" ,unzip)))
700 (inputs
701 `(("mesa" ,mesa)))
702 (home-page "https://www.lonesock.net/soil.html")
703 (synopsis "OpenGL texture loading library")
704 (description
705 "SOIL is a tiny C library used primarily for uploading textures into
706 OpenGL.")
707 (license license:public-domain)))
708
709 (define-public glfw
710 (package
711 (name "glfw")
712 (version "3.2.1")
713 (source (origin
714 (method url-fetch)
715 (uri (string-append "https://github.com/glfw/glfw"
716 "/releases/download/" version
717 "/glfw-" version ".zip"))
718 (sha256
719 (base32
720 "09kk5yc1zhss9add8ryqrngrr16hdmc94rszgng135bhw09mxmdp"))))
721 (build-system cmake-build-system)
722 (arguments
723 '(#:tests? #f ; no test target
724 #:configure-flags '("-DBUILD_SHARED_LIBS=ON")))
725 (native-inputs
726 `(("doxygen" ,doxygen)
727 ("unzip" ,unzip)))
728 (propagated-inputs
729 `(("mesa" ,mesa) ;included in public headers
730
731 ;; These are in 'Requires.private' of 'glfw3.pc'.
732 ("libx11" ,libx11)
733 ("libxrandr" ,libxrandr)
734 ("libxinerama" ,libxinerama)
735 ("libxcursor" ,libxcursor)
736 ("libxxf86vm" ,libxxf86vm)))
737 (home-page "https://www.glfw.org")
738 (synopsis "OpenGL application development library")
739 (description
740 "GLFW is a library for OpenGL, OpenGL ES and Vulkan development for
741 desktop computers. It provides a simple API for creating windows, contexts
742 and surfaces, receiving input and events.")
743 (license license:zlib)))
744
745 (define-public nanovg-for-extempore
746 (let ((version "0.7.1")
747 (revision "0")
748 (commit "3c60175fcc2e5fe305b04355cdce35d499c80310"))
749 (package
750 (name "nanovg-for-extempore")
751 (version (git-version version revision commit))
752 (source (origin
753 (method git-fetch)
754 (uri (git-reference
755 (url "https://github.com/extemporelang/nanovg.git")
756 (commit commit)))
757 (file-name (git-file-name name version))
758 (sha256
759 (base32
760 "0ddn3d3mxqn8hj9967v3pss7lz1wn08pcdnqzc118g7yjkq7hxzy"))))
761 (build-system cmake-build-system)
762 (arguments `(#:tests? #f)) ; no tests included
763 (inputs
764 `(("mesa" ,mesa)))
765 ;; Extempore refuses to build on architectures other than x86_64
766 (supported-systems '("x86_64-linux"))
767 (home-page "https://github.com/extemporelang/nanovg")
768 (synopsis "2D vector drawing library on top of OpenGL")
769 (description "NanoVG is small antialiased vector graphics rendering
770 library for OpenGL. It has lean API modeled after HTML5 canvas API. It is
771 aimed to be a practical and fun toolset for building scalable user interfaces
772 and visualizations.")
773 (license license:zlib))))
774
775 (define-public gl2ps
776 (package
777 (name "gl2ps")
778 (version "1.4.0")
779 (source
780 (origin
781 (method url-fetch)
782 (uri (string-append
783 "http://geuz.org/gl2ps/src/gl2ps-"
784 version ".tgz"))
785 (sha256
786 (base32
787 "1qpidkz8x3bxqf69hlhyz1m0jmfi9kq24fxsp7rq6wfqzinmxjq3"))))
788 (build-system cmake-build-system)
789 (inputs
790 `(("libpng" ,libpng)
791 ("mesa" ,mesa)
792 ("zlib" ,zlib)))
793 (arguments
794 `(#:tests? #f)) ;; no tests
795 (home-page "http://www.geuz.org/gl2ps/")
796 (synopsis "OpenGL to PostScript printing library")
797 (description "GL2PS is a C library providing high quality vector
798 output for any OpenGL application. GL2PS uses sorting algorithms
799 capable of handling intersecting and stretched polygons, as well as
800 non-manifold objects. GL2PS provides many features including advanced
801 smooth shading and text rendering, culling of invisible primitives and
802 mixed vector/bitmap output.")
803 ;; GL2PS is dual-licenced and can be used under the terms of either.
804 (license (list license:lgpl2.0+
805 (license:fsf-free "http://www.geuz.org/gl2ps/COPYING.GL2PS"
806 "GPL-incompatible copyleft license")))))
807
808 (define-public virtualgl
809 (package
810 (name "virtualgl")
811 (version "2.6.2")
812 (source
813 (origin
814 (method git-fetch)
815 (uri (git-reference
816 (url "https://github.com/VirtualGL/virtualgl.git")
817 (commit version)))
818 (file-name (git-file-name name version))
819 (sha256
820 (base32 "0yyc553xsb5n0rx7jp9p4wdbd7md07b3qrkf3ssyjavqqg908qg9"))))
821 (arguments
822 `(#:tests? #f ; no tests are available
823 #:configure-flags (list
824 (string-append "-DCMAKE_INSTALL_LIBDIR="
825 (assoc-ref %outputs "out") "/lib")
826 "-DVGL_USESSL=1"))) ; use OpenSSL
827 (build-system cmake-build-system)
828 (inputs `(("glu" ,glu)
829 ("libjpeg-turbo" ,libjpeg-turbo)
830 ("libxtst" ,libxtst)
831 ("mesa" ,mesa)
832 ("openssl" ,openssl)))
833 (native-inputs `(("pkg-config" ,pkg-config)))
834 (home-page "https://www.virtualgl.org")
835 (synopsis "Redirects 3D commands from an OpenGL application onto a 3D
836 graphics card")
837 (description "VirtualGL redirects the 3D rendering commands from OpenGL
838 applications to 3D accelerator hardware in a dedicated server and displays the
839 rendered output interactively to a thin client located elsewhere on the
840 network.")
841 (license license:wxwindows3.1+)))
842
843 (define-public mojoshader
844 (let ((changeset "5887634ea695"))
845 (package
846 (name "mojoshader")
847 (version (string-append "20190825" "-" changeset))
848 (source
849 (origin
850 (method hg-fetch)
851 (uri (hg-reference
852 (url "https://hg.icculus.org/icculus/mojoshader/")
853 (changeset changeset)))
854 (file-name (git-file-name name version))
855 (sha256
856 (base32 "0ibl4z1696jiifv9j5drir7jm0b5px0vwkwckbi7cfd46p7p6wcy"))))
857 (arguments
858 ;; Tests only for COMPILER_SUPPORT=ON.
859 `(#:tests? #f
860 #:configure-flags '("-DBUILD_SHARED=ON"
861 "-DFLIP_VIEWPORT=ON"
862 "-DDEPTH_CLIPPING=ON")
863 #:phases
864 (modify-phases %standard-phases
865 (replace 'install
866 (lambda* (#:key outputs #:allow-other-keys)
867 (let* ((out (assoc-ref outputs "out"))
868 (lib (string-append out "/lib"))
869 (header (string-append out "/include")))
870 (install-file "libmojoshader.so" lib)
871 (for-each (lambda (f)
872 (install-file f header))
873 (find-files "../source" "mojoshader.*\\.h$"))
874 (let ((profiles-header (string-append header "/profiles")))
875 (mkdir-p profiles-header)
876 (rename-file (string-append header "/mojoshader_profile.h")
877 (string-append profiles-header "/mojoshader_profile.h"))))
878 #t)))))
879 (build-system cmake-build-system)
880 (home-page "https://www.icculus.org/mojoshader/")
881 (synopsis "Work with Direct3D shaders on alternate 3D APIs")
882 (description "MojoShader is a library to work with Direct3D shaders on
883 alternate 3D APIs and non-Windows platforms. The primary motivation is moving
884 shaders to OpenGL languages on the fly. The developer deals with \"profiles\"
885 that represent various target languages, such as GLSL or ARB_*_program.
886
887 This allows a developer to manage one set of shaders, presumably written in
888 Direct3D HLSL, and use them across multiple rendering backends. This also
889 means that the developer only has to worry about one (offline) compiler to
890 manage program complexity, while MojoShader itself deals with the reduced
891 complexity of the bytecode at runtime.
892
893 MojoShader provides both a simple API to convert bytecode to various profiles,
894 and (optionally) basic glue to rendering APIs to abstract the management of
895 the shaders at runtime.")
896 (license license:zlib))))
897
898 (define-public mojoshader-with-viewport-flip
899 ;; Changeset c586d4590241 replaced glProgramViewportFlip with
900 ;; glProgramViewportInfo.
901 ;; https://hg.icculus.org/icculus/mojoshader/rev/c586d4590241
902 (let ((changeset "2e37299b13d8"))
903 (package
904 (inherit mojoshader)
905 (name "mojoshader-with-viewport-flip")
906 (version (string-append "20190725" "-" changeset))
907 (source
908 (origin
909 (method hg-fetch)
910 (uri (hg-reference
911 (url "https://hg.icculus.org/icculus/mojoshader/")
912 (changeset changeset)))
913 (file-name (git-file-name name version))
914 (sha256
915 (base32 "0ffws7cqbskxwc3hjsnnzq4r2bbf008kdr3b11pa3kr7dsi50y6i"))))
916 (synopsis "Work with Direct3D shaders on alternate 3D APIs (with viewport flip)")
917 (description "This is the last version of the mojoshader library with
918 the glProgramViewportFlip before it was replaced with glProgramViewportInfo.")
919 (license license:zlib))))
920
921 (define-public mojoshader-cs
922 (let ((commit "10d0dba21ff1cfe332eb7de328a2adce01286bd7"))
923 (package
924 (name "mojoshader-cs")
925 (version (git-version "20191205" "1" commit))
926 (source (origin
927 (method git-fetch)
928 (uri (git-reference
929 (url "https://github.com/FNA-XNA/MojoShader")
930 (commit commit)))
931 (file-name (git-file-name name version))
932 (sha256
933 (base32
934 "11mdhf3fmb9rsn2iv753gmb596j4dh5j2iipgw078vg0lj23rml7"))))
935 (build-system gnu-build-system)
936 (arguments
937 '(#:tests? #f ; No tests.
938 #:phases
939 (modify-phases %standard-phases
940 (delete 'configure)
941 (replace 'build
942 (lambda _
943 (invoke "make" "-C" "csharp")))
944 (replace 'install
945 (lambda* (#:key outputs #:allow-other-keys)
946 (let ((out (assoc-ref outputs "out")))
947 (install-file "csharp/bin/MojoShader-CS.dll" (string-append out "/lib"))
948 #t))))))
949 (native-inputs
950 `(("mono" ,mono)))
951 (home-page "https://github.com/FNA-XNA/MojoShader")
952 (synopsis "C# wrapper for MojoShader")
953 (description
954 "Mojoshader-CS provides C# bindings for the Mojoshader library.
955 The C# wrapper was written to be used for FNA's platform support. However, this
956 is written in a way that can be used for any general C# application.")
957 (license license:zlib))))