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@we.make.ritual.n0.is>
7 ;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
8 ;;; Copyright © 2016 David Thompson <davet@gnu.org>
9 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
10 ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
12 ;;; This file is part of GNU Guix.
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27 (define-module (gnu packages gl)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages autotools)
30 #:use-module (gnu packages bison)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages documentation)
33 #:use-module (gnu packages elf)
34 #:use-module (gnu packages flex)
35 #:use-module (gnu packages fontutils)
36 #:use-module (gnu packages freedesktop)
37 #:use-module (gnu packages gettext)
38 #:use-module (gnu packages guile)
39 #:use-module (gnu packages image)
40 #:use-module (gnu packages linux)
41 #:use-module (gnu packages llvm)
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages python)
44 #:use-module (gnu packages video)
45 #:use-module (gnu packages xdisorg)
46 #:use-module (gnu packages xml)
47 #:use-module (gnu packages xorg)
48 #:use-module (guix download)
49 #:use-module (guix build utils)
50 #:use-module (guix build-system gnu)
51 #:use-module (guix build-system cmake)
52 #:use-module ((guix licenses) #:prefix license:)
53 #:use-module (guix packages)
54 #:use-module (guix utils)
55 #:use-module (ice-9 match))
63 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/glu/glu-"
67 "0r72yyhj09x3krn3kn629jqbwyq50ji8w5ri2pn6zwrk35m4g1s3"))))
68 (build-system gnu-build-system)
70 `(("mesa" ,mesa))) ; according to glu.pc
71 (home-page "http://www.opengl.org/archives/resources/faq/technical/glu.htm")
72 (synopsis "Mesa OpenGL Utility library")
74 "GLU, or OpenGL Utility Library provides some higher-level functionality
75 not provided by just OpenGL itself. Some of GLU's Features
76 include: Scaling of 2D images and creation of mipmap pyramids,
77 Transformation of object coordinates into device coordinates and
78 vice versa, Support for NURBS surfaces, Support for tessellation
79 of concave or bow tie polygonal primitives, Specialty transformation
80 matrices for creating perspective and orthographic projections,
81 positioning a camera, and selection/picking, Rendering of disk,
82 cylinder, and sphere primitives, Interpreting OpenGL error values
84 (license (license:x11-style "http://directory.fsf.org/wiki/License:SGIFreeBv2"))))
86 (define-public freeglut
93 "mirror://sourceforge/freeglut/freeglut/"
94 version "/freeglut-" version ".tar.gz"))
97 "18knkyczzwbmyg8hr4zh8a1i5ga01np2jzd1rwmsh7mh2n2vwhra"))))
98 (build-system cmake-build-system)
99 (arguments '(#:tests? #f)) ; no test target
100 (inputs `(("mesa" ,mesa)
103 ("libxrandr" ,libxrandr)
104 ("libxxf86vm" ,libxxf86vm)
105 ("inputproto" ,inputproto)
108 ;; Headers from Mesa and GLU are needed.
111 (home-page "http://freeglut.sourceforge.net/")
112 (synopsis "Alternative to the OpenGL Utility Toolkit (GLUT)")
114 "Freeglut is a completely Free/OpenSourced alternative to
115 the OpenGL Utility Toolkit (GLUT) library. GLUT was originally
116 written by Mark Kilgard to support the sample programs in the
117 second edition OpenGL 'RedBook'. Since then, GLUT has been used
118 in a wide variety of practical applications because it is simple,
119 widely available and highly portable.
121 GLUT (and hence freeglut) allows the user to create and manage windows
122 containing OpenGL contexts on a wide range of platforms and also read
123 the mouse, keyboard and joystick functions. Freeglut is released under
124 the X-Consortium license.")
125 (license license:x11)))
127 ;; Needed for "kiki".
128 (define-public freeglut-2.8
129 (package (inherit freeglut)
135 "mirror://sourceforge/freeglut/freeglut/"
136 version "/freeglut-" version ".tar.gz"))
139 "16lrxxxd9ps9l69y3zsw6iy0drwjsp6m26d1937xj71alqk6dr6x"))))
140 (build-system gnu-build-system)))
145 (version "2.1.3-rc5")
149 "mirror://sourceforge/ftgl/FTGL%20Source/2.1.3~rc5/"
150 "ftgl-" version ".tar.gz"))
153 "0nsn4s6vnv5xcgxcw6q031amvh2zfj2smy1r5mbnjj2548hxcn2l"))))
154 (build-system gnu-build-system)
155 ;; The pkg-config file lists "freetype2" as Requires.private.
156 (propagated-inputs `(("freetype" ,freetype)))
157 (inputs `(("libx11" ,libx11)
160 (home-page "http://ftgl.sourceforge.net")
161 (synopsis "Font rendering library for OpenGL applications")
163 "FTGL is a font rendering library for OpenGL applications. Supported
164 rendering modes are: Bitmaps, Anti-aliased pixmaps, Texture maps, Outlines,
165 Polygon meshes, and Extruded polygon meshes.")
166 (license license:x11)))
176 "https://github.com/divVerent/s2tc/archive/v" version ".tar.gz"))
178 (base32 "0ibfdib277fhbqvxzan0bmglwnsl1y1rw2g8skvz82l1sfmmn752"))
179 (file-name (string-append name "-" version ".tar.gz"))))
180 (build-system gnu-build-system)
182 `(("autoconf" ,autoconf)
183 ("automake" ,automake)
184 ("libtool" ,libtool)))
186 `(("mesa-headers" ,mesa-headers)))
189 (modify-phases %standard-phases
190 (add-after 'unpack 'autogen
192 (zero? (system* "sh" "autogen.sh")))))))
193 (home-page "https://github.com/divVerent/s2tc")
194 (synopsis "S3 Texture Compression implementation")
196 "S2TC is a patent-free implementation of S3 Texture Compression (S3TC,
197 also known as DXTn or DXTC) for Mesa.")
198 (license license:expat)))
200 ;;; Mesa needs LibVA headers to build its Gallium-based VA API implementation;
201 ;;; LibVA itself depends on Mesa. We use the following to solve the circular
203 (define libva-without-mesa
204 ;; Delay to work around circular import problem.
208 (name "libva-without-mesa")
209 (inputs (alist-delete "mesa" (package-inputs libva)))
211 (strip-keyword-arguments
213 (substitute-keyword-arguments (package-arguments libva)
214 ((#:configure-flags flags)
215 '(list "--disable-glx" "--disable-egl"))))))))
224 (uri (list (string-append "https://mesa.freedesktop.org/archive/"
225 "mesa-" version ".tar.xz")
226 (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
227 "mesa-" version ".tar.xz")
228 (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
229 version "/mesa-" version ".tar.xz")))
232 "07msr6xismw2jq87irwhz7vygvzj6hi38d71paij9zvwh8bmsf3p"))
234 (search-patches "mesa-wayland-egl-symbols-check-mips.patch"
235 "mesa-skip-disk-cache-test.patch"))))
236 (build-system gnu-build-system)
238 `(("glproto" ,glproto)
239 ;; The following are in the Requires.private field of gl.pc.
241 ("libvdpau" ,libvdpau)
243 ("libxdamage" ,libxdamage)
244 ("libxfixes" ,libxfixes)
245 ("libxshmfence" ,libxshmfence)
246 ("libxxf86vm" ,libxxf86vm)))
249 ("dri2proto" ,dri2proto)
250 ("dri3proto" ,dri3proto)
251 ("libelf" ,libelf) ;required for r600 when using llvm
252 ("libva" ,(force libva-without-mesa))
254 ;; TODO: Add 'libxml2-python' for OpenGL ES 1.1 and 2.0 support
256 ,@(match (%current-system)
257 ((or "x86_64-linux" "i686-linux")
258 `(("llvm" ,llvm-3.9.1))) ; exactly 3.9.0 or 3.9.1 for swrast
261 ("makedepend" ,makedepend)
262 ("presentproto" ,presentproto)
265 ("wayland-protocols" ,wayland-protocols)))
267 `(("pkg-config" ,pkg-config)
269 ("which" ,(@ (gnu packages base) which))))
272 '(,@(match (%current-system)
274 ;; TODO: Add etnaviv,imx when libdrm supports etnaviv.
275 '("--with-gallium-drivers=freedreno,nouveau,r300,r600,swrast,vc4,virgl"))
277 ;; TODO: Fix svga driver for aarch64 and armhf.
278 '("--with-gallium-drivers=freedreno,nouveau,r300,r600,swrast,vc4,virgl"))
280 '("--with-gallium-drivers=i915,nouveau,r300,r600,svga,swrast,virgl")))
281 ;; Enable various optional features. TODO: opencl requires libclc,
282 ;; omx requires libomxil-bellagio
283 "--with-platforms=x11,drm,wayland,surfaceless"
284 "--enable-glx-tls" ;Thread Local Storage, improves performance
289 ;; features required by wayland
292 "--enable-shared-glapi"
293 ;; Without floating point texture support, drivers such as Nouveau
294 ;; are stuck at OpenGL 2.1 instead of OpenGL 3.0+.
295 "--enable-texture-float"
297 ;; Also enable the tests.
298 "--enable-gallium-tests"
300 ;; on non-intel systems, drop i915 and i965
301 ;; from the default dri drivers
302 ,@(match (%current-system)
303 ((or "x86_64-linux" "i686-linux")
304 '("--with-dri-drivers=i915,i965,nouveau,r200,radeon,swrast"
305 "--enable-llvm")) ; default is x86/x86_64 only
307 '("--with-dri-drivers=nouveau,r200,radeon,swrast"))))
309 (modify-phases %standard-phases
311 'unpack 'patch-create_test_cases
313 (substitute* "src/compiler/glsl/tests/lower_jumps/create_test_cases.py"
314 (("/usr/bin/env bash") (which "bash")))
315 (substitute* "src/intel/genxml/gen_pack_header.py"
316 (("/usr/bin/env python2") (which "python")))
319 'build 'fix-dlopen-libnames
320 (lambda* (#:key inputs outputs #:allow-other-keys)
321 (let ((s2tc (assoc-ref inputs "s2tc"))
322 (out (assoc-ref outputs "out")))
323 ;; Remain agnostic to .so.X.Y.Z versions while doing
324 ;; the substitutions so we're future-safe.
326 '("src/gallium/auxiliary/util/u_format_s3tc.c"
327 "src/mesa/main/texcompress_s3tc.c")
328 (("\"libtxc_dxtn\\.so")
329 (string-append "\"" s2tc "/lib/libtxc_dxtn.so")))
330 (substitute* "src/glx/dri_common.c"
331 (("dlopen\\(\"libGL\\.so")
332 (string-append "dlopen(\"" out "/lib/libGL.so")))
333 (substitute* "src/egl/drivers/dri2/egl_dri2.c"
335 (string-append "\"" out "/lib/libglapi.so")))
336 (substitute* "src/gbm/main/backend.c"
337 ;; No need to patch the gbm_gallium_drm.so reference;
338 ;; it's never installed since Mesa removed its
339 ;; egl_gallium support.
341 (string-append "\"" out "/lib/dri/gbm_dri.so")))
343 (home-page "https://mesa3d.org/")
344 (synopsis "OpenGL implementation")
345 (description "Mesa is a free implementation of the OpenGL specification -
346 a system for rendering interactive 3D graphics. A variety of device drivers
347 allows Mesa to be used in many different environments ranging from software
348 emulation to complete hardware acceleration for modern GPUs.")
349 (license license:x11)))
351 (define-public mesa-headers
354 (name "mesa-headers")
355 (propagated-inputs '())
360 (modify-phases %standard-phases
365 (lambda* (#:key outputs #:allow-other-keys)
366 (copy-recursively "include" (string-append
367 (assoc-ref outputs "out")
370 ;;; The mesa-demos distribution contains non-free files, many files with no
371 ;;; clear license information, and many demos that aren't useful for most
372 ;;; people, so we just use this for the mesa-utils package below, and possibly
373 ;;; other packages in the future. This is modeled after Debian's solution.
374 (define (mesa-demos-source version)
377 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/demos/" version
378 "/mesa-demos-" version ".tar.bz2"))
379 (sha256 (base32 "1vqb7s5m3fcg2csbiz45mha1pys2xx6rhw94fcyvapqdpm5iawy1"))))
381 (define-public mesa-utils
385 (source (mesa-demos-source version))
386 (build-system gnu-build-system)
392 `(("pkg-config" ,pkg-config)))
395 (modify-phases %standard-phases
398 (lambda* (#:key outputs #:allow-other-keys)
399 (let ((out (assoc-ref outputs "out")))
400 (mkdir-p (string-append out "/bin"))
403 (copy-file file (string-append out "/bin/" (basename file))))
404 '("src/xdemos/glxdemo" "src/xdemos/glxgears"
405 "src/xdemos/glxinfo" "src/xdemos/glxheads"))))))))
406 (home-page "http://mesa3d.org/")
407 (synopsis "Utility tools for Mesa")
409 "The mesa-utils package contains several utility tools for Mesa: glxdemo,
410 glxgears, glxheads, and glxinfo.")
411 ;; glxdemo is public domain; others expat.
412 (license (list license:expat license:public-domain))))
420 (uri (string-append "mirror://sourceforge/glew/glew/" version
421 "/glew-" version ".tgz"))
424 "0r37fg2s1f0jrvwh6c8cz5x6v4wqmhq42qm15cs9qs349q5c6wn5"))
425 (modules '((guix build utils)))
427 '(substitute* "config/Makefile.linux"
429 (("/lib64") "/lib")))))
430 (build-system gnu-build-system)
432 '(#:phases (modify-phases %standard-phases (delete 'configure))
433 #:make-flags (list (string-append "GLEW_PREFIX="
434 (assoc-ref %outputs "out"))
435 (string-append "GLEW_DEST="
436 (assoc-ref %outputs "out")))
437 #:tests? #f)) ;no 'check' target
444 ;; <GL/glew.h> includes <GL/glu.h>.
445 (propagated-inputs `(("glu" ,glu)))
447 (home-page "http://glew.sourceforge.net/")
448 (synopsis "OpenGL extension loading library for C and C++")
450 "The OpenGL Extension Wrangler Library (GLEW) is a C/C++ extension
451 loading library. GLEW provides efficient run-time mechanisms for determining
452 which OpenGL extensions are supported on the target platform. OpenGL core and
453 extension functionality is exposed in a single header file.")
454 (license license:bsd-3)))
456 (define-public guile-opengl
458 (name "guile-opengl")
462 (uri (string-append "mirror://gnu/guile-opengl/guile-opengl-"
466 "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim"))))
467 (build-system gnu-build-system)
468 (native-inputs `(("pkg-config" ,pkg-config)))
469 (inputs `(("guile" ,guile-2.2)
472 ("freeglut" ,freeglut)))
474 '(#:phases (modify-phases %standard-phases
475 (add-after 'configure 'patch-makefile
477 ;; Install compiled Guile files in the expected place.
478 (substitute* '("Makefile")
480 "godir = $(moddir)\n"))))
481 (add-before 'build 'patch-dynamic-link
482 (lambda* (#:key inputs outputs #:allow-other-keys)
483 (define (dynamic-link-substitute file lib input)
485 (("dynamic-link \"lib([a-zA-Z]+)\"" _ lib)
486 (string-append "dynamic-link \""
487 (assoc-ref inputs input)
488 "/lib/lib" lib "\""))))
489 ;; Replace dynamic-link calls for libGL, libGLU, and
490 ;; libglut with absolute paths to the store.
491 (dynamic-link-substitute "glx/runtime.scm" "GL" "mesa")
492 (dynamic-link-substitute "glu/runtime.scm" "GLU" "glu")
493 (dynamic-link-substitute "glut/runtime.scm" "glut"
495 (home-page "https://gnu.org/s/guile-opengl")
496 (synopsis "Guile binding for the OpenGL graphics API")
498 "Guile-OpenGL is a library for Guile that provides bindings to the
499 OpenGL graphics API.")
500 (license license:lgpl3+)))
502 (define-public libepoxy
509 "https://github.com/anholt/libepoxy/releases/download/"
510 version "/libepoxy-" version ".tar.xz"))
513 "19hsyap2p0sflj75ycf4af9bsp453bamymbcgnmrphigabsspil8"))))
516 (modify-phases %standard-phases
518 'configure 'patch-paths
519 (lambda* (#:key inputs #:allow-other-keys)
520 (let ((python (assoc-ref inputs "python"))
521 (mesa (assoc-ref inputs "mesa")))
522 (substitute* "src/gen_dispatch.py"
523 (("/usr/bin/env python") python))
524 ;; Add support for aarch64, see upstream:
525 ;; https://github.com/anholt/libepoxy/pull/114
526 (substitute* "test/dlwrap.c"
527 (("GLIBC_2.4") "GLIBC_2.17\", \"GLIBC_2.4"))
528 (substitute* (find-files "." "\\.[ch]$")
529 (("libGL.so.1") (string-append mesa "/lib/libGL.so.1"))
530 (("libEGL.so.1") (string-append mesa "/lib/libEGL.so.1")))
532 (build-system gnu-build-system)
534 `(("pkg-config" ,pkg-config)
538 (home-page "https://github.com/anholt/libepoxy/")
539 (synopsis "A library for handling OpenGL function pointer management")
541 "A library for handling OpenGL function pointer management.")
542 (license license:x11)))
550 ;; No versioned archive available.
551 (uri "http://www.lonesock.net/files/soil.zip")
554 "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52"))))
555 (build-system gnu-build-system)
557 '(#:tests? #f ; no tests
558 #:phases (modify-phases %standard-phases
560 (add-before 'build 'init-build
561 (lambda* (#:key outputs #:allow-other-keys)
562 (let ((out (assoc-ref outputs "out")))
563 (setenv "CFLAGS" "-fPIC") ; needed for shared library
564 ;; Use alternate Makefile
565 (copy-file "projects/makefile/alternate Makefile.txt"
568 (substitute* '("Makefile")
569 (("INCLUDEDIR = /usr/include/SOIL")
570 (string-append "INCLUDEDIR = " out "/include/SOIL"))
571 (("LIBDIR = /usr/lib")
572 (string-append "LIBDIR = " out "/lib"))
573 ;; Remove these flags from 'install' commands.
574 (("-o root -g root") ""))))))))
579 (home-page "http://www.lonesock.net/soil.html")
580 (synopsis "OpenGL texture loading library")
582 "SOIL is a tiny C library used primarily for uploading textures into
584 (license license:public-domain)))
592 (uri (string-append "https://github.com/glfw/glfw"
593 "/releases/download/" version
594 "/glfw-" version ".zip"))
597 "09kk5yc1zhss9add8ryqrngrr16hdmc94rszgng135bhw09mxmdp"))))
598 (build-system cmake-build-system)
600 '(#:tests? #f ; no test target
601 #:configure-flags '("-DBUILD_SHARED_LIBS=ON")))
603 `(("doxygen" ,doxygen)
606 `(("mesa" ,mesa) ;included in public headers
608 ;; These are in 'Requires.private' of 'glfw3.pc'.
610 ("libxrandr" ,libxrandr)
611 ("libxinerama" ,libxinerama)
612 ("libxcursor" ,libxcursor)
613 ("libxxf86vm" ,libxxf86vm)))
614 (home-page "http://www.glfw.org")
615 (synopsis "OpenGL application development library")
617 "GLFW is a library for OpenGL, OpenGL ES and Vulkan development for
618 desktop computers. It provides a simple API for creating windows, contexts
619 and surfaces, receiving input and events.")
620 (license license:zlib)))
622 (define-public nanovg-for-extempore
624 (name "nanovg-for-extempore")
628 (uri (string-append "https://github.com/extemporelang/nanovg/"
629 "archive/" version ".tar.gz"))
630 (file-name (string-append name "-" version ".tar.gz"))
633 "0ivs1sagq19xiw8jxd9f8w2b39svi0n9hrbmdvckwvqg95r8701g"))))
634 (build-system cmake-build-system)
635 (arguments `(#:tests? #f)) ; no tests included
638 ;; Extempore refuses to build on architectures other than x86_64
639 (supported-systems '("x86_64-linux"))
640 (home-page "https://github.com/extemporelang/nanovg")
641 (synopsis "2D vector drawing library on top of OpenGL")
642 (description "NanoVG is small antialiased vector graphics rendering
643 library for OpenGL. It has lean API modeled after HTML5 canvas API. It is
644 aimed to be a practical and fun toolset for building scalable user interfaces
645 and visualizations.")
646 (license license:zlib)))
656 "http://geuz.org/gl2ps/src/gl2ps-"
660 "0h1nrhmkc4qjw2ninwpj2zbgwhc0qg6pdhpsibbvry0d2bzhns4a"))))
661 (build-system cmake-build-system)
667 `(#:tests? #f)) ;; no tests
668 (home-page "http://www.geuz.org/gl2ps/")
669 (synopsis "OpenGL to PostScript printing library")
670 (description "GL2PS is a C library providing high quality vector
671 output for any OpenGL application. GL2PS uses sorting algorithms
672 capable of handling intersecting and stretched polygons, as well as
673 non-manifold objects. GL2PS provides many features including advanced
674 smooth shading and text rendering, culling of invisible primitives and
675 mixed vector/bitmap output.")
676 (license (list license:lgpl2.0+
677 (license:fsf-free "http://www.geuz.org/gl2ps/COPYING.GL2PS"
678 "GPL-incompatible copyleft license")))))