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 flex)
34 #:use-module (gnu packages fontutils)
35 #:use-module (gnu packages freedesktop)
36 #:use-module (gnu packages gettext)
37 #:use-module (gnu packages guile)
38 #:use-module (gnu packages image)
39 #:use-module (gnu packages linux)
40 #:use-module (gnu packages llvm)
41 #:use-module (gnu packages pkg-config)
42 #:use-module (gnu packages python)
43 #:use-module (gnu packages video)
44 #:use-module (gnu packages xdisorg)
45 #:use-module (gnu packages xml)
46 #:use-module (gnu packages xorg)
47 #:use-module (guix download)
48 #:use-module (guix build utils)
49 #:use-module (guix build-system gnu)
50 #:use-module (guix build-system cmake)
51 #:use-module ((guix licenses) #:prefix license:)
52 #:use-module (guix packages)
53 #:use-module (guix utils)
54 #:use-module (ice-9 match))
62 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/glu/glu-"
66 "0r72yyhj09x3krn3kn629jqbwyq50ji8w5ri2pn6zwrk35m4g1s3"))))
67 (build-system gnu-build-system)
69 `(("mesa" ,mesa))) ; according to glu.pc
70 (home-page "http://www.opengl.org/archives/resources/faq/technical/glu.htm")
71 (synopsis "Mesa OpenGL Utility library")
73 "GLU, or OpenGL Utility Library provides some higher-level functionality
74 not provided by just OpenGL itself. Some of GLU's Features
75 include: Scaling of 2D images and creation of mipmap pyramids,
76 Transformation of object coordinates into device coordinates and
77 vice versa, Support for NURBS surfaces, Support for tessellation
78 of concave or bow tie polygonal primitives, Specialty transformation
79 matrices for creating perspective and orthographic projections,
80 positioning a camera, and selection/picking, Rendering of disk,
81 cylinder, and sphere primitives, Interpreting OpenGL error values
83 (license (license:x11-style "http://directory.fsf.org/wiki/License:SGIFreeBv2"))))
85 (define-public freeglut
92 "mirror://sourceforge/freeglut/freeglut/"
93 version "/freeglut-" version ".tar.gz"))
96 "18knkyczzwbmyg8hr4zh8a1i5ga01np2jzd1rwmsh7mh2n2vwhra"))))
97 (build-system cmake-build-system)
98 (arguments '(#:tests? #f)) ; no test target
99 (inputs `(("mesa" ,mesa)
102 ("libxrandr" ,libxrandr)
103 ("libxxf86vm" ,libxxf86vm)
104 ("inputproto" ,inputproto)
107 ;; Headers from Mesa and GLU are needed.
110 (home-page "http://freeglut.sourceforge.net/")
111 (synopsis "Alternative to the OpenGL Utility Toolkit (GLUT)")
113 "Freeglut is a completely Free/OpenSourced alternative to
114 the OpenGL Utility Toolkit (GLUT) library. GLUT was originally
115 written by Mark Kilgard to support the sample programs in the
116 second edition OpenGL 'RedBook'. Since then, GLUT has been used
117 in a wide variety of practical applications because it is simple,
118 widely available and highly portable.
120 GLUT (and hence freeglut) allows the user to create and manage windows
121 containing OpenGL contexts on a wide range of platforms and also read
122 the mouse, keyboard and joystick functions. Freeglut is released under
123 the X-Consortium license.")
124 (license license:x11)))
126 ;; Needed for "kiki".
127 (define-public freeglut-2.8
128 (package (inherit freeglut)
134 "mirror://sourceforge/freeglut/freeglut/"
135 version "/freeglut-" version ".tar.gz"))
138 "16lrxxxd9ps9l69y3zsw6iy0drwjsp6m26d1937xj71alqk6dr6x"))))
139 (build-system gnu-build-system)))
144 (version "2.1.3-rc5")
148 "mirror://sourceforge/ftgl/FTGL%20Source/2.1.3~rc5/"
149 "ftgl-" version ".tar.gz"))
152 "0nsn4s6vnv5xcgxcw6q031amvh2zfj2smy1r5mbnjj2548hxcn2l"))))
153 (build-system gnu-build-system)
154 ;; The pkg-config file lists "freetype2" as Requires.private.
155 (propagated-inputs `(("freetype" ,freetype)))
156 (inputs `(("libx11" ,libx11)
159 (home-page "http://ftgl.sourceforge.net")
160 (synopsis "Font rendering library for OpenGL applications")
162 "FTGL is a font rendering library for OpenGL applications. Supported
163 rendering modes are: Bitmaps, Anti-aliased pixmaps, Texture maps, Outlines,
164 Polygon meshes, and Extruded polygon meshes.")
165 (license license:x11)))
175 "https://github.com/divVerent/s2tc/archive/v" version ".tar.gz"))
177 (base32 "0ibfdib277fhbqvxzan0bmglwnsl1y1rw2g8skvz82l1sfmmn752"))
178 (file-name (string-append name "-" version ".tar.gz"))))
179 (build-system gnu-build-system)
181 `(("autoconf" ,autoconf)
182 ("automake" ,automake)
183 ("libtool" ,libtool)))
185 `(("mesa-headers" ,mesa-headers)))
188 (modify-phases %standard-phases
189 (add-after 'unpack 'autogen
191 (zero? (system* "sh" "autogen.sh")))))))
192 (home-page "https://github.com/divVerent/s2tc")
193 (synopsis "S3 Texture Compression implementation")
195 "S2TC is a patent-free implementation of S3 Texture Compression (S3TC,
196 also known as DXTn or DXTC) for Mesa.")
197 (license license:expat)))
199 ;;; Mesa needs LibVA headers to build its Gallium-based VA API implementation;
200 ;;; LibVA itself depends on Mesa. We use the following to solve the circular
202 (define libva-without-mesa
203 ;; Delay to work around circular import problem.
207 (name "libva-without-mesa")
208 (inputs (alist-delete "mesa" (package-inputs libva)))
210 (strip-keyword-arguments
212 (substitute-keyword-arguments (package-arguments libva)
213 ((#:configure-flags flags)
214 '(list "--disable-glx" "--disable-egl"))))))))
223 (uri (list (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
224 "mesa-" version ".tar.xz")
225 (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
226 version "/mesa-" version ".tar.xz")))
229 "17d60jjzg4ddm95gk2cqx0xz6b9anmmz6ax4majwr3gis2yg7v49"))
231 (search-patches "mesa-fix-32bit-test-failures.patch"
232 "mesa-wayland-egl-symbols-check-mips.patch"
233 "mesa-skip-disk-cache-test.patch"))))
234 (build-system gnu-build-system)
236 `(("glproto" ,glproto)
237 ;; The following are in the Requires.private field of gl.pc.
239 ("libvdpau" ,libvdpau)
241 ("libxdamage" ,libxdamage)
242 ("libxfixes" ,libxfixes)
243 ("libxshmfence" ,libxshmfence)
244 ("libxxf86vm" ,libxxf86vm)))
247 ("dri2proto" ,dri2proto)
248 ("dri3proto" ,dri3proto)
249 ("libva" ,(force libva-without-mesa))
251 ;; TODO: Add 'libxml2-python' for OpenGL ES 1.1 and 2.0 support
253 ,@(match (%current-system)
254 ((or "x86_64-linux" "i686-linux")
258 ("makedepend" ,makedepend)
259 ("presentproto" ,presentproto)
261 ("wayland" ,wayland)))
263 `(("pkg-config" ,pkg-config)
264 ("python" ,python-2)))
267 '(,@(match (%current-system)
268 ((or "armhf-linux" "aarch64-linux")
269 '("--with-gallium-drivers=freedreno,nouveau,r300,r600,svga,swrast,vc4,virgl"))
271 '("--with-gallium-drivers=i915,nouveau,r300,r600,svga,swrast,virgl")))
272 ;; Enable various optional features. TODO: opencl requires libclc,
273 ;; omx requires libomxil-bellagio
274 "--with-egl-platforms=x11,drm,wayland"
275 "--enable-glx-tls" ;Thread Local Storage, improves performance
280 ;; features required by wayland
283 "--enable-shared-glapi"
284 ;; Without floating point texture support, drivers such as Nouveau
285 ;; are stuck at OpenGL 2.1 instead of OpenGL 3.0+.
286 "--enable-texture-float"
288 ;; Also enable the tests.
289 "--enable-gallium-tests"
291 ;; on non-intel systems, drop i915 and i965
292 ;; from the default dri drivers
293 ,@(match (%current-system)
294 ((or "x86_64-linux" "i686-linux")
295 '("--with-dri-drivers=i915,i965,nouveau,r200,radeon,swrast"
296 "--enable-gallium-llvm")) ; default is x86/x86_64 only
298 '("--with-dri-drivers=nouveau,r200,radeon,swrast"))))
300 (modify-phases %standard-phases
302 'unpack 'patch-create_test_cases
304 (substitute* "src/compiler/glsl/tests/lower_jumps/create_test_cases.py"
305 (("/usr/bin/env bash") (which "bash")))
306 (substitute* "src/intel/genxml/gen_pack_header.py"
307 (("/usr/bin/env python2") (which "python")))
310 'build 'fix-dlopen-libnames
311 (lambda* (#:key inputs outputs #:allow-other-keys)
312 (let ((s2tc (assoc-ref inputs "s2tc"))
313 (out (assoc-ref outputs "out")))
314 ;; Remain agnostic to .so.X.Y.Z versions while doing
315 ;; the substitutions so we're future-safe.
317 '("src/gallium/auxiliary/util/u_format_s3tc.c"
318 "src/mesa/main/texcompress_s3tc.c")
319 (("\"libtxc_dxtn\\.so")
320 (string-append "\"" s2tc "/lib/libtxc_dxtn.so")))
321 (substitute* "src/glx/dri_common.c"
322 (("dlopen\\(\"libGL\\.so")
323 (string-append "dlopen(\"" out "/lib/libGL.so")))
324 (substitute* "src/egl/drivers/dri2/egl_dri2.c"
326 (string-append "\"" out "/lib/libglapi.so")))
327 (substitute* "src/gbm/main/backend.c"
328 ;; No need to patch the gbm_gallium_drm.so reference;
329 ;; it's never installed since Mesa removed its
330 ;; egl_gallium support.
332 (string-append "\"" out "/lib/dri/gbm_dri.so")))
334 (home-page "https://mesa3d.org/")
335 (synopsis "OpenGL implementation")
336 (description "Mesa is a free implementation of the OpenGL specification -
337 a system for rendering interactive 3D graphics. A variety of device drivers
338 allows Mesa to be used in many different environments ranging from software
339 emulation to complete hardware acceleration for modern GPUs.")
340 (license license:x11)))
342 (define-public mesa-headers
345 (name "mesa-headers")
346 (propagated-inputs '())
351 (modify-phases %standard-phases
356 (lambda* (#:key outputs #:allow-other-keys)
357 (copy-recursively "include" (string-append
358 (assoc-ref outputs "out")
361 ;;; The mesa-demos distribution contains non-free files, many files with no
362 ;;; clear license information, and many demos that aren't useful for most
363 ;;; people, so we just use this for the mesa-utils package below, and possibly
364 ;;; other packages in the future. This is modeled after Debian's solution.
365 (define (mesa-demos-source version)
368 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/demos/" version
369 "/mesa-demos-" version ".tar.bz2"))
370 (sha256 (base32 "1vqb7s5m3fcg2csbiz45mha1pys2xx6rhw94fcyvapqdpm5iawy1"))))
372 (define-public mesa-utils
376 (source (mesa-demos-source version))
377 (build-system gnu-build-system)
383 `(("pkg-config" ,pkg-config)))
386 (modify-phases %standard-phases
389 (lambda* (#:key outputs #:allow-other-keys)
390 (let ((out (assoc-ref outputs "out")))
391 (mkdir-p (string-append out "/bin"))
394 (copy-file file (string-append out "/bin/" (basename file))))
395 '("src/xdemos/glxdemo" "src/xdemos/glxgears"
396 "src/xdemos/glxinfo" "src/xdemos/glxheads"))))))))
397 (home-page "http://mesa3d.org/")
398 (synopsis "Utility tools for Mesa")
400 "The mesa-utils package contains several utility tools for Mesa: glxdemo,
401 glxgears, glxheads, and glxinfo.")
402 ;; glxdemo is public domain; others expat.
403 (license (list license:expat license:public-domain))))
411 (uri (string-append "mirror://sourceforge/glew/glew/" version
412 "/glew-" version ".tgz"))
415 "0r37fg2s1f0jrvwh6c8cz5x6v4wqmhq42qm15cs9qs349q5c6wn5"))
416 (modules '((guix build utils)))
418 '(substitute* "config/Makefile.linux"
420 (("/lib64") "/lib")))))
421 (build-system gnu-build-system)
423 '(#:phases (alist-delete 'configure %standard-phases)
424 #:make-flags (list (string-append "GLEW_PREFIX="
425 (assoc-ref %outputs "out"))
426 (string-append "GLEW_DEST="
427 (assoc-ref %outputs "out")))
428 #:tests? #f)) ;no 'check' target
435 ;; <GL/glew.h> includes <GL/glu.h>.
436 (propagated-inputs `(("glu" ,glu)))
438 (home-page "http://glew.sourceforge.net/")
439 (synopsis "OpenGL extension loading library for C and C++")
441 "The OpenGL Extension Wrangler Library (GLEW) is a C/C++ extension
442 loading library. GLEW provides efficient run-time mechanisms for determining
443 which OpenGL extensions are supported on the target platform. OpenGL core and
444 extension functionality is exposed in a single header file.")
445 (license license:bsd-3)))
447 (define-public guile-opengl
449 (name "guile-opengl")
453 (uri (string-append "mirror://gnu/guile-opengl/guile-opengl-"
457 "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim"))))
458 (build-system gnu-build-system)
459 (native-inputs `(("pkg-config" ,pkg-config)))
460 (inputs `(("guile" ,guile-2.2)
463 ("freeglut" ,freeglut)))
465 '(#:phases (modify-phases %standard-phases
466 (add-after 'configure 'patch-makefile
468 ;; Install compiled Guile files in the expected place.
469 (substitute* '("Makefile")
471 "godir = $(moddir)\n"))))
472 (add-before 'build 'patch-dynamic-link
473 (lambda* (#:key inputs outputs #:allow-other-keys)
474 (define (dynamic-link-substitute file lib input)
476 (("dynamic-link \"lib([a-zA-Z]+)\"" _ lib)
477 (string-append "dynamic-link \""
478 (assoc-ref inputs input)
479 "/lib/lib" lib "\""))))
480 ;; Replace dynamic-link calls for libGL, libGLU, and
481 ;; libglut with absolute paths to the store.
482 (dynamic-link-substitute "glx/runtime.scm" "GL" "mesa")
483 (dynamic-link-substitute "glu/runtime.scm" "GLU" "glu")
484 (dynamic-link-substitute "glut/runtime.scm" "glut"
486 (home-page "https://gnu.org/s/guile-opengl")
487 (synopsis "Guile binding for the OpenGL graphics API")
489 "Guile-OpenGL is a library for Guile that provides bindings to the
490 OpenGL graphics API.")
491 (license license:lgpl3+)))
493 (define-public libepoxy
500 "https://github.com/anholt/libepoxy/releases/download/"
501 version "/libepoxy-" version ".tar.xz"))
504 "19hsyap2p0sflj75ycf4af9bsp453bamymbcgnmrphigabsspil8"))))
507 (modify-phases %standard-phases
509 'configure 'patch-paths
510 (lambda* (#:key inputs #:allow-other-keys)
511 (let ((python (assoc-ref inputs "python"))
512 (mesa (assoc-ref inputs "mesa")))
513 (substitute* "src/gen_dispatch.py"
514 (("/usr/bin/env python") python))
515 ;; Add support for aarch64, see upstream:
516 ;; https://github.com/anholt/libepoxy/pull/114
517 (substitute* "test/dlwrap.c"
518 (("GLIBC_2.4") "GLIBC_2.17\", \"GLIBC_2.4"))
519 (substitute* (find-files "." "\\.[ch]$")
520 (("libGL.so.1") (string-append mesa "/lib/libGL.so.1"))
521 (("libEGL.so.1") (string-append mesa "/lib/libEGL.so.1")))
523 (build-system gnu-build-system)
525 `(("pkg-config" ,pkg-config)
529 (home-page "https://github.com/anholt/libepoxy/")
530 (synopsis "A library for handling OpenGL function pointer management")
532 "A library for handling OpenGL function pointer management.")
533 (license license:x11)))
541 ;; No versioned archive available.
542 (uri "http://www.lonesock.net/files/soil.zip")
545 "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52"))))
546 (build-system gnu-build-system)
548 '(#:tests? #f ; no tests
549 #:phases (modify-phases %standard-phases
551 (add-before 'build 'init-build
552 (lambda* (#:key outputs #:allow-other-keys)
553 (let ((out (assoc-ref outputs "out")))
554 (setenv "CFLAGS" "-fPIC") ; needed for shared library
555 ;; Use alternate Makefile
556 (copy-file "projects/makefile/alternate Makefile.txt"
559 (substitute* '("Makefile")
560 (("INCLUDEDIR = /usr/include/SOIL")
561 (string-append "INCLUDEDIR = " out "/include/SOIL"))
562 (("LIBDIR = /usr/lib")
563 (string-append "LIBDIR = " out "/lib"))
564 ;; Remove these flags from 'install' commands.
565 (("-o root -g root") ""))))))))
570 (home-page "http://www.lonesock.net/soil.html")
571 (synopsis "OpenGL texture loading library")
573 "SOIL is a tiny C library used primarily for uploading textures into
575 (license license:public-domain)))
583 (uri (string-append "https://github.com/glfw/glfw"
584 "/releases/download/" version
585 "/glfw-" version ".zip"))
588 "09kk5yc1zhss9add8ryqrngrr16hdmc94rszgng135bhw09mxmdp"))))
589 (build-system cmake-build-system)
591 '(#:tests? #f ; no test target
592 #:configure-flags '("-DBUILD_SHARED_LIBS=ON")))
594 `(("doxygen" ,doxygen)
597 `(("mesa" ,mesa) ;included in public headers
599 ;; These are in 'Requires.private' of 'glfw3.pc'.
601 ("libxrandr" ,libxrandr)
602 ("libxinerama" ,libxinerama)
603 ("libxcursor" ,libxcursor)
604 ("libxxf86vm" ,libxxf86vm)))
605 (home-page "http://www.glfw.org")
606 (synopsis "OpenGL application development library")
608 "GLFW is a library for OpenGL, OpenGL ES and Vulkan development for
609 desktop computers. It provides a simple API for creating windows, contexts
610 and surfaces, receiving input and events.")
611 (license license:zlib)))
613 (define-public nanovg-for-extempore
615 (name "nanovg-for-extempore")
619 (uri (string-append "https://github.com/extemporelang/nanovg/"
620 "archive/" version ".tar.gz"))
621 (file-name (string-append name "-" version ".tar.gz"))
624 "0ivs1sagq19xiw8jxd9f8w2b39svi0n9hrbmdvckwvqg95r8701g"))))
625 (build-system cmake-build-system)
626 (arguments `(#:tests? #f)) ; no tests included
629 ;; Extempore refuses to build on architectures other than x86_64
630 (supported-systems '("x86_64-linux"))
631 (home-page "https://github.com/extemporelang/nanovg")
632 (synopsis "2D vector drawing library on top of OpenGL")
633 (description "NanoVG is small antialiased vector graphics rendering
634 library for OpenGL. It has lean API modeled after HTML5 canvas API. It is
635 aimed to be a practical and fun toolset for building scalable user interfaces
636 and visualizations.")
637 (license license:zlib)))
647 "http://geuz.org/gl2ps/src/gl2ps-"
651 "0h1nrhmkc4qjw2ninwpj2zbgwhc0qg6pdhpsibbvry0d2bzhns4a"))))
652 (build-system cmake-build-system)
658 `(#:tests? #f)) ;; no tests
659 (home-page "http://www.geuz.org/gl2ps/")
660 (synopsis "OpenGL to PostScript printing library")
661 (description "GL2PS is a C library providing high quality vector
662 output for any OpenGL application. GL2PS uses sorting algorithms
663 capable of handling intersecting and stretched polygons, as well as
664 non-manifold objects. GL2PS provides many features including advanced
665 smooth shading and text rendering, culling of invisible primitives and
666 mixed vector/bitmap output.")
667 (license (list license:lgpl2.0+
668 (license:fsf-free "http://www.geuz.org/gl2ps/COPYING.GL2PS"
669 "GPL-incompatible copyleft license")))))