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 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2016 ng0 <ng0@we.make.ritual.n0.is>
7 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu packages gl)
25 #:use-module (gnu packages)
26 #:use-module (gnu packages autotools)
27 #:use-module (gnu packages bison)
28 #:use-module (gnu packages documentation)
29 #:use-module (gnu packages flex)
30 #:use-module (gnu packages fontutils)
31 #:use-module (gnu packages freedesktop)
32 #:use-module (gnu packages gettext)
33 #:use-module (gnu packages guile)
34 #:use-module (gnu packages linux)
35 #:use-module (gnu packages pkg-config)
36 #:use-module (gnu packages python)
37 #:use-module (gnu packages video)
38 #:use-module (gnu packages xdisorg)
39 #:use-module (gnu packages xml)
40 #:use-module (gnu packages xorg)
41 #:use-module (gnu packages zip)
42 #:use-module (guix download)
43 #:use-module (guix build utils)
44 #:use-module (guix build-system gnu)
45 #:use-module (guix build-system cmake)
46 #:use-module ((guix licenses) #:prefix license:)
47 #:use-module (guix packages)
48 #:use-module (guix utils)
49 #:use-module (ice-9 match))
57 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/glu/glu-"
61 "0r72yyhj09x3krn3kn629jqbwyq50ji8w5ri2pn6zwrk35m4g1s3"))))
62 (build-system gnu-build-system)
64 `(("mesa" ,mesa))) ; according to glu.pc
65 (home-page "http://www.opengl.org/archives/resources/faq/technical/glu.htm")
66 (synopsis "Mesa OpenGL Utility library")
68 "GLU, or OpenGL Utility Library provides some higher-level functionality
69 not provided by just OpenGL itself. Some of GLU's Features
70 include: Scaling of 2D images and creation of mipmap pyramids,
71 Transformation of object coordinates into device coordinates and
72 vice versa, Support for NURBS surfaces, Support for tessellation
73 of concave or bow tie polygonal primitives, Specialty transformation
74 matrices for creating perspective and orthographic projections,
75 positioning a camera, and selection/picking, Rendering of disk,
76 cylinder, and sphere primitives, Interpreting OpenGL error values
78 (license (license:x11-style "http://directory.fsf.org/wiki/License:SGIFreeBv2"))))
80 (define-public freeglut
87 "mirror://sourceforge/freeglut/freeglut/"
88 version "/freeglut-" version ".tar.gz"))
91 "18knkyczzwbmyg8hr4zh8a1i5ga01np2jzd1rwmsh7mh2n2vwhra"))))
92 (build-system cmake-build-system)
93 (arguments '(#:tests? #f)) ; no test target
94 (inputs `(("mesa" ,mesa)
97 ("libxrandr" ,libxrandr)
98 ("libxxf86vm" ,libxxf86vm)
99 ("inputproto" ,inputproto)
102 ;; Headers from Mesa and GLU are needed.
105 (home-page "http://freeglut.sourceforge.net/")
106 (synopsis "Alternative to the OpenGL Utility Toolkit (GLUT)")
108 "Freeglut is a completely Free/OpenSourced alternative to
109 the OpenGL Utility Toolkit (GLUT) library. GLUT was originally
110 written by Mark Kilgard to support the sample programs in the
111 second edition OpenGL 'RedBook'. Since then, GLUT has been used
112 in a wide variety of practical applications because it is simple,
113 widely available and highly portable.
115 GLUT (and hence freeglut) allows the user to create and manage windows
116 containing OpenGL contexts on a wide range of platforms and also read
117 the mouse, keyboard and joystick functions. Freeglut is released under
118 the X-Consortium license.")
119 (license license:x11)))
124 (version "2.1.3-rc5")
128 "mirror://sourceforge/ftgl/FTGL%20Source/2.1.3~rc5/"
129 "ftgl-" version ".tar.gz"))
132 "0nsn4s6vnv5xcgxcw6q031amvh2zfj2smy1r5mbnjj2548hxcn2l"))))
133 (build-system gnu-build-system)
134 ;; The pkg-config file lists "freetype2" as Requires.private.
135 (propagated-inputs `(("freetype" ,freetype)))
136 (inputs `(("libx11" ,libx11)
139 (home-page "http://ftgl.sourceforge.net")
140 (synopsis "Font rendering library for OpenGL applications")
142 "FTGL is a font rendering library for OpenGL applications. Supported
143 rendering modes are: Bitmaps, Anti-aliased pixmaps, Texture maps, Outlines,
144 Polygon meshes, and Extruded polygon meshes.")
145 (license license:x11)))
155 "https://github.com/divVerent/s2tc/archive/v" version ".tar.gz"))
157 (base32 "0ibfdib277fhbqvxzan0bmglwnsl1y1rw2g8skvz82l1sfmmn752"))
158 (file-name (string-append name "-" version ".tar.gz"))))
159 (build-system gnu-build-system)
161 `(("autoconf" ,autoconf)
162 ("automake" ,automake)
163 ("libtool" ,libtool)))
165 `(("mesa-headers" ,mesa-headers)))
168 (modify-phases %standard-phases
169 (add-after 'unpack 'autogen
171 (zero? (system* "sh" "autogen.sh")))))))
172 (home-page "https://github.com/divVerent/s2tc")
173 (synopsis "S3 Texture Compression implementation")
175 "S2TC is a patent-free implementation of S3 Texture Compression (S3TC,
176 also known as DXTn or DXTC) for Mesa.")
177 (license license:expat)))
179 ;;; Mesa needs LibVA headers to build its Gallium-based VA API implementation;
180 ;;; LibVA itself depends on Mesa. We use the following to solve the circular
182 (define libva-without-mesa
183 ;; Delay to work around circular import problem.
187 (name "libva-without-mesa")
188 (inputs (alist-delete "mesa" (package-inputs libva)))
190 (strip-keyword-arguments
192 (substitute-keyword-arguments (package-arguments libva)
193 ((#:configure-flags flags)
194 '(list "--disable-glx" "--disable-egl"))))))))
203 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
204 version "/mesa-" version ".tar.xz"))
207 "1m8n8kd8kcs5ddyvldiw09wvpi5wwpfmmxlb87d63vgl8lk65vd6"))
209 (search-patches "mesa-wayland-egl-symbols-check-mips.patch"))))
210 (build-system gnu-build-system)
212 `(("glproto" ,glproto)
213 ;; The following are in the Requires.private field of gl.pc.
215 ("libvdpau" ,libvdpau)
217 ("libxdamage" ,libxdamage)
218 ("libxfixes" ,libxfixes)
219 ("libxshmfence" ,libxshmfence)
220 ("libxxf86vm" ,libxxf86vm)))
223 ("dri2proto" ,dri2proto)
224 ("dri3proto" ,dri3proto)
225 ("libva" ,(force libva-without-mesa))
227 ;; TODO: Add 'libxml2-python' for OpenGL ES 1.1 and 2.0 support
229 ("makedepend" ,makedepend)
230 ("presentproto" ,presentproto)
232 ("wayland" ,wayland)))
234 `(("pkg-config" ,pkg-config)
235 ("python" ,python-2)))
238 '(;; drop r300 from default gallium drivers, as it requires llvm
239 "--with-gallium-drivers=r600,svga,swrast,nouveau,virgl"
240 ;; Enable various optional features. TODO: opencl requires libclc,
241 ;; omx requires libomxil-bellagio
242 "--with-egl-platforms=x11,drm,wayland"
243 "--enable-glx-tls" ;Thread Local Storage, improves performance
248 ;; features required by wayland
251 "--enable-shared-glapi"
253 ;; on non-intel systems, drop i915 and i965
254 ;; from the default dri drivers
255 ,@(match (%current-system)
256 ((or "x86_64-linux" "i686-linux")
259 '("--with-dri-drivers=nouveau,r200,radeon,swrast"))))
261 (modify-phases %standard-phases
263 'unpack 'patch-create_test_cases
265 (substitute* "src/compiler/glsl/tests/lower_jumps/create_test_cases.py"
266 (("/usr/bin/env bash") (which "bash")))
267 (substitute* "src/intel/genxml/gen_pack_header.py"
268 (("/usr/bin/env python2") (which "python")))))
270 'build 'fix-dlopen-libnames
271 (lambda* (#:key inputs outputs #:allow-other-keys)
272 (let ((s2tc (assoc-ref inputs "s2tc"))
273 (out (assoc-ref outputs "out")))
274 ;; Remain agnostic to .so.X.Y.Z versions while doing
275 ;; the substitutions so we're future-safe.
277 '("src/gallium/auxiliary/util/u_format_s3tc.c"
278 "src/mesa/main/texcompress_s3tc.c")
279 (("\"libtxc_dxtn\\.so")
280 (string-append "\"" s2tc "/lib/libtxc_dxtn.so")))
281 (substitute* "src/glx/dri_common.c"
282 (("dlopen\\(\"libGL\\.so")
283 (string-append "dlopen(\"" out "/lib/libGL.so")))
284 (substitute* "src/egl/drivers/dri2/egl_dri2.c"
286 (string-append "\"" out "/lib/libglapi.so")))
287 (substitute* "src/gbm/main/backend.c"
288 ;; No need to patch the gbm_gallium_drm.so reference;
289 ;; it's never installed since Mesa removed its
290 ;; egl_gallium support.
292 (string-append "\"" out "/lib/dri/gbm_dri.so")))))))))
293 (home-page "http://mesa3d.org/")
294 (synopsis "OpenGL implementation")
295 (description "Mesa is a free implementation of the OpenGL specification -
296 a system for rendering interactive 3D graphics. A variety of device drivers
297 allows Mesa to be used in many different environments ranging from software
298 emulation to complete hardware acceleration for modern GPUs.")
299 (license license:x11)))
301 (define-public mesa-headers
304 (name "mesa-headers")
305 (propagated-inputs '())
310 (modify-phases %standard-phases
315 (lambda* (#:key outputs #:allow-other-keys)
316 (copy-recursively "include" (string-append
317 (assoc-ref outputs "out")
320 ;;; The mesa-demos distribution contains non-free files, many files with no
321 ;;; clear license information, and many demos that aren't useful for most
322 ;;; people, so we just use this for the mesa-utils package below, and possibly
323 ;;; other packages in the future. This is modeled after Debian's solution.
324 (define (mesa-demos-source version)
327 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/demos/" version
328 "/mesa-demos-" version ".tar.bz2"))
329 (sha256 (base32 "1vqb7s5m3fcg2csbiz45mha1pys2xx6rhw94fcyvapqdpm5iawy1"))))
331 (define-public mesa-utils
335 (source (mesa-demos-source version))
336 (build-system gnu-build-system)
342 `(("pkg-config" ,pkg-config)))
345 (modify-phases %standard-phases
348 (lambda* (#:key outputs #:allow-other-keys)
349 (let ((out (assoc-ref outputs "out")))
350 (mkdir-p (string-append out "/bin"))
353 (copy-file file (string-append out "/bin/" (basename file))))
354 '("src/xdemos/glxdemo" "src/xdemos/glxgears"
355 "src/xdemos/glxinfo" "src/xdemos/glxheads"))))))))
356 (home-page "http://mesa3d.org/")
357 (synopsis "Utility tools for Mesa")
359 "The mesa-utils package contains several utility tools for Mesa: glxdemo,
360 glxgears, glxheads, and glxinfo.")
361 ;; glxdemo is public domain; others expat.
362 (license (list license:expat license:public-domain))))
370 (uri (string-append "mirror://sourceforge/glew/glew/" version
371 "/glew-" version ".tgz"))
374 "0r37fg2s1f0jrvwh6c8cz5x6v4wqmhq42qm15cs9qs349q5c6wn5"))
375 (modules '((guix build utils)))
377 '(substitute* "config/Makefile.linux"
379 (("/lib64") "/lib")))))
380 (build-system gnu-build-system)
382 '(#:phases (alist-delete 'configure %standard-phases)
383 #:make-flags (list (string-append "GLEW_PREFIX="
384 (assoc-ref %outputs "out"))
385 (string-append "GLEW_DEST="
386 (assoc-ref %outputs "out")))
387 #:tests? #f)) ;no 'check' target
394 ;; <GL/glew.h> includes <GL/glu.h>.
395 (propagated-inputs `(("glu" ,glu)))
397 (home-page "http://glew.sourceforge.net/")
398 (synopsis "OpenGL extension loading library for C and C++")
400 "The OpenGL Extension Wrangler Library (GLEW) is a C/C++ extension
401 loading library. GLEW provides efficient run-time mechanisms for determining
402 which OpenGL extensions are supported on the target platform. OpenGL core and
403 extension functionality is exposed in a single header file.")
404 (license license:bsd-3)))
406 (define-public guile-opengl
408 (name "guile-opengl")
412 (uri (string-append "mirror://gnu/guile-opengl/guile-opengl-"
416 "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim"))))
417 (build-system gnu-build-system)
418 (native-inputs `(("pkg-config" ,pkg-config)))
419 (inputs `(("guile" ,guile-2.0)
422 ("freeglut" ,freeglut)))
424 '(#:phases (modify-phases %standard-phases
425 (add-after 'configure 'patch-makefile
427 ;; Install compiled Guile files in the expected place.
428 (substitute* '("Makefile")
430 "godir = $(moddir)\n"))))
431 (add-before 'build 'patch-dynamic-link
432 (lambda* (#:key inputs outputs #:allow-other-keys)
433 (define (dynamic-link-substitute file lib input)
435 (("dynamic-link \"lib([a-zA-Z]+)\"" _ lib)
436 (string-append "dynamic-link \""
437 (assoc-ref inputs input)
438 "/lib/lib" lib "\""))))
439 ;; Replace dynamic-link calls for libGL, libGLU, and
440 ;; libglut with absolute paths to the store.
441 (dynamic-link-substitute "glx/runtime.scm" "GL" "mesa")
442 (dynamic-link-substitute "glu/runtime.scm" "GLU" "glu")
443 (dynamic-link-substitute "glut/runtime.scm" "glut"
445 (home-page "https://gnu.org/s/guile-opengl")
446 (synopsis "Guile binding for the OpenGL graphics API")
448 "Guile-OpenGL is a library for Guile that provides bindings to the
449 OpenGL graphics API.")
450 (license license:lgpl3+)))
452 (define-public libepoxy
459 "https://github.com/anholt/libepoxy/archive/v"
462 (file-name (string-append name "-" version ".tar.gz"))
465 "1d1brhwfmlzgnphmdwlvn5wbcrxsdyzf1qfcf8nb89xqzznxs037"))))
468 (modify-phases %standard-phases
472 (zero? (system* "autoreconf" "-vif"))))
474 'configure 'patch-paths
475 (lambda* (#:key inputs #:allow-other-keys)
476 (let ((python (assoc-ref inputs "python"))
477 (mesa (assoc-ref inputs "mesa")))
478 (substitute* "src/gen_dispatch.py"
479 (("/usr/bin/env python") python))
480 (substitute* (find-files "." "\\.[ch]$")
481 (("libGL.so.1") (string-append mesa "/lib/libGL.so.1"))
482 (("libEGL.so.1") (string-append mesa "/lib/libEGL.so.1")))
484 ;; XXX On armhf systems, we must add "GLIBC_2.4" to the list of
485 ;; versions in test/dlwrap.c:dlwrap_real_dlsym. It would be
486 ;; better to make this a normal patch, but for now we do it here
487 ;; to prevent rebuilding on other platforms.
488 ,@(if (string-prefix? "arm" (or (%current-target-system)
490 '((substitute* '"test/dlwrap.c"
491 (("\"GLIBC_2\\.0\"") "\"GLIBC_2.0\", \"GLIBC_2.4\"")))
494 (build-system gnu-build-system)
496 `(("autoconf" ,autoconf)
497 ("automake" ,automake)
499 ("pkg-config" ,pkg-config)
503 (home-page "http://github.com/anholt/libepoxy/")
504 (synopsis "A library for handling OpenGL function pointer management")
506 "A library for handling OpenGL function pointer management.")
507 (license license:x11)))
515 ;; No versioned archive available.
516 (uri "http://www.lonesock.net/files/soil.zip")
519 "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52"))))
520 (build-system gnu-build-system)
522 '(#:tests? #f ; no tests
523 #:phases (modify-phases %standard-phases
525 (add-before 'build 'init-build
526 (lambda* (#:key outputs #:allow-other-keys)
527 (let ((out (assoc-ref outputs "out")))
528 (setenv "CFLAGS" "-fPIC") ; needed for shared library
529 ;; Use alternate Makefile
530 (copy-file "projects/makefile/alternate Makefile.txt"
533 (substitute* '("Makefile")
534 (("INCLUDEDIR = /usr/include/SOIL")
535 (string-append "INCLUDEDIR = " out "/include/SOIL"))
536 (("LIBDIR = /usr/lib")
537 (string-append "LIBDIR = " out "/lib"))
538 ;; Remove these flags from 'install' commands.
539 (("-o root -g root") ""))))))))
544 (home-page "http://www.lonesock.net/soil.html")
545 (synopsis "OpenGL texture loading library")
547 "SOIL is a tiny C library used primarily for uploading textures into
549 (license license:public-domain)))
557 (uri (string-append "https://github.com/glfw/glfw"
558 "/releases/download/" version
559 "/glfw-" version ".zip"))
562 "09kk5yc1zhss9add8ryqrngrr16hdmc94rszgng135bhw09mxmdp"))))
563 (build-system cmake-build-system)
565 '(#:tests? #f ; no test target
566 #:configure-flags '("-DBUILD_SHARED_LIBS=ON")))
568 `(("doxygen" ,doxygen)
571 `(("mesa" ,mesa) ;included in public headers
573 ;; These are in 'Requires.private' of 'glfw3.pc'.
575 ("libxrandr" ,libxrandr)
576 ("libxinerama" ,libxinerama)
577 ("libxcursor" ,libxcursor)
578 ("libxxf86vm" ,libxxf86vm)))
579 (home-page "http://www.glfw.org")
580 (synopsis "OpenGL application development library")
582 "GLFW is a library for OpenGL, OpenGL ES and Vulkan development for
583 desktop computers. It provides a simple API for creating windows, contexts
584 and surfaces, receiving input and events.")
585 (license license:zlib)))
587 (define-public nanovg-for-extempore
589 (name "nanovg-for-extempore")
593 (uri (string-append "https://github.com/extemporelang/nanovg/"
594 "archive/" version ".tar.gz"))
595 (file-name (string-append name "-" version ".tar.gz"))
598 "0ivs1sagq19xiw8jxd9f8w2b39svi0n9hrbmdvckwvqg95r8701g"))))
599 (build-system cmake-build-system)
600 (arguments `(#:tests? #f)) ; no tests included
603 ;; Extempore refuses to build on architectures other than x86_64
604 (supported-systems '("x86_64-linux"))
605 (home-page "https://github.com/extemporelang/nanovg")
606 (synopsis "2D vector drawing library on top of OpenGL")
607 (description "NanoVG is small antialiased vector graphics rendering
608 library for OpenGL. It has lean API modeled after HTML5 canvas API. It is
609 aimed to be a practical and fun toolset for building scalable user interfaces
610 and visualizations.")
611 (license license:zlib)))