gnu: xmenu: Update to 4.4.1.
[jackhill/guix/guix.git] / gnu / packages / gl.scm
CommitLineData
daca8666 1;;; GNU Guix --- Functional package management for GNU
187731a5 2;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
822efdff 3;;; Copyright © 2013 Joshua Grant <tadni@riseup.net>
432360d7 4;;; Copyright © 2014, 2016 David Thompson <davet@gnu.org>
d0d0f8d1 5;;; Copyright © 2014, 2015, 2016, 2017 Mark H Weaver <mhw@netris.org>
3c986a7d 6;;; Copyright © 2016 Nikita <nikita@n0.is>
ad1edd03 7;;; Copyright © 2016, 2017, 2018, 2020 Ricardo Wurmus <rekado@elephly.net>
b4c8c413 8;;; Copyright © 2016 David Thompson <davet@gnu.org>
ba4c0d69 9;;; Copyright © 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
725d8d2c 10;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
e6a668ec 11;;; Copyright © 2017, 2018, 2019 Rutger Helling <rhelling@mykolab.com>
6018d1ee 12;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
5c154738 13;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
8ae17933 14;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
7bb0ba81 15;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
daca8666
JG
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)
c4a667bf 33 #:use-module (gnu packages)
b021a2ad 34 #:use-module (gnu packages autotools)
200726ed 35 #:use-module (gnu packages bison)
725d8d2c 36 #:use-module (gnu packages compression)
432360d7 37 #:use-module (gnu packages documentation)
653569e8 38 #:use-module (gnu packages elf)
200726ed 39 #:use-module (gnu packages flex)
3a92a5b3
DC
40 #:use-module (gnu packages fontutils)
41 #:use-module (gnu packages freedesktop)
ce4d7abf 42 #:use-module (gnu packages gettext)
3a92a5b3 43 #:use-module (gnu packages guile)
725d8d2c 44 #:use-module (gnu packages image)
ce4d7abf 45 #:use-module (gnu packages linux)
093c6f8b 46 #:use-module (gnu packages llvm)
bea58fa1 47 #:use-module (gnu packages mono)
3a92a5b3 48 #:use-module (gnu packages pkg-config)
200726ed 49 #:use-module (gnu packages python)
44d10b1f 50 #:use-module (gnu packages python-xyz)
d64f3439 51 #:use-module (gnu packages tls)
7e31978b 52 #:use-module (gnu packages video)
301b2e74 53 #:use-module (gnu packages vulkan)
2b226af1 54 #:use-module (gnu packages xdisorg)
3a92a5b3
DC
55 #:use-module (gnu packages xml)
56 #:use-module (gnu packages xorg)
3a92a5b3 57 #:use-module (guix download)
872ea4eb 58 #:use-module (guix git-download)
5c154738 59 #:use-module (guix hg-download)
3a92a5b3
DC
60 #:use-module (guix build-system gnu)
61 #:use-module (guix build-system cmake)
54d860cc 62 #:use-module (guix build-system meson)
3a92a5b3
DC
63 #:use-module ((guix licenses) #:prefix license:)
64 #:use-module (guix packages)
65 #:use-module (guix utils)
3ee7b4cc 66 #:use-module (ice-9 match)
af403cf0 67 #:use-module ((srfi srfi-1) #:hide (zip)))
daca8666
JG
68
69(define-public glu
70 (package
71 (name "glu")
1dff73ac 72 (version "9.0.1")
daca8666 73 (source (origin
a124bbd2
SB
74 (method url-fetch)
75 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/glu/glu-"
76 version ".tar.gz"))
77 (sha256
78 (base32
1dff73ac 79 "1xqhk9bn10nbvffw3r4p4rjslwz1l7gaycc0x2pqkr2irp7q9x7n"))))
daca8666 80 (build-system gnu-build-system)
187731a5 81 (propagated-inputs
a124bbd2 82 `(("mesa" ,mesa))) ; according to glu.pc
daca8666
JG
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
35b9e423 87not provided by just OpenGL itself. Some of GLU's Features
daca8666
JG
88include: Scaling of 2D images and creation of mipmap pyramids,
89Transformation of object coordinates into device coordinates and
90vice versa, Support for NURBS surfaces, Support for tessellation
91of concave or bow tie polygonal primitives, Specialty transformation
92matrices for creating perspective and orthographic projections,
93positioning a camera, and selection/picking, Rendering of disk,
94cylinder, and sphere primitives, Interpreting OpenGL error values
95as ASCII text.")
584f2e1b 96 (license (license:x11-style "http://directory.fsf.org/wiki/License:SGIFreeBv2"))))
daca8666
JG
97
98(define-public freeglut
99 (package
100 (name "freeglut")
64136870 101 (version "3.2.1")
daca8666 102 (source (origin
a124bbd2
SB
103 (method url-fetch)
104 (uri (string-append
0f971a04 105 "mirror://sourceforge/freeglut/freeglut/"
a124bbd2
SB
106 version "/freeglut-" version ".tar.gz"))
107 (sha256
108 (base32
64136870 109 "0s6sk49q8ijgbsrrryb7dzqx2fa744jhx1wck5cz5jia2010w06l"))))
8ce36e81 110 (build-system cmake-build-system)
5f613047
MB
111 (arguments
112 '(#:tests? #f ;no test target
113 #:configure-flags '("-DFREEGLUT_BUILD_STATIC_LIBS=OFF")))
64136870 114 (inputs `(("libx11" ,libx11)
a124bbd2
SB
115 ("libxi" ,libxi)
116 ("libxrandr" ,libxrandr)
64136870 117 ("libxxf86vm" ,libxxf86vm)))
9b5db9be
TUBK
118 (propagated-inputs
119 ;; Headers from Mesa and GLU are needed.
120 `(("glu" ,glu)
121 ("mesa" ,mesa)))
daca8666
JG
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
35b9e423 126the OpenGL Utility Toolkit (GLUT) library. GLUT was originally
daca8666 127written by Mark Kilgard to support the sample programs in the
36a4366d 128second edition OpenGL @code{RedBook}. Since then, GLUT has been used
daca8666
JG
129in a wide variety of practical applications because it is simple,
130widely available and highly portable.
131
132GLUT (and hence freeglut) allows the user to create and manage windows
133containing OpenGL contexts on a wide range of platforms and also read
35b9e423 134the mouse, keyboard and joystick functions. Freeglut is released under
daca8666 135the X-Consortium license.")
584f2e1b 136 (license license:x11)))
daca8666 137
0da0f434
RW
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"))))
80921d29
MB
151 (build-system gnu-build-system)
152 (arguments
153 '(#:configure-flags '("--disable-static")))))
0da0f434 154
daca8666
JG
155(define-public ftgl
156 (package
157 (name "ftgl")
c7e31cde
MB
158 (version "2.4.0")
159 (home-page "https://github.com/frankheckenbach/ftgl")
daca8666 160 (source (origin
c7e31cde
MB
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))
a124bbd2
SB
165 (sha256
166 (base32
c7e31cde 167 "0zjs1h9w30gajq9lndzvjsa26rsmr1081lb1fbpbj10yhcdcsc79"))))
daca8666 168 (build-system gnu-build-system)
2e652add
MB
169 (arguments
170 `(#:configure-flags '("--disable-static")))
9e850534
RW
171 ;; The pkg-config file lists "freetype2" as Requires.private.
172 (propagated-inputs `(("freetype" ,freetype)))
173 (inputs `(("libx11" ,libx11)
a124bbd2
SB
174 ("mesa" ,mesa)
175 ("glu" ,glu)))
a53a5b71 176 (native-inputs
c7e31cde
MB
177 `(("pkg-config" ,pkg-config)
178 ("autoconf" ,autoconf)
179 ("automake" ,automake)
180 ("libtool" ,libtool)))
daca8666
JG
181 (synopsis "Font rendering library for OpenGL applications")
182 (description
35b9e423 183 "FTGL is a font rendering library for OpenGL applications. Supported
daca8666 184rendering modes are: Bitmaps, Anti-aliased pixmaps, Texture maps, Outlines,
e881752c 185Polygon meshes, and Extruded polygon meshes.")
584f2e1b 186 (license license:x11)))
200726ed 187
b021a2ad
TUBK
188(define-public s2tc
189 (package
190 (name "s2tc")
191 (version "1.0")
192 (source
193 (origin
872ea4eb
RW
194 (method git-fetch)
195 (uri (git-reference
b0e7b699 196 (url "https://github.com/divVerent/s2tc")
872ea4eb
RW
197 (commit (string-append "v" version))))
198 (file-name (git-file-name name version))
b021a2ad 199 (sha256
872ea4eb 200 (base32 "1fg323fk7wlv2xh6lw66wswgcv6qi8aaadk7c28h2f2lj1s7njnf"))))
b021a2ad
TUBK
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)))
b021a2ad
TUBK
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,
212also known as DXTn or DXTC) for Mesa.")
584f2e1b 213 (license license:expat)))
b021a2ad 214
7e31978b
TUBK
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")
3ee7b4cc
EF
224 (inputs `(,@(fold alist-delete (package-inputs libva)
225 '("mesa" "wayland"))))
7e31978b
TUBK
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
200726ed
JD
233(define-public mesa
234 (package
235 (name "mesa")
b7c0b0ad 236 (version "20.1.9")
200726ed
JD
237 (source
238 (origin
239 (method url-fetch)
57cdc1fa
MB
240 (uri (list (string-append "https://mesa.freedesktop.org/archive/"
241 "mesa-" version ".tar.xz")
242 (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
0315b20a
MB
243 "mesa-" version ".tar.xz")
244 (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
245 version "/mesa-" version ".tar.xz")))
200726ed 246 (sha256
ce4d7abf 247 (base32
b7c0b0ad 248 "10kk8a8k7f4ip8yaiqdyrx162nbw8pw4h3b4hs4ha8mpd43wlldj"))
17f2b485 249 (patches
91304b79 250 (search-patches "mesa-skip-disk-cache-test.patch"))))
f6dadee4 251 (build-system meson-build-system)
200726ed 252 (propagated-inputs
70b02a6a 253 `(;; The following are in the Requires.private field of gl.pc.
ce4d7abf 254 ("libdrm" ,libdrm)
4ea1ad91 255 ("libvdpau" ,libvdpau)
8bb1699b 256 ("libx11" ,libx11)
200726ed 257 ("libxdamage" ,libxdamage)
45191970
TUBK
258 ("libxfixes" ,libxfixes)
259 ("libxshmfence" ,libxshmfence)
70b02a6a
MB
260 ("libxxf86vm" ,libxxf86vm)
261 ("xorgproto" ,xorgproto)))
200726ed 262 (inputs
e0b744f1 263 `(("expat" ,expat)
9b3b4c05 264 ("libelf" ,elfutils) ;required for r600 when using llvm
7e31978b 265 ("libva" ,(force libva-without-mesa))
200726ed 266 ("libxml2" ,libxml2)
ce4d7abf 267 ;; TODO: Add 'libxml2-python' for OpenGL ES 1.1 and 2.0 support
aea3ec0f 268 ("libxrandr" ,libxrandr)
0272ee49 269 ("libxvmc" ,libxvmc)
c5e91014
EF
270 ,@(match (%current-system)
271 ((or "x86_64-linux" "i686-linux")
f5eb13b2 272 ;; Note: update the 'clang' input of mesa-opencl when bumping this.
e634d959 273 `(("llvm" ,llvm-10)))
c5e91014
EF
274 (_
275 `()))
cb639269
MB
276 ("wayland" ,wayland)
277 ("wayland-protocols" ,wayland-protocols)))
200726ed 278 (native-inputs
f6dadee4
RH
279 `(("bison" ,bison)
280 ("flex" ,flex)
281 ("gettext" ,gettext-minimal)
301b2e74
RH
282 ,@(match (%current-system)
283 ((or "x86_64-linux" "i686-linux")
47406a92 284 `(("glslang" ,glslang)))
301b2e74
RH
285 (_
286 `()))
f6dadee4 287 ("pkg-config" ,pkg-config)
178611c8 288 ("python" ,python-wrapper)
17c3e0d8 289 ("python-mako" ,python-mako)
653569e8 290 ("which" ,(@ (gnu packages base) which))))
0df5bdf8 291 (outputs '("out" "bin"))
200726ed 292 (arguments
ce4d7abf 293 `(#:configure-flags
2a8b89c2 294 '(,@(match (%current-system)
cd9f99f1 295 ((or "armhf-linux" "aarch64-linux")
31c70cce 296 ;; TODO: Fix svga driver for aarch64 and armhf.
ee401ed9 297 '("-Dgallium-drivers=etnaviv,freedreno,kmsro,lima,nouveau,panfrost,r300,r600,swrast,tegra,v3d,vc4,virgl"))
2a8b89c2 298 (_
688d8f22 299 '("-Dgallium-drivers=iris,nouveau,r300,r600,radeonsi,svga,swrast,virgl")))
3e2570d8
TUBK
300 ;; Enable various optional features. TODO: opencl requires libclc,
301 ;; omx requires libomxil-bellagio
f6dadee4
RH
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
8ea75f27 309 ;; features required by wayland
f6dadee4
RH
310 "-Dgles2=true"
311 "-Dgbm=true"
312 "-Dshared-glapi=true"
0315b20a 313
abdb97f8 314 ;; Enable Vulkan on i686-linux and x86-64-linux.
6713e9cb 315 ,@(match (%current-system)
3f14c913 316 ((or "i686-linux" "x86_64-linux")
f6dadee4 317 '("-Dvulkan-drivers=intel,amd"))
6713e9cb 318 (_
7d1494d9 319 '("-Dvulkan-drivers=auto")))
6713e9cb 320
301b2e74
RH
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 (_
93ef8ca6 326 '()))
301b2e74 327
044006f3 328 ;; Also enable the tests.
f6dadee4 329 "-Dbuild-tests=true"
0f481f06
MW
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")
f6dadee4
RH
335 '("-Ddri-drivers=i915,i965,nouveau,r200,r100"
336 "-Dllvm=true")) ; default is x86/x86_64 only
0f481f06 337 (_
f6dadee4 338 '("-Ddri-drivers=nouveau,r200,r100"))))
6fe808f4
MB
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
dcc00f54
LC
344 #:modules ((ice-9 match)
345 (srfi srfi-1)
346 (guix build utils)
f6dadee4 347 (guix build meson-build-system))
e8a7a180
EF
348 #:phases
349 (modify-phases %standard-phases
ccbc1c5e
PN
350 ,@(if (string-prefix? "i686" (or (%current-target-system)
351 (%current-system)))
4bed3b10
MB
352 ;; Disable new test from Mesa 19 that fails on i686. Upstream
353 ;; report: <https://bugs.freedesktop.org/show_bug.cgi?id=110612>.
354 `((add-after 'unpack 'disable-failing-test
355 (lambda _
2d271359 356 (substitute* "src/util/tests/format/meson.build"
4bed3b10
MB
357 (("'u_format_test',") ""))
358 #t)))
359 '())
5a746104 360 (add-before 'configure 'fix-dlopen-libnames
e8a7a180 361 (lambda* (#:key inputs outputs #:allow-other-keys)
db481977 362 (let ((out (assoc-ref outputs "out")))
e8a7a180
EF
363 ;; Remain agnostic to .so.X.Y.Z versions while doing
364 ;; the substitutions so we're future-safe.
5a746104
MB
365 (substitute* "src/glx/meson.build"
366 (("-DGL_LIB_NAME=\"lib@0@\\.so\\.@1@\"")
367 (string-append "-DGL_LIB_NAME=\"" out
368 "/lib/lib@0@.so.@1@\"")))
369 (substitute* "src/gbm/backends/dri/gbm_dri.c"
e8a7a180
EF
370 (("\"libglapi\\.so")
371 (string-append "\"" out "/lib/libglapi.so")))
372 (substitute* "src/gbm/main/backend.c"
373 ;; No need to patch the gbm_gallium_drm.so reference;
374 ;; it's never installed since Mesa removed its
375 ;; egl_gallium support.
376 (("\"gbm_dri\\.so")
0315b20a 377 (string-append "\"" out "/lib/dri/gbm_dri.so")))
dcc00f54 378 #t)))
0df5bdf8
MB
379 (add-after 'install 'split-outputs
380 (lambda* (#:key outputs #:allow-other-keys)
381 (let ((out (assoc-ref outputs "out"))
382 (bin (assoc-ref outputs "bin")))
383 ,@(match (%current-system)
384 ((or "i686-linux" "x86_64-linux")
385 ;; Install the Vulkan overlay control script to a separate
386 ;; output to prevent a reference on Python, saving ~70 MiB
387 ;; on the closure size.
388 '((copy-recursively (string-append out "/bin")
389 (string-append bin "/bin"))
390 (delete-file-recursively (string-append out "/bin"))))
391 (_
392 ;; XXX: On architectures without the Vulkan overlay layer
393 ;; just create an empty file because outputs can not be
394 ;; added conditionally.
395 '((mkdir-p (string-append bin "/bin"))
396 (call-with-output-file (string-append bin "/bin/.empty")
397 (const #t)))))
398 #t)))
dcc00f54
LC
399 (add-after 'install 'symlinks-instead-of-hard-links
400 (lambda* (#:key outputs #:allow-other-keys)
401 ;; All the drivers and gallium targets create hard links upon
402 ;; installation (search for "hardlink each megadriver instance"
403 ;; in the makefiles). This is no good for us since we'd produce
404 ;; nars that contain several copies of these files. Thus, turn
405 ;; them into symlinks, which saves ~124 MiB.
406 (let* ((out (assoc-ref outputs "out"))
407 (lib (string-append out "/lib"))
408 (files (find-files lib
409 (lambda (file stat)
410 (and (string-contains file ".so")
411 (eq? 'regular
412 (stat:type stat))))))
413 (inodes (map (compose stat:ino stat) files)))
414 (for-each (lambda (inode)
415 (match (filter-map (match-lambda
416 ((file ino)
417 (and (= ino inode) file)))
418 (zip files inodes))
419 ((_)
420 #f)
421 ((reference others ..1)
422 (format #t "creating ~a symlinks to '~a'~%"
423 (length others) reference)
424 (for-each delete-file others)
425 (for-each (lambda (file)
426 (if (string=? (dirname file)
427 (dirname reference))
428 (symlink (basename reference)
429 file)
430 (symlink reference file)))
431 others))))
432 (delete-duplicates inodes))
0315b20a
MB
433 #t))))))
434 (home-page "https://mesa3d.org/")
6713e9cb
RH
435 (synopsis "OpenGL and Vulkan implementations")
436 (description "Mesa is a free implementation of the OpenGL and Vulkan
437specifications - systems for rendering interactive 3D graphics. A variety of
438device drivers allows Mesa to be used in many different environments ranging
439from software emulation to complete hardware acceleration for modern GPUs.")
584f2e1b 440 (license license:x11)))
7025a035 441
fae42942 442(define-public mesa-opencl
8ea91d05 443 (package/inherit mesa
fae42942
RW
444 (name "mesa-opencl")
445 (arguments
446 (substitute-keyword-arguments (package-arguments mesa)
447 ((#:configure-flags flags)
448 `(cons "-Dgallium-opencl=standalone" ,flags))))
449 (inputs
450 `(("libclc" ,libclc)
451 ,@(package-inputs mesa)))
452 (native-inputs
e634d959 453 `(("clang" ,clang-10)
fae42942
RW
454 ,@(package-native-inputs mesa)))))
455
37cb4e5b 456(define-public mesa-opencl-icd
8ea91d05 457 (package/inherit mesa-opencl
37cb4e5b
RW
458 (name "mesa-opencl-icd")
459 (arguments
460 (substitute-keyword-arguments (package-arguments mesa)
461 ((#:configure-flags flags)
462 `(cons "-Dgallium-opencl=icd"
463 ,(delete "-Dgallium-opencl=standalone" flags)))))))
464
b021a2ad 465(define-public mesa-headers
8ea91d05 466 (package/inherit mesa
b021a2ad
TUBK
467 (name "mesa-headers")
468 (propagated-inputs '())
469 (inputs '())
470 (native-inputs '())
cb475eaa 471 (outputs '("out"))
b021a2ad
TUBK
472 (arguments
473 '(#:phases
474 (modify-phases %standard-phases
f8503e2b
LC
475 (delete 'configure)
476 (delete 'build)
477 (delete 'check)
478 (replace 'install
51b491b0
MW
479 (lambda* (#:key outputs #:allow-other-keys)
480 (copy-recursively "include" (string-append
481 (assoc-ref outputs "out")
482 "/include"))
483 #t)))))))
b021a2ad 484
c90a50eb
TUBK
485;;; The mesa-demos distribution contains non-free files, many files with no
486;;; clear license information, and many demos that aren't useful for most
487;;; people, so we just use this for the mesa-utils package below, and possibly
488;;; other packages in the future. This is modeled after Debian's solution.
489(define (mesa-demos-source version)
490 (origin
491 (method url-fetch)
18cbba26 492 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/demos"
c90a50eb 493 "/mesa-demos-" version ".tar.bz2"))
18cbba26 494 (sha256 (base32 "0zgzbz55a14hz83gbmm0n9gpjnf5zadzi2kjjvkn6khql2a9rs81"))))
c90a50eb
TUBK
495
496(define-public mesa-utils
497 (package
498 (name "mesa-utils")
18cbba26 499 (version "8.4.0")
c90a50eb
TUBK
500 (source (mesa-demos-source version))
501 (build-system gnu-build-system)
502 (inputs
503 `(("mesa" ,mesa)
504 ("glut" ,freeglut)
505 ("glew" ,glew)))
506 (native-inputs
507 `(("pkg-config" ,pkg-config)))
508 (arguments
7fe3f8cf 509 '(#:phases
c90a50eb
TUBK
510 (modify-phases %standard-phases
511 (replace
f8503e2b 512 'install
c90a50eb
TUBK
513 (lambda* (#:key outputs #:allow-other-keys)
514 (let ((out (assoc-ref outputs "out")))
515 (mkdir-p (string-append out "/bin"))
516 (for-each
517 (lambda (file)
518 (copy-file file (string-append out "/bin/" (basename file))))
519 '("src/xdemos/glxdemo" "src/xdemos/glxgears"
feb08043
MW
520 "src/xdemos/glxinfo" "src/xdemos/glxheads"))
521 #t))))))
7c22aa63 522 (home-page "https://mesa3d.org/")
c90a50eb
TUBK
523 (synopsis "Utility tools for Mesa")
524 (description
525 "The mesa-utils package contains several utility tools for Mesa: glxdemo,
526glxgears, glxheads, and glxinfo.")
527 ;; glxdemo is public domain; others expat.
584f2e1b 528 (license (list license:expat license:public-domain))))
c90a50eb 529
524f4bec
LC
530(define-public glew
531 (package
532 (name "glew")
bbc94a08 533 (version "2.1.0")
524f4bec
LC
534 (source (origin
535 (method url-fetch)
de67e922
LF
536 (uri (string-append "mirror://sourceforge/glew/glew/" version
537 "/glew-" version ".tgz"))
524f4bec
LC
538 (sha256
539 (base32
bbc94a08 540 "159wk5dc0ykjbxvag5i1m2mhp23zkk6ra04l26y3jc3nwvkr3ph4"))
524f4bec
LC
541 (modules '((guix build utils)))
542 (snippet
6cbee49d
MW
543 '(begin
544 (substitute* "config/Makefile.linux"
545 (("= cc") "= gcc")
546 (("/lib64") "/lib"))
547 #t))))
524f4bec
LC
548 (build-system gnu-build-system)
549 (arguments
dc1d3cde 550 '(#:phases (modify-phases %standard-phases (delete 'configure))
524f4bec
LC
551 #:make-flags (list (string-append "GLEW_PREFIX="
552 (assoc-ref %outputs "out"))
553 (string-append "GLEW_DEST="
554 (assoc-ref %outputs "out")))
555 #:tests? #f)) ;no 'check' target
556 (inputs
557 `(("libxi" ,libxi)
558 ("libxmu" ,libxmu)
559 ("libx11" ,libx11)
560 ("mesa" ,mesa)))
561
562 ;; <GL/glew.h> includes <GL/glu.h>.
563 (propagated-inputs `(("glu" ,glu)))
564
565 (home-page "http://glew.sourceforge.net/")
566 (synopsis "OpenGL extension loading library for C and C++")
567 (description
568 "The OpenGL Extension Wrangler Library (GLEW) is a C/C++ extension
569loading library. GLEW provides efficient run-time mechanisms for determining
570which OpenGL extensions are supported on the target platform. OpenGL core and
571extension functionality is exposed in a single header file.")
584f2e1b 572 (license license:bsd-3)))
524f4bec 573
7025a035
DT
574(define-public guile-opengl
575 (package
576 (name "guile-opengl")
577 (version "0.1.0")
578 (source (origin
579 (method url-fetch)
580 (uri (string-append "mirror://gnu/guile-opengl/guile-opengl-"
581 version ".tar.gz"))
582 (sha256
583 (base32
584 "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim"))))
585 (build-system gnu-build-system)
586 (native-inputs `(("pkg-config" ,pkg-config)))
42994090 587 (inputs `(("guile" ,guile-2.2)
7025a035 588 ("mesa" ,mesa)
4becc792 589 ("glu" ,glu)
7025a035
DT
590 ("freeglut" ,freeglut)))
591 (arguments
0e215f49
DT
592 '(#:phases (modify-phases %standard-phases
593 (add-after 'configure 'patch-makefile
594 (lambda _
595 ;; Install compiled Guile files in the expected place.
596 (substitute* '("Makefile")
597 (("^godir = .*$")
598 "godir = $(moddir)\n"))))
599 (add-before 'build 'patch-dynamic-link
600 (lambda* (#:key inputs outputs #:allow-other-keys)
601 (define (dynamic-link-substitute file lib input)
602 (substitute* file
603 (("dynamic-link \"lib([a-zA-Z]+)\"" _ lib)
604 (string-append "dynamic-link \""
605 (assoc-ref inputs input)
606 "/lib/lib" lib "\""))))
607 ;; Replace dynamic-link calls for libGL, libGLU, and
608 ;; libglut with absolute paths to the store.
609 (dynamic-link-substitute "glx/runtime.scm" "GL" "mesa")
610 (dynamic-link-substitute "glu/runtime.scm" "GLU" "glu")
611 (dynamic-link-substitute "glut/runtime.scm" "glut"
612 "freeglut"))))))
cc7a5c71 613 (home-page "https://gnu.org/s/guile-opengl")
66672a45 614 (synopsis "Guile binding for the OpenGL graphics API")
7025a035 615 (description
66672a45
LC
616 "Guile-OpenGL is a library for Guile that provides bindings to the
617OpenGL graphics API.")
584f2e1b 618 (license license:lgpl3+)))
131ddf99 619
ad1edd03
RW
620(define-public guile3.0-opengl
621 (package
622 (inherit guile-opengl)
623 (name "guile3.0-opengl")
624 (arguments
625 (substitute-keyword-arguments (package-arguments guile-opengl)
626 ((#:phases phases)
627 `(modify-phases ,phases
628 (add-after 'unpack 'build-with-guile-3.0
629 (lambda _
630 (substitute* "configure"
631 (("_guile_versions_to_search=\"")
632 "_guile_versions_to_search=\"3.0 "))
633 #t))))))
634 (inputs
635 `(("guile" ,guile-3.0)
636 ("mesa" ,mesa)
637 ("glu" ,glu)
638 ("freeglut" ,freeglut)))))
639
131ddf99
AW
640(define-public libepoxy
641 (package
642 (name "libepoxy")
8d9d6adb 643 (version "1.5.4")
131ddf99
AW
644 (source (origin
645 (method url-fetch)
646 (uri (string-append
3d3d4014
EF
647 "https://github.com/anholt/libepoxy/releases/download/"
648 version "/libepoxy-" version ".tar.xz"))
131ddf99
AW
649 (sha256
650 (base32
8d9d6adb 651 "1ll9fach4v30dsyd47s5ial4gaiwihzr2afb77vxxzzy3mlcrlhb"))))
131ddf99 652 (arguments
9bbd52e5 653 `(#:phases
5f8dd6dc 654 (modify-phases %standard-phases
54d860cc 655 (delete 'bootstrap)
5f8dd6dc
EF
656 (add-before
657 'configure 'patch-paths
658 (lambda* (#:key inputs #:allow-other-keys)
659 (let ((python (assoc-ref inputs "python"))
660 (mesa (assoc-ref inputs "mesa")))
661 (substitute* "src/gen_dispatch.py"
662 (("/usr/bin/env python") python))
663 (substitute* (find-files "." "\\.[ch]$")
664 (("libGL.so.1") (string-append mesa "/lib/libGL.so.1"))
665 (("libEGL.so.1") (string-append mesa "/lib/libEGL.so.1")))
5f8dd6dc 666 #t))))))
54d860cc 667 (build-system meson-build-system)
131ddf99 668 (native-inputs
827dc629 669 `(("pkg-config" ,pkg-config)
131ddf99
AW
670 ("python" ,python)))
671 (inputs
672 `(("mesa" ,mesa)))
3d3d4014 673 (home-page "https://github.com/anholt/libepoxy/")
131ddf99
AW
674 (synopsis "A library for handling OpenGL function pointer management")
675 (description
676 "A library for handling OpenGL function pointer management.")
584f2e1b 677 (license license:x11)))
2b226af1 678
e7b2ac1c
MB
679(define-public libglvnd
680 (package
681 (name "libglvnd")
6018d1ee 682 (version "1.3.2")
e7b2ac1c
MB
683 (home-page "https://gitlab.freedesktop.org/glvnd/libglvnd")
684 (source (origin
685 (method git-fetch)
686 (uri (git-reference
687 (url home-page)
688 (commit (string-append "v" version))))
689 (file-name (git-file-name name version))
690 (sha256
691 (base32
6018d1ee 692 "10x7fgb114r4gikdg6flszl3kwzcb9y5qa7sj9936mk0zxhjaylz"))))
e7b2ac1c
MB
693 (build-system meson-build-system)
694 (arguments
695 '(#:configure-flags '("-Dx11=enabled")
696 #:phases (modify-phases %standard-phases
697 (add-after 'unpack 'disable-glx-tests
698 (lambda _
699 ;; This package is meant to be used alongside Mesa.
700 ;; To avoid a circular dependency, disable tests that
701 ;; require a running Xorg server.
702 (substitute* "tests/meson.build"
703 (("if with_glx")
704 "if false"))
705 #t)))))
706 (native-inputs
707 `(("pkg-config" ,pkg-config)))
708 (inputs
709 `(("libx11" ,libx11)
710 ("libxext" ,libxext)
711 ("xorgproto" ,xorgproto)))
712 (synopsis "Vendor-neutral OpenGL dispatch library")
713 (description
714 "libglvnd is a vendor-neutral dispatch layer for arbitrating OpenGL
715API calls between multiple vendors. It allows multiple drivers from
716different vendors to coexist on the same filesystem, and determines which
717vendor to dispatch each API call to at runtime.
718
719Both GLX and EGL are supported, in any combination with OpenGL and OpenGL ES.")
720 ;; libglvnd is available under a custom X11-style license, and incorporates
721 ;; code with various other licenses. See README.md for details.
722 (license (list (license:x11-style "file://README.md")
723 license:x11
724 license:expat))))
725
2b226af1
DT
726(define-public soil
727 (package
728 (name "soil")
729 (version "1.0.7")
730 (source (origin
731 (method url-fetch)
732 ;; No versioned archive available.
733 (uri "http://www.lonesock.net/files/soil.zip")
734 (sha256
735 (base32
736 "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52"))))
737 (build-system gnu-build-system)
738 (arguments
739 '(#:tests? #f ; no tests
740 #:phases (modify-phases %standard-phases
741 (delete 'configure)
742 (add-before 'build 'init-build
743 (lambda* (#:key outputs #:allow-other-keys)
744 (let ((out (assoc-ref outputs "out")))
745 (setenv "CFLAGS" "-fPIC") ; needed for shared library
746 ;; Use alternate Makefile
747 (copy-file "projects/makefile/alternate Makefile.txt"
748 "src/Makefile")
749 (chdir "src")
750 (substitute* '("Makefile")
751 (("INCLUDEDIR = /usr/include/SOIL")
752 (string-append "INCLUDEDIR = " out "/include/SOIL"))
753 (("LIBDIR = /usr/lib")
754 (string-append "LIBDIR = " out "/lib"))
755 ;; Remove these flags from 'install' commands.
756 (("-o root -g root") ""))))))))
757 (native-inputs
758 `(("unzip" ,unzip)))
759 (inputs
760 `(("mesa" ,mesa)))
c0f6eebb 761 (home-page "https://www.lonesock.net/soil.html")
2b226af1
DT
762 (synopsis "OpenGL texture loading library")
763 (description
764 "SOIL is a tiny C library used primarily for uploading textures into
765OpenGL.")
584f2e1b 766 (license license:public-domain)))
432360d7
DT
767
768(define-public glfw
769 (package
770 (name "glfw")
771 (version "3.2.1")
772 (source (origin
773 (method url-fetch)
774 (uri (string-append "https://github.com/glfw/glfw"
775 "/releases/download/" version
776 "/glfw-" version ".zip"))
777 (sha256
778 (base32
779 "09kk5yc1zhss9add8ryqrngrr16hdmc94rszgng135bhw09mxmdp"))))
780 (build-system cmake-build-system)
781 (arguments
782 '(#:tests? #f ; no test target
783 #:configure-flags '("-DBUILD_SHARED_LIBS=ON")))
784 (native-inputs
785 `(("doxygen" ,doxygen)
786 ("unzip" ,unzip)))
a966281f
LC
787 (propagated-inputs
788 `(("mesa" ,mesa) ;included in public headers
789
790 ;; These are in 'Requires.private' of 'glfw3.pc'.
432360d7
DT
791 ("libx11" ,libx11)
792 ("libxrandr" ,libxrandr)
793 ("libxinerama" ,libxinerama)
a966281f
LC
794 ("libxcursor" ,libxcursor)
795 ("libxxf86vm" ,libxxf86vm)))
c9938fa8 796 (home-page "https://www.glfw.org")
432360d7
DT
797 (synopsis "OpenGL application development library")
798 (description
799 "GLFW is a library for OpenGL, OpenGL ES and Vulkan development for
800desktop computers. It provides a simple API for creating windows, contexts
801and surfaces, receiving input and events.")
802 (license license:zlib)))
78acbcb5
RW
803
804(define-public nanovg-for-extempore
7bb0ba81
GL
805 (let ((version "0.7.1")
806 (revision "0")
807 (commit "3c60175fcc2e5fe305b04355cdce35d499c80310"))
808 (package
809 (name "nanovg-for-extempore")
810 (version (git-version version revision commit))
811 (source (origin
812 (method git-fetch)
813 (uri (git-reference
b0e7b699 814 (url "https://github.com/extemporelang/nanovg")
7bb0ba81
GL
815 (commit commit)))
816 (file-name (git-file-name name version))
817 (sha256
818 (base32
819 "0ddn3d3mxqn8hj9967v3pss7lz1wn08pcdnqzc118g7yjkq7hxzy"))))
820 (build-system cmake-build-system)
821 (arguments `(#:tests? #f)) ; no tests included
822 (inputs
823 `(("mesa" ,mesa)))
824 ;; Extempore refuses to build on architectures other than x86_64
825 (supported-systems '("x86_64-linux"))
826 (home-page "https://github.com/extemporelang/nanovg")
827 (synopsis "2D vector drawing library on top of OpenGL")
828 (description "NanoVG is small antialiased vector graphics rendering
78acbcb5
RW
829library for OpenGL. It has lean API modeled after HTML5 canvas API. It is
830aimed to be a practical and fun toolset for building scalable user interfaces
831and visualizations.")
7bb0ba81 832 (license license:zlib))))
725d8d2c
AI
833
834(define-public gl2ps
835 (package
836 (name "gl2ps")
52c463a9 837 (version "1.4.2")
725d8d2c
AI
838 (source
839 (origin
840 (method url-fetch)
841 (uri (string-append
842 "http://geuz.org/gl2ps/src/gl2ps-"
843 version ".tgz"))
844 (sha256
52c463a9 845 (base32 "1sgzv547h7hrskb9qd0x5yp45kmhvibjwj2mfswv95lg070h074d"))))
725d8d2c
AI
846 (build-system cmake-build-system)
847 (inputs
848 `(("libpng" ,libpng)
849 ("mesa" ,mesa)
850 ("zlib" ,zlib)))
851 (arguments
52c463a9 852 `(#:tests? #f)) ; no tests
725d8d2c
AI
853 (home-page "http://www.geuz.org/gl2ps/")
854 (synopsis "OpenGL to PostScript printing library")
855 (description "GL2PS is a C library providing high quality vector
856output for any OpenGL application. GL2PS uses sorting algorithms
857capable of handling intersecting and stretched polygons, as well as
858non-manifold objects. GL2PS provides many features including advanced
859smooth shading and text rendering, culling of invisible primitives and
860mixed vector/bitmap output.")
905d15e1 861 ;; GL2PS is dual-licenced and can be used under the terms of either.
725d8d2c
AI
862 (license (list license:lgpl2.0+
863 (license:fsf-free "http://www.geuz.org/gl2ps/COPYING.GL2PS"
864 "GPL-incompatible copyleft license")))))
d64f3439
RH
865
866(define-public virtualgl
867 (package
868 (name "virtualgl")
0cece1b5 869 (version "2.6.2")
d64f3439
RH
870 (source
871 (origin
bd7daf9c
RW
872 (method git-fetch)
873 (uri (git-reference
b0e7b699 874 (url "https://github.com/VirtualGL/virtualgl")
bd7daf9c
RW
875 (commit version)))
876 (file-name (git-file-name name version))
d64f3439 877 (sha256
0cece1b5 878 (base32 "0yyc553xsb5n0rx7jp9p4wdbd7md07b3qrkf3ssyjavqqg908qg9"))))
d64f3439 879 (arguments
c30fd002 880 `(#:tests? #f ; no tests are available
07b8ea84 881 #:configure-flags (list
c30fd002
TGR
882 (string-append "-DCMAKE_INSTALL_LIBDIR="
883 (assoc-ref %outputs "out") "/lib")
884 "-DVGL_USESSL=1"))) ; use OpenSSL
d64f3439
RH
885 (build-system cmake-build-system)
886 (inputs `(("glu" ,glu)
887 ("libjpeg-turbo" ,libjpeg-turbo)
c30fd002 888 ("libxtst" ,libxtst)
d64f3439
RH
889 ("mesa" ,mesa)
890 ("openssl" ,openssl)))
c695fb76 891 (native-inputs `(("pkg-config" ,pkg-config)))
d64f3439
RH
892 (home-page "https://www.virtualgl.org")
893 (synopsis "Redirects 3D commands from an OpenGL application onto a 3D
894graphics card")
895 (description "VirtualGL redirects the 3D rendering commands from OpenGL
896applications to 3D accelerator hardware in a dedicated server and displays the
897rendered output interactively to a thin client located elsewhere on the
898network.")
899 (license license:wxwindows3.1+)))
5c154738
PN
900
901(define-public mojoshader
902 (let ((changeset "5887634ea695"))
903 (package
904 (name "mojoshader")
3429f5d9 905 (version (string-append "20190825" "-" changeset))
5c154738
PN
906 (source
907 (origin
908 (method hg-fetch)
909 (uri (hg-reference
910 (url "https://hg.icculus.org/icculus/mojoshader/")
911 (changeset changeset)))
912 (file-name (git-file-name name version))
913 (sha256
914 (base32 "0ibl4z1696jiifv9j5drir7jm0b5px0vwkwckbi7cfd46p7p6wcy"))))
915 (arguments
916 ;; Tests only for COMPILER_SUPPORT=ON.
917 `(#:tests? #f
3429f5d9
PN
918 #:configure-flags '("-DBUILD_SHARED=ON"
919 "-DFLIP_VIEWPORT=ON"
920 "-DDEPTH_CLIPPING=ON")
5c154738
PN
921 #:phases
922 (modify-phases %standard-phases
923 (replace 'install
924 (lambda* (#:key outputs #:allow-other-keys)
925 (let* ((out (assoc-ref outputs "out"))
926 (lib (string-append out "/lib"))
927 (header (string-append out "/include")))
928 (install-file "libmojoshader.so" lib)
929 (for-each (lambda (f)
930 (install-file f header))
931 (find-files "../source" "mojoshader.*\\.h$"))
932 (let ((profiles-header (string-append header "/profiles")))
933 (mkdir-p profiles-header)
934 (rename-file (string-append header "/mojoshader_profile.h")
935 (string-append profiles-header "/mojoshader_profile.h"))))
936 #t)))))
937 (build-system cmake-build-system)
938 (home-page "https://www.icculus.org/mojoshader/")
939 (synopsis "Work with Direct3D shaders on alternate 3D APIs")
940 (description "MojoShader is a library to work with Direct3D shaders on
941alternate 3D APIs and non-Windows platforms. The primary motivation is moving
942shaders to OpenGL languages on the fly. The developer deals with \"profiles\"
943that represent various target languages, such as GLSL or ARB_*_program.
944
945This allows a developer to manage one set of shaders, presumably written in
946Direct3D HLSL, and use them across multiple rendering backends. This also
947means that the developer only has to worry about one (offline) compiler to
948manage program complexity, while MojoShader itself deals with the reduced
949complexity of the bytecode at runtime.
950
951MojoShader provides both a simple API to convert bytecode to various profiles,
952and (optionally) basic glue to rendering APIs to abstract the management of
953the shaders at runtime.")
954 (license license:zlib))))
b150e83b
PN
955
956(define-public mojoshader-with-viewport-flip
957 ;; Changeset c586d4590241 replaced glProgramViewportFlip with
958 ;; glProgramViewportInfo.
959 ;; https://hg.icculus.org/icculus/mojoshader/rev/c586d4590241
960 (let ((changeset "2e37299b13d8"))
961 (package
962 (inherit mojoshader)
963 (name "mojoshader-with-viewport-flip")
964 (version (string-append "20190725" "-" changeset))
965 (source
966 (origin
967 (method hg-fetch)
968 (uri (hg-reference
969 (url "https://hg.icculus.org/icculus/mojoshader/")
970 (changeset changeset)))
971 (file-name (git-file-name name version))
972 (sha256
973 (base32 "0ffws7cqbskxwc3hjsnnzq4r2bbf008kdr3b11pa3kr7dsi50y6i"))))
974 (synopsis "Work with Direct3D shaders on alternate 3D APIs (with viewport flip)")
975 (description "This is the last version of the mojoshader library with
976the glProgramViewportFlip before it was replaced with glProgramViewportInfo.")
977 (license license:zlib))))
bea58fa1
PN
978
979(define-public mojoshader-cs
980 (let ((commit "10d0dba21ff1cfe332eb7de328a2adce01286bd7"))
981 (package
982 (name "mojoshader-cs")
983 (version (git-version "20191205" "1" commit))
984 (source (origin
985 (method git-fetch)
986 (uri (git-reference
987 (url "https://github.com/FNA-XNA/MojoShader")
988 (commit commit)))
989 (file-name (git-file-name name version))
990 (sha256
991 (base32
992 "11mdhf3fmb9rsn2iv753gmb596j4dh5j2iipgw078vg0lj23rml7"))))
993 (build-system gnu-build-system)
994 (arguments
995 '(#:tests? #f ; No tests.
996 #:phases
997 (modify-phases %standard-phases
998 (delete 'configure)
999 (replace 'build
1000 (lambda _
1001 (invoke "make" "-C" "csharp")))
1002 (replace 'install
1003 (lambda* (#:key outputs #:allow-other-keys)
1004 (let ((out (assoc-ref outputs "out")))
1005 (install-file "csharp/bin/MojoShader-CS.dll" (string-append out "/lib"))
1006 #t))))))
1007 (native-inputs
1008 `(("mono" ,mono)))
1009 (home-page "https://github.com/FNA-XNA/MojoShader")
1010 (synopsis "C# wrapper for MojoShader")
1011 (description
1012 "Mojoshader-CS provides C# bindings for the Mojoshader library.
1013The C# wrapper was written to be used for FNA's platform support. However, this
1014is written in a way that can be used for any general C# application.")
1015 (license license:zlib))))