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