Merge branch 'staging' 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 mono)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages python)
48 #:use-module (gnu packages python-xyz)
49 #:use-module (gnu packages tls)
50 #:use-module (gnu packages video)
51 #:use-module (gnu packages vulkan)
52 #:use-module (gnu packages xdisorg)
53 #:use-module (gnu packages xml)
54 #:use-module (gnu packages xorg)
55 #:use-module (guix download)
56 #:use-module (guix git-download)
57 #:use-module (guix hg-download)
58 #:use-module (guix build-system gnu)
59 #:use-module (guix build-system cmake)
60 #:use-module (guix build-system meson)
61 #:use-module ((guix licenses) #:prefix license:)
62 #:use-module (guix packages)
63 #:use-module (guix utils)
64 #:use-module (ice-9 match)
65 #:use-module ((srfi srfi-1) #:hide (zip)))
66
67 (define-public glu
68 (package
69 (name "glu")
70 (version "9.0.1")
71 (source (origin
72 (method url-fetch)
73 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/glu/glu-"
74 version ".tar.gz"))
75 (sha256
76 (base32
77 "1xqhk9bn10nbvffw3r4p4rjslwz1l7gaycc0x2pqkr2irp7q9x7n"))))
78 (build-system gnu-build-system)
79 (propagated-inputs
80 `(("mesa" ,mesa))) ; according to glu.pc
81 (home-page "http://www.opengl.org/archives/resources/faq/technical/glu.htm")
82 (synopsis "Mesa OpenGL Utility library")
83 (description
84 "GLU, or OpenGL Utility Library provides some higher-level functionality
85 not provided by just OpenGL itself. Some of GLU's Features
86 include: Scaling of 2D images and creation of mipmap pyramids,
87 Transformation of object coordinates into device coordinates and
88 vice versa, Support for NURBS surfaces, Support for tessellation
89 of concave or bow tie polygonal primitives, Specialty transformation
90 matrices for creating perspective and orthographic projections,
91 positioning a camera, and selection/picking, Rendering of disk,
92 cylinder, and sphere primitives, Interpreting OpenGL error values
93 as ASCII text.")
94 (license (license:x11-style "http://directory.fsf.org/wiki/License:SGIFreeBv2"))))
95
96 (define-public freeglut
97 (package
98 (name "freeglut")
99 (version "3.2.1")
100 (source (origin
101 (method url-fetch)
102 (uri (string-append
103 "mirror://sourceforge/freeglut/freeglut/"
104 version "/freeglut-" version ".tar.gz"))
105 (sha256
106 (base32
107 "0s6sk49q8ijgbsrrryb7dzqx2fa744jhx1wck5cz5jia2010w06l"))))
108 (build-system cmake-build-system)
109 (arguments
110 '(#:tests? #f ;no test target
111 #:configure-flags '("-DFREEGLUT_BUILD_STATIC_LIBS=OFF")))
112 (inputs `(("libx11" ,libx11)
113 ("libxi" ,libxi)
114 ("libxrandr" ,libxrandr)
115 ("libxxf86vm" ,libxxf86vm)))
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.3.2")
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 "1hg1gvcwvayksrdh9z8rfz66h3z1ffspmm2qgyy2nd8n8qrfwfjf"))
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 (_
282 `()))
283 ("pkg-config" ,pkg-config)
284 ("python" ,python-wrapper)
285 ("python-mako" ,python-mako)
286 ("which" ,(@ (gnu packages base) which))))
287 (arguments
288 `(#:configure-flags
289 '(,@(match (%current-system)
290 ((or "armhf-linux" "aarch64-linux")
291 ;; TODO: Fix svga driver for aarch64 and armhf.
292 '("-Dgallium-drivers=etnaviv,freedreno,nouveau,r300,r600,swrast,tegra,v3d,vc4,virgl"))
293 (_
294 '("-Dgallium-drivers=iris,nouveau,r300,r600,radeonsi,svga,swrast,virgl")))
295 ;; Enable various optional features. TODO: opencl requires libclc,
296 ;; omx requires libomxil-bellagio
297 "-Dplatforms=x11,drm,surfaceless,wayland"
298 "-Dglx=dri" ;Thread Local Storage, improves performance
299 ;; "-Dopencl=true"
300 ;; "-Domx=true"
301 "-Dosmesa=gallium"
302 "-Dgallium-xa=true"
303
304 ;; features required by wayland
305 "-Dgles2=true"
306 "-Dgbm=true"
307 "-Dshared-glapi=true"
308
309 ;; Enable Vulkan on i686-linux and x86-64-linux.
310 ,@(match (%current-system)
311 ((or "i686-linux" "x86_64-linux")
312 '("-Dvulkan-drivers=intel,amd"))
313 (_
314 '("-Dvulkan-drivers=auto")))
315
316 ;; Enable the Vulkan overlay layer on i686-linux and x86-64-linux.
317 ,@(match (%current-system)
318 ((or "x86_64-linux" "i686-linux")
319 '("-Dvulkan-overlay-layer=true"))
320 (_
321 '()))
322
323 ;; Also enable the tests.
324 "-Dbuild-tests=true"
325
326 ;; on non-intel systems, drop i915 and i965
327 ;; from the default dri drivers
328 ,@(match (%current-system)
329 ((or "x86_64-linux" "i686-linux")
330 '("-Ddri-drivers=i915,i965,nouveau,r200,r100"
331 "-Dllvm=true")) ; default is x86/x86_64 only
332 (_
333 '("-Ddri-drivers=nouveau,r200,r100"))))
334
335 ;; XXX: 'debugoptimized' causes LTO link failures on some drivers. The
336 ;; documentation recommends using 'release' for performance anyway.
337 #:build-type "release"
338
339 #:modules ((ice-9 match)
340 (srfi srfi-1)
341 (guix build utils)
342 (guix build meson-build-system))
343 #:phases
344 (modify-phases %standard-phases
345 (add-after
346 'unpack 'patch-create_test_cases
347 (lambda _
348 (substitute* "src/intel/genxml/gen_pack_header.py"
349 (("/usr/bin/env python2") (which "python")))
350 #t))
351 ,@(if (string-prefix? "i686" (or (%current-target-system)
352 (%current-system)))
353 ;; Disable new test from Mesa 19 that fails on i686. Upstream
354 ;; report: <https://bugs.freedesktop.org/show_bug.cgi?id=110612>.
355 `((add-after 'unpack 'disable-failing-test
356 (lambda _
357 (substitute* "src/gallium/tests/unit/meson.build"
358 (("'u_format_test',") ""))
359 #t)))
360 '())
361 (add-before
362 '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/dri_common.c"
368 (("dlopen\\(\"libGL\\.so")
369 (string-append "dlopen(\"" out "/lib/libGL.so")))
370 (substitute* "src/egl/drivers/dri2/egl_dri2.c"
371 (("\"libglapi\\.so")
372 (string-append "\"" out "/lib/libglapi.so")))
373 (substitute* "src/gbm/main/backend.c"
374 ;; No need to patch the gbm_gallium_drm.so reference;
375 ;; it's never installed since Mesa removed its
376 ;; egl_gallium support.
377 (("\"gbm_dri\\.so")
378 (string-append "\"" out "/lib/dri/gbm_dri.so")))
379 #t)))
380 (add-after 'install 'symlinks-instead-of-hard-links
381 (lambda* (#:key outputs #:allow-other-keys)
382 ;; All the drivers and gallium targets create hard links upon
383 ;; installation (search for "hardlink each megadriver instance"
384 ;; in the makefiles). This is no good for us since we'd produce
385 ;; nars that contain several copies of these files. Thus, turn
386 ;; them into symlinks, which saves ~124 MiB.
387 (let* ((out (assoc-ref outputs "out"))
388 (lib (string-append out "/lib"))
389 (files (find-files lib
390 (lambda (file stat)
391 (and (string-contains file ".so")
392 (eq? 'regular
393 (stat:type stat))))))
394 (inodes (map (compose stat:ino stat) files)))
395 (for-each (lambda (inode)
396 (match (filter-map (match-lambda
397 ((file ino)
398 (and (= ino inode) file)))
399 (zip files inodes))
400 ((_)
401 #f)
402 ((reference others ..1)
403 (format #t "creating ~a symlinks to '~a'~%"
404 (length others) reference)
405 (for-each delete-file others)
406 (for-each (lambda (file)
407 (if (string=? (dirname file)
408 (dirname reference))
409 (symlink (basename reference)
410 file)
411 (symlink reference file)))
412 others))))
413 (delete-duplicates inodes))
414 #t))))))
415 (home-page "https://mesa3d.org/")
416 (synopsis "OpenGL and Vulkan implementations")
417 (description "Mesa is a free implementation of the OpenGL and Vulkan
418 specifications - systems for rendering interactive 3D graphics. A variety of
419 device drivers allows Mesa to be used in many different environments ranging
420 from software emulation to complete hardware acceleration for modern GPUs.")
421 (license license:x11)))
422
423 (define-public mesa-opencl
424 (package
425 (inherit mesa)
426 (name "mesa-opencl")
427 (arguments
428 (substitute-keyword-arguments (package-arguments mesa)
429 ((#:configure-flags flags)
430 `(cons "-Dgallium-opencl=standalone" ,flags))))
431 (inputs
432 `(("libclc" ,libclc)
433 ,@(package-inputs mesa)))
434 (native-inputs
435 `(("clang" ,clang)
436 ,@(package-native-inputs mesa)))))
437
438 (define-public mesa-opencl-icd
439 (package
440 (inherit mesa-opencl)
441 (name "mesa-opencl-icd")
442 (arguments
443 (substitute-keyword-arguments (package-arguments mesa)
444 ((#:configure-flags flags)
445 `(cons "-Dgallium-opencl=icd"
446 ,(delete "-Dgallium-opencl=standalone" flags)))))))
447
448 (define-public mesa-headers
449 (package
450 (inherit mesa)
451 (name "mesa-headers")
452 (propagated-inputs '())
453 (inputs '())
454 (native-inputs '())
455 (arguments
456 '(#:phases
457 (modify-phases %standard-phases
458 (delete 'configure)
459 (delete 'build)
460 (delete 'check)
461 (replace 'install
462 (lambda* (#:key outputs #:allow-other-keys)
463 (copy-recursively "include" (string-append
464 (assoc-ref outputs "out")
465 "/include"))
466 #t)))))))
467
468 ;;; The mesa-demos distribution contains non-free files, many files with no
469 ;;; clear license information, and many demos that aren't useful for most
470 ;;; people, so we just use this for the mesa-utils package below, and possibly
471 ;;; other packages in the future. This is modeled after Debian's solution.
472 (define (mesa-demos-source version)
473 (origin
474 (method url-fetch)
475 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/demos"
476 "/mesa-demos-" version ".tar.bz2"))
477 (sha256 (base32 "0zgzbz55a14hz83gbmm0n9gpjnf5zadzi2kjjvkn6khql2a9rs81"))))
478
479 (define-public mesa-utils
480 (package
481 (name "mesa-utils")
482 (version "8.4.0")
483 (source (mesa-demos-source version))
484 (build-system gnu-build-system)
485 (inputs
486 `(("mesa" ,mesa)
487 ("glut" ,freeglut)
488 ("glew" ,glew)))
489 (native-inputs
490 `(("pkg-config" ,pkg-config)))
491 (arguments
492 '(#:phases
493 (modify-phases %standard-phases
494 (replace
495 'install
496 (lambda* (#:key outputs #:allow-other-keys)
497 (let ((out (assoc-ref outputs "out")))
498 (mkdir-p (string-append out "/bin"))
499 (for-each
500 (lambda (file)
501 (copy-file file (string-append out "/bin/" (basename file))))
502 '("src/xdemos/glxdemo" "src/xdemos/glxgears"
503 "src/xdemos/glxinfo" "src/xdemos/glxheads"))
504 #t))))))
505 (home-page "https://mesa3d.org/")
506 (synopsis "Utility tools for Mesa")
507 (description
508 "The mesa-utils package contains several utility tools for Mesa: glxdemo,
509 glxgears, glxheads, and glxinfo.")
510 ;; glxdemo is public domain; others expat.
511 (license (list license:expat license:public-domain))))
512
513 (define-public glew
514 (package
515 (name "glew")
516 (version "2.1.0")
517 (source (origin
518 (method url-fetch)
519 (uri (string-append "mirror://sourceforge/glew/glew/" version
520 "/glew-" version ".tgz"))
521 (sha256
522 (base32
523 "159wk5dc0ykjbxvag5i1m2mhp23zkk6ra04l26y3jc3nwvkr3ph4"))
524 (modules '((guix build utils)))
525 (snippet
526 '(begin
527 (substitute* "config/Makefile.linux"
528 (("= cc") "= gcc")
529 (("/lib64") "/lib"))
530 #t))))
531 (build-system gnu-build-system)
532 (arguments
533 '(#:phases (modify-phases %standard-phases (delete 'configure))
534 #:make-flags (list (string-append "GLEW_PREFIX="
535 (assoc-ref %outputs "out"))
536 (string-append "GLEW_DEST="
537 (assoc-ref %outputs "out")))
538 #:tests? #f)) ;no 'check' target
539 (inputs
540 `(("libxi" ,libxi)
541 ("libxmu" ,libxmu)
542 ("libx11" ,libx11)
543 ("mesa" ,mesa)))
544
545 ;; <GL/glew.h> includes <GL/glu.h>.
546 (propagated-inputs `(("glu" ,glu)))
547
548 (home-page "http://glew.sourceforge.net/")
549 (synopsis "OpenGL extension loading library for C and C++")
550 (description
551 "The OpenGL Extension Wrangler Library (GLEW) is a C/C++ extension
552 loading library. GLEW provides efficient run-time mechanisms for determining
553 which OpenGL extensions are supported on the target platform. OpenGL core and
554 extension functionality is exposed in a single header file.")
555 (license license:bsd-3)))
556
557 (define-public guile-opengl
558 (package
559 (name "guile-opengl")
560 (version "0.1.0")
561 (source (origin
562 (method url-fetch)
563 (uri (string-append "mirror://gnu/guile-opengl/guile-opengl-"
564 version ".tar.gz"))
565 (sha256
566 (base32
567 "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim"))))
568 (build-system gnu-build-system)
569 (native-inputs `(("pkg-config" ,pkg-config)))
570 (inputs `(("guile" ,guile-2.2)
571 ("mesa" ,mesa)
572 ("glu" ,glu)
573 ("freeglut" ,freeglut)))
574 (arguments
575 '(#:phases (modify-phases %standard-phases
576 (add-after 'configure 'patch-makefile
577 (lambda _
578 ;; Install compiled Guile files in the expected place.
579 (substitute* '("Makefile")
580 (("^godir = .*$")
581 "godir = $(moddir)\n"))))
582 (add-before 'build 'patch-dynamic-link
583 (lambda* (#:key inputs outputs #:allow-other-keys)
584 (define (dynamic-link-substitute file lib input)
585 (substitute* file
586 (("dynamic-link \"lib([a-zA-Z]+)\"" _ lib)
587 (string-append "dynamic-link \""
588 (assoc-ref inputs input)
589 "/lib/lib" lib "\""))))
590 ;; Replace dynamic-link calls for libGL, libGLU, and
591 ;; libglut with absolute paths to the store.
592 (dynamic-link-substitute "glx/runtime.scm" "GL" "mesa")
593 (dynamic-link-substitute "glu/runtime.scm" "GLU" "glu")
594 (dynamic-link-substitute "glut/runtime.scm" "glut"
595 "freeglut"))))))
596 (home-page "https://gnu.org/s/guile-opengl")
597 (synopsis "Guile binding for the OpenGL graphics API")
598 (description
599 "Guile-OpenGL is a library for Guile that provides bindings to the
600 OpenGL graphics API.")
601 (license license:lgpl3+)))
602
603 (define-public libepoxy
604 (package
605 (name "libepoxy")
606 (version "1.5.4")
607 (source (origin
608 (method url-fetch)
609 (uri (string-append
610 "https://github.com/anholt/libepoxy/releases/download/"
611 version "/libepoxy-" version ".tar.xz"))
612 (sha256
613 (base32
614 "1ll9fach4v30dsyd47s5ial4gaiwihzr2afb77vxxzzy3mlcrlhb"))))
615 (arguments
616 `(#:phases
617 (modify-phases %standard-phases
618 (delete 'bootstrap)
619 (add-before
620 'configure 'patch-paths
621 (lambda* (#:key inputs #:allow-other-keys)
622 (let ((python (assoc-ref inputs "python"))
623 (mesa (assoc-ref inputs "mesa")))
624 (substitute* "src/gen_dispatch.py"
625 (("/usr/bin/env python") python))
626 (substitute* (find-files "." "\\.[ch]$")
627 (("libGL.so.1") (string-append mesa "/lib/libGL.so.1"))
628 (("libEGL.so.1") (string-append mesa "/lib/libEGL.so.1")))
629 #t))))))
630 (build-system meson-build-system)
631 (native-inputs
632 `(("pkg-config" ,pkg-config)
633 ("python" ,python)))
634 (inputs
635 `(("mesa" ,mesa)))
636 (home-page "https://github.com/anholt/libepoxy/")
637 (synopsis "A library for handling OpenGL function pointer management")
638 (description
639 "A library for handling OpenGL function pointer management.")
640 (license license:x11)))
641
642 (define-public soil
643 (package
644 (name "soil")
645 (version "1.0.7")
646 (source (origin
647 (method url-fetch)
648 ;; No versioned archive available.
649 (uri "http://www.lonesock.net/files/soil.zip")
650 (sha256
651 (base32
652 "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52"))))
653 (build-system gnu-build-system)
654 (arguments
655 '(#:tests? #f ; no tests
656 #:phases (modify-phases %standard-phases
657 (delete 'configure)
658 (add-before 'build 'init-build
659 (lambda* (#:key outputs #:allow-other-keys)
660 (let ((out (assoc-ref outputs "out")))
661 (setenv "CFLAGS" "-fPIC") ; needed for shared library
662 ;; Use alternate Makefile
663 (copy-file "projects/makefile/alternate Makefile.txt"
664 "src/Makefile")
665 (chdir "src")
666 (substitute* '("Makefile")
667 (("INCLUDEDIR = /usr/include/SOIL")
668 (string-append "INCLUDEDIR = " out "/include/SOIL"))
669 (("LIBDIR = /usr/lib")
670 (string-append "LIBDIR = " out "/lib"))
671 ;; Remove these flags from 'install' commands.
672 (("-o root -g root") ""))))))))
673 (native-inputs
674 `(("unzip" ,unzip)))
675 (inputs
676 `(("mesa" ,mesa)))
677 (home-page "https://www.lonesock.net/soil.html")
678 (synopsis "OpenGL texture loading library")
679 (description
680 "SOIL is a tiny C library used primarily for uploading textures into
681 OpenGL.")
682 (license license:public-domain)))
683
684 (define-public glfw
685 (package
686 (name "glfw")
687 (version "3.2.1")
688 (source (origin
689 (method url-fetch)
690 (uri (string-append "https://github.com/glfw/glfw"
691 "/releases/download/" version
692 "/glfw-" version ".zip"))
693 (sha256
694 (base32
695 "09kk5yc1zhss9add8ryqrngrr16hdmc94rszgng135bhw09mxmdp"))))
696 (build-system cmake-build-system)
697 (arguments
698 '(#:tests? #f ; no test target
699 #:configure-flags '("-DBUILD_SHARED_LIBS=ON")))
700 (native-inputs
701 `(("doxygen" ,doxygen)
702 ("unzip" ,unzip)))
703 (propagated-inputs
704 `(("mesa" ,mesa) ;included in public headers
705
706 ;; These are in 'Requires.private' of 'glfw3.pc'.
707 ("libx11" ,libx11)
708 ("libxrandr" ,libxrandr)
709 ("libxinerama" ,libxinerama)
710 ("libxcursor" ,libxcursor)
711 ("libxxf86vm" ,libxxf86vm)))
712 (home-page "http://www.glfw.org")
713 (synopsis "OpenGL application development library")
714 (description
715 "GLFW is a library for OpenGL, OpenGL ES and Vulkan development for
716 desktop computers. It provides a simple API for creating windows, contexts
717 and surfaces, receiving input and events.")
718 (license license:zlib)))
719
720 (define-public nanovg-for-extempore
721 (package
722 (name "nanovg-for-extempore")
723 (version "0.7.1")
724 (source (origin
725 (method url-fetch)
726 (uri (string-append "https://github.com/extemporelang/nanovg/"
727 "archive/" version ".tar.gz"))
728 (file-name (string-append name "-" version ".tar.gz"))
729 (sha256
730 (base32
731 "0ivs1sagq19xiw8jxd9f8w2b39svi0n9hrbmdvckwvqg95r8701g"))))
732 (build-system cmake-build-system)
733 (arguments `(#:tests? #f)) ; no tests included
734 (inputs
735 `(("mesa" ,mesa)))
736 ;; Extempore refuses to build on architectures other than x86_64
737 (supported-systems '("x86_64-linux"))
738 (home-page "https://github.com/extemporelang/nanovg")
739 (synopsis "2D vector drawing library on top of OpenGL")
740 (description "NanoVG is small antialiased vector graphics rendering
741 library for OpenGL. It has lean API modeled after HTML5 canvas API. It is
742 aimed to be a practical and fun toolset for building scalable user interfaces
743 and visualizations.")
744 (license license:zlib)))
745
746 (define-public gl2ps
747 (package
748 (name "gl2ps")
749 (version "1.4.0")
750 (source
751 (origin
752 (method url-fetch)
753 (uri (string-append
754 "http://geuz.org/gl2ps/src/gl2ps-"
755 version ".tgz"))
756 (sha256
757 (base32
758 "1qpidkz8x3bxqf69hlhyz1m0jmfi9kq24fxsp7rq6wfqzinmxjq3"))))
759 (build-system cmake-build-system)
760 (inputs
761 `(("libpng" ,libpng)
762 ("mesa" ,mesa)
763 ("zlib" ,zlib)))
764 (arguments
765 `(#:tests? #f)) ;; no tests
766 (home-page "http://www.geuz.org/gl2ps/")
767 (synopsis "OpenGL to PostScript printing library")
768 (description "GL2PS is a C library providing high quality vector
769 output for any OpenGL application. GL2PS uses sorting algorithms
770 capable of handling intersecting and stretched polygons, as well as
771 non-manifold objects. GL2PS provides many features including advanced
772 smooth shading and text rendering, culling of invisible primitives and
773 mixed vector/bitmap output.")
774 ;; GL2PS is dual-licenced and can be used under the terms of either.
775 (license (list license:lgpl2.0+
776 (license:fsf-free "http://www.geuz.org/gl2ps/COPYING.GL2PS"
777 "GPL-incompatible copyleft license")))))
778
779 (define-public virtualgl
780 (package
781 (name "virtualgl")
782 (version "2.6.2")
783 (source
784 (origin
785 (method git-fetch)
786 (uri (git-reference
787 (url "https://github.com/VirtualGL/virtualgl.git")
788 (commit version)))
789 (file-name (git-file-name name version))
790 (sha256
791 (base32 "0yyc553xsb5n0rx7jp9p4wdbd7md07b3qrkf3ssyjavqqg908qg9"))))
792 (arguments
793 `(#:tests? #f ; no tests are available
794 #:configure-flags (list
795 (string-append "-DCMAKE_INSTALL_LIBDIR="
796 (assoc-ref %outputs "out") "/lib")
797 "-DVGL_USESSL=1"))) ; use OpenSSL
798 (build-system cmake-build-system)
799 (inputs `(("glu" ,glu)
800 ("libjpeg-turbo" ,libjpeg-turbo)
801 ("libxtst" ,libxtst)
802 ("mesa" ,mesa)
803 ("openssl" ,openssl)))
804 (native-inputs `(("pkg-config" ,pkg-config)))
805 (home-page "https://www.virtualgl.org")
806 (synopsis "Redirects 3D commands from an OpenGL application onto a 3D
807 graphics card")
808 (description "VirtualGL redirects the 3D rendering commands from OpenGL
809 applications to 3D accelerator hardware in a dedicated server and displays the
810 rendered output interactively to a thin client located elsewhere on the
811 network.")
812 (license license:wxwindows3.1+)))
813
814 (define-public mojoshader
815 (let ((changeset "5887634ea695"))
816 (package
817 (name "mojoshader")
818 (version (string-append "20190825" "-" changeset))
819 (source
820 (origin
821 (method hg-fetch)
822 (uri (hg-reference
823 (url "https://hg.icculus.org/icculus/mojoshader/")
824 (changeset changeset)))
825 (file-name (git-file-name name version))
826 (sha256
827 (base32 "0ibl4z1696jiifv9j5drir7jm0b5px0vwkwckbi7cfd46p7p6wcy"))))
828 (arguments
829 ;; Tests only for COMPILER_SUPPORT=ON.
830 `(#:tests? #f
831 #:configure-flags '("-DBUILD_SHARED=ON"
832 "-DFLIP_VIEWPORT=ON"
833 "-DDEPTH_CLIPPING=ON")
834 #:phases
835 (modify-phases %standard-phases
836 (replace 'install
837 (lambda* (#:key outputs #:allow-other-keys)
838 (let* ((out (assoc-ref outputs "out"))
839 (lib (string-append out "/lib"))
840 (header (string-append out "/include")))
841 (install-file "libmojoshader.so" lib)
842 (for-each (lambda (f)
843 (install-file f header))
844 (find-files "../source" "mojoshader.*\\.h$"))
845 (let ((profiles-header (string-append header "/profiles")))
846 (mkdir-p profiles-header)
847 (rename-file (string-append header "/mojoshader_profile.h")
848 (string-append profiles-header "/mojoshader_profile.h"))))
849 #t)))))
850 (build-system cmake-build-system)
851 (home-page "https://www.icculus.org/mojoshader/")
852 (synopsis "Work with Direct3D shaders on alternate 3D APIs")
853 (description "MojoShader is a library to work with Direct3D shaders on
854 alternate 3D APIs and non-Windows platforms. The primary motivation is moving
855 shaders to OpenGL languages on the fly. The developer deals with \"profiles\"
856 that represent various target languages, such as GLSL or ARB_*_program.
857
858 This allows a developer to manage one set of shaders, presumably written in
859 Direct3D HLSL, and use them across multiple rendering backends. This also
860 means that the developer only has to worry about one (offline) compiler to
861 manage program complexity, while MojoShader itself deals with the reduced
862 complexity of the bytecode at runtime.
863
864 MojoShader provides both a simple API to convert bytecode to various profiles,
865 and (optionally) basic glue to rendering APIs to abstract the management of
866 the shaders at runtime.")
867 (license license:zlib))))
868
869 (define-public mojoshader-with-viewport-flip
870 ;; Changeset c586d4590241 replaced glProgramViewportFlip with
871 ;; glProgramViewportInfo.
872 ;; https://hg.icculus.org/icculus/mojoshader/rev/c586d4590241
873 (let ((changeset "2e37299b13d8"))
874 (package
875 (inherit mojoshader)
876 (name "mojoshader-with-viewport-flip")
877 (version (string-append "20190725" "-" changeset))
878 (source
879 (origin
880 (method hg-fetch)
881 (uri (hg-reference
882 (url "https://hg.icculus.org/icculus/mojoshader/")
883 (changeset changeset)))
884 (file-name (git-file-name name version))
885 (sha256
886 (base32 "0ffws7cqbskxwc3hjsnnzq4r2bbf008kdr3b11pa3kr7dsi50y6i"))))
887 (synopsis "Work with Direct3D shaders on alternate 3D APIs (with viewport flip)")
888 (description "This is the last version of the mojoshader library with
889 the glProgramViewportFlip before it was replaced with glProgramViewportInfo.")
890 (license license:zlib))))
891
892 (define-public mojoshader-cs
893 (let ((commit "10d0dba21ff1cfe332eb7de328a2adce01286bd7"))
894 (package
895 (name "mojoshader-cs")
896 (version (git-version "20191205" "1" commit))
897 (source (origin
898 (method git-fetch)
899 (uri (git-reference
900 (url "https://github.com/FNA-XNA/MojoShader")
901 (commit commit)))
902 (file-name (git-file-name name version))
903 (sha256
904 (base32
905 "11mdhf3fmb9rsn2iv753gmb596j4dh5j2iipgw078vg0lj23rml7"))))
906 (build-system gnu-build-system)
907 (arguments
908 '(#:tests? #f ; No tests.
909 #:phases
910 (modify-phases %standard-phases
911 (delete 'configure)
912 (replace 'build
913 (lambda _
914 (invoke "make" "-C" "csharp")))
915 (replace 'install
916 (lambda* (#:key outputs #:allow-other-keys)
917 (let ((out (assoc-ref outputs "out")))
918 (install-file "csharp/bin/MojoShader-CS.dll" (string-append out "/lib"))
919 #t))))))
920 (native-inputs
921 `(("mono" ,mono)))
922 (home-page "https://github.com/FNA-XNA/MojoShader")
923 (synopsis "C# wrapper for MojoShader")
924 (description
925 "Mojoshader-CS provides C# bindings for the Mojoshader library.
926 The C# wrapper was written to be used for FNA's platform support. However, this
927 is written in a way that can be used for any general C# application.")
928 (license license:zlib))))