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 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2016 ng0 <ng0@we.make.ritual.n0.is>
8 ;;; This file is part of GNU Guix.
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23 (define-module (gnu packages gl)
24 #:use-module (gnu packages autotools)
25 #:use-module (gnu packages bison)
26 #:use-module (gnu packages documentation)
27 #:use-module (gnu packages flex)
28 #:use-module (gnu packages fontutils)
29 #:use-module (gnu packages freedesktop)
30 #:use-module (gnu packages gettext)
31 #:use-module (gnu packages guile)
32 #:use-module (gnu packages linux)
33 #:use-module (gnu packages pkg-config)
34 #:use-module (gnu packages python)
35 #:use-module (gnu packages video)
36 #:use-module (gnu packages xdisorg)
37 #:use-module (gnu packages xml)
38 #:use-module (gnu packages xorg)
39 #:use-module (gnu packages zip)
40 #:use-module (guix download)
41 #:use-module (guix build utils)
42 #:use-module (guix build-system gnu)
43 #:use-module (guix build-system cmake)
44 #:use-module ((guix licenses) #:prefix license:)
45 #:use-module (guix packages)
46 #:use-module (guix utils)
47 #:use-module (ice-9 match))
55 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/glu/glu-"
59 "0r72yyhj09x3krn3kn629jqbwyq50ji8w5ri2pn6zwrk35m4g1s3"))))
60 (build-system gnu-build-system)
62 `(("mesa" ,mesa))) ; according to glu.pc
63 (home-page "http://www.opengl.org/archives/resources/faq/technical/glu.htm")
64 (synopsis "Mesa OpenGL Utility library")
66 "GLU, or OpenGL Utility Library provides some higher-level functionality
67 not provided by just OpenGL itself. Some of GLU's Features
68 include: Scaling of 2D images and creation of mipmap pyramids,
69 Transformation of object coordinates into device coordinates and
70 vice versa, Support for NURBS surfaces, Support for tessellation
71 of concave or bow tie polygonal primitives, Specialty transformation
72 matrices for creating perspective and orthographic projections,
73 positioning a camera, and selection/picking, Rendering of disk,
74 cylinder, and sphere primitives, Interpreting OpenGL error values
76 (license (license:x11-style "http://directory.fsf.org/wiki/License:SGIFreeBv2"))))
78 (define-public freeglut
85 "mirror://sourceforge/freeglut/freeglut/"
86 version "/freeglut-" version ".tar.gz"))
89 "18knkyczzwbmyg8hr4zh8a1i5ga01np2jzd1rwmsh7mh2n2vwhra"))))
90 (build-system cmake-build-system)
91 (arguments '(#:tests? #f)) ; no test target
92 (inputs `(("mesa" ,mesa)
95 ("libxrandr" ,libxrandr)
96 ("libxxf86vm" ,libxxf86vm)
97 ("inputproto" ,inputproto)
100 ;; Headers from Mesa and GLU are needed.
103 (home-page "http://freeglut.sourceforge.net/")
104 (synopsis "Alternative to the OpenGL Utility Toolkit (GLUT)")
106 "Freeglut is a completely Free/OpenSourced alternative to
107 the OpenGL Utility Toolkit (GLUT) library. GLUT was originally
108 written by Mark Kilgard to support the sample programs in the
109 second edition OpenGL 'RedBook'. Since then, GLUT has been used
110 in a wide variety of practical applications because it is simple,
111 widely available and highly portable.
113 GLUT (and hence freeglut) allows the user to create and manage windows
114 containing OpenGL contexts on a wide range of platforms and also read
115 the mouse, keyboard and joystick functions. Freeglut is released under
116 the X-Consortium license.")
117 (license license:x11)))
122 (version "2.1.3-rc5")
126 "mirror://sourceforge/ftgl/FTGL%20Source/2.1.3~rc5/"
127 "ftgl-" version ".tar.gz"))
130 "0nsn4s6vnv5xcgxcw6q031amvh2zfj2smy1r5mbnjj2548hxcn2l"))))
131 (build-system gnu-build-system)
132 ;; The pkg-config file lists "freetype2" as Requires.private.
133 (propagated-inputs `(("freetype" ,freetype)))
134 (inputs `(("libx11" ,libx11)
137 (home-page "http://ftgl.sourceforge.net")
138 (synopsis "Font rendering library for OpenGL applications")
140 "FTGL is a font rendering library for OpenGL applications. Supported
141 rendering modes are: Bitmaps, Anti-aliased pixmaps, Texture maps, Outlines,
142 Polygon meshes, and Extruded polygon meshes.")
143 (license license:x11)))
153 "https://github.com/divVerent/s2tc/archive/v" version ".tar.gz"))
155 (base32 "0ibfdib277fhbqvxzan0bmglwnsl1y1rw2g8skvz82l1sfmmn752"))
156 (file-name (string-append name "-" version ".tar.gz"))))
157 (build-system gnu-build-system)
159 `(("autoconf" ,autoconf)
160 ("automake" ,automake)
161 ("libtool" ,libtool)))
163 `(("mesa-headers" ,mesa-headers)))
166 (modify-phases %standard-phases
167 (add-after 'unpack 'autogen
169 (zero? (system* "sh" "autogen.sh")))))))
170 (home-page "https://github.com/divVerent/s2tc")
171 (synopsis "S3 Texture Compression implementation")
173 "S2TC is a patent-free implementation of S3 Texture Compression (S3TC,
174 also known as DXTn or DXTC) for Mesa.")
175 (license license:expat)))
177 ;;; Mesa needs LibVA headers to build its Gallium-based VA API implementation;
178 ;;; LibVA itself depends on Mesa. We use the following to solve the circular
180 (define libva-without-mesa
181 ;; Delay to work around circular import problem.
185 (name "libva-without-mesa")
186 (inputs (alist-delete "mesa" (package-inputs libva)))
188 (strip-keyword-arguments
190 (substitute-keyword-arguments (package-arguments libva)
191 ((#:configure-flags flags)
192 '(list "--disable-glx" "--disable-egl"))))))))
201 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
202 version "/mesa-" version ".tar.xz"))
205 "009b3nq8ly5nzy9cxi9cxf4qasrhggjz0v0q87rwq5kaqvqjy9m1"))))
206 (build-system gnu-build-system)
208 `(("glproto" ,glproto)
209 ;; The following are in the Requires.private field of gl.pc.
212 ("libxdamage" ,libxdamage)
213 ("libxfixes" ,libxfixes)
214 ("libxshmfence" ,libxshmfence)
215 ("libxxf86vm" ,libxxf86vm)))
219 ("dri2proto" ,dri2proto)
220 ("dri3proto" ,dri3proto)
221 ("presentproto" ,presentproto)
223 ("libva" ,(force libva-without-mesa))
225 ;; TODO: Add 'libxml2-python' for OpenGL ES 1.1 and 2.0 support
227 ("makedepend" ,makedepend)
230 `(("pkg-config" ,pkg-config)))
233 '(;; drop r300 from default gallium drivers, as it requires llvm
234 "--with-gallium-drivers=r600,svga,swrast,nouveau"
235 ;; Enable various optional features. TODO: opencl requires libclc,
236 ;; omx requires libomxil-bellagio
237 "--with-egl-platforms=x11,drm"
238 "--enable-glx-tls" ;Thread Local Storage, improves performance
244 ;; on non-intel systems, drop i915 and i965
245 ;; from the default dri drivers
246 ,@(match (%current-system)
247 ((or "x86_64-linux" "i686-linux")
250 '("--with-dri-drivers=nouveau,r200,radeon,swrast"))))
251 #:phases (alist-cons-after
252 'unpack 'patch-create_test_cases
254 (substitute* "src/glsl/tests/lower_jumps/create_test_cases.py"
255 (("/usr/bin/env bash") (which "bash"))))
257 'build 'fix-dlopen-libnames
258 (lambda* (#:key inputs outputs #:allow-other-keys)
259 (let ((s2tc (assoc-ref inputs "s2tc"))
260 (udev (assoc-ref inputs "udev"))
261 (out (assoc-ref outputs "out")))
262 ;; Remain agnostic to .so.X.Y.Z versions while doing
263 ;; the substitutions so we're future-safe.
265 '("src/gallium/auxiliary/util/u_format_s3tc.c"
266 "src/mesa/main/texcompress_s3tc.c")
267 (("\"libtxc_dxtn\\.so")
268 (string-append "\"" s2tc "/lib/libtxc_dxtn.so")))
269 (substitute* "src/loader/loader.c"
270 (("udev_handle = dlopen\\(name")
271 (string-append "udev_handle = dlopen(\""
272 udev "/lib/libudev.so\"")))
273 (substitute* "src/glx/dri_common.c"
274 (("dlopen\\(\"libGL\\.so")
275 (string-append "dlopen(\"" out "/lib/libGL.so")))
276 (substitute* "src/egl/drivers/dri2/egl_dri2.c"
278 (string-append "\"" out "/lib/libglapi.so")))
279 (substitute* "src/gbm/main/backend.c"
280 ;; No need to patch the gbm_gallium_drm.so reference;
281 ;; it's never installed since Mesa removed its
282 ;; egl_gallium support.
284 (string-append "\"" out "/lib/dri/gbm_dri.so")))))
286 (home-page "http://mesa3d.org/")
287 (synopsis "OpenGL implementation")
288 (description "Mesa is a free implementation of the OpenGL specification -
289 a system for rendering interactive 3D graphics. A variety of device drivers
290 allows Mesa to be used in many different environments ranging from software
291 emulation to complete hardware acceleration for modern GPUs.")
292 (license license:x11)))
294 (define-public mesa-headers
297 (name "mesa-headers")
298 (propagated-inputs '())
303 (modify-phases %standard-phases
308 (lambda* (#:key outputs #:allow-other-keys)
309 (copy-recursively "include" (string-append
310 (assoc-ref outputs "out")
313 ;;; The mesa-demos distribution contains non-free files, many files with no
314 ;;; clear license information, and many demos that aren't useful for most
315 ;;; people, so we just use this for the mesa-utils package below, and possibly
316 ;;; other packages in the future. This is modeled after Debian's solution.
317 (define (mesa-demos-source version)
320 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/demos/" version
321 "/mesa-demos-" version ".tar.bz2"))
322 (sha256 (base32 "1vqb7s5m3fcg2csbiz45mha1pys2xx6rhw94fcyvapqdpm5iawy1"))))
324 (define-public mesa-utils
328 (source (mesa-demos-source version))
329 (build-system gnu-build-system)
335 `(("pkg-config" ,pkg-config)))
338 (modify-phases %standard-phases
341 (lambda* (#:key outputs #:allow-other-keys)
342 (let ((out (assoc-ref outputs "out")))
343 (mkdir-p (string-append out "/bin"))
346 (copy-file file (string-append out "/bin/" (basename file))))
347 '("src/xdemos/glxdemo" "src/xdemos/glxgears"
348 "src/xdemos/glxinfo" "src/xdemos/glxheads"))))))))
349 (home-page "http://mesa3d.org/")
350 (synopsis "Utility tools for Mesa")
352 "The mesa-utils package contains several utility tools for Mesa: glxdemo,
353 glxgears, glxheads, and glxinfo.")
354 ;; glxdemo is public domain; others expat.
355 (license (list license:expat license:public-domain))))
363 (uri (string-append "mirror://sourceforge/glew/glew/" version
364 "/glew-" version ".tgz"))
367 "0r37fg2s1f0jrvwh6c8cz5x6v4wqmhq42qm15cs9qs349q5c6wn5"))
368 (modules '((guix build utils)))
370 '(substitute* "config/Makefile.linux"
372 (("/lib64") "/lib")))))
373 (build-system gnu-build-system)
375 '(#:phases (alist-delete 'configure %standard-phases)
376 #:make-flags (list (string-append "GLEW_PREFIX="
377 (assoc-ref %outputs "out"))
378 (string-append "GLEW_DEST="
379 (assoc-ref %outputs "out")))
380 #:tests? #f)) ;no 'check' target
387 ;; <GL/glew.h> includes <GL/glu.h>.
388 (propagated-inputs `(("glu" ,glu)))
390 (home-page "http://glew.sourceforge.net/")
391 (synopsis "OpenGL extension loading library for C and C++")
393 "The OpenGL Extension Wrangler Library (GLEW) is a C/C++ extension
394 loading library. GLEW provides efficient run-time mechanisms for determining
395 which OpenGL extensions are supported on the target platform. OpenGL core and
396 extension functionality is exposed in a single header file.")
397 (license license:bsd-3)))
399 (define-public guile-opengl
401 (name "guile-opengl")
405 (uri (string-append "mirror://gnu/guile-opengl/guile-opengl-"
409 "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim"))))
410 (build-system gnu-build-system)
411 (native-inputs `(("pkg-config" ,pkg-config)))
412 (inputs `(("guile" ,guile-2.0)
415 ("freeglut" ,freeglut)))
417 '(#:phases (modify-phases %standard-phases
418 (add-after 'configure 'patch-makefile
420 ;; Install compiled Guile files in the expected place.
421 (substitute* '("Makefile")
423 "godir = $(moddir)\n"))))
424 (add-before 'build 'patch-dynamic-link
425 (lambda* (#:key inputs outputs #:allow-other-keys)
426 (define (dynamic-link-substitute file lib input)
428 (("dynamic-link \"lib([a-zA-Z]+)\"" _ lib)
429 (string-append "dynamic-link \""
430 (assoc-ref inputs input)
431 "/lib/lib" lib "\""))))
432 ;; Replace dynamic-link calls for libGL, libGLU, and
433 ;; libglut with absolute paths to the store.
434 (dynamic-link-substitute "glx/runtime.scm" "GL" "mesa")
435 (dynamic-link-substitute "glu/runtime.scm" "GLU" "glu")
436 (dynamic-link-substitute "glut/runtime.scm" "glut"
438 (home-page "https://gnu.org/s/guile-opengl")
439 (synopsis "Guile binding for the OpenGL graphics API")
441 "Guile-OpenGL is a library for Guile that provides bindings to the
442 OpenGL graphics API.")
443 (license license:lgpl3+)))
445 (define-public libepoxy
452 "https://github.com/anholt/libepoxy/archive/v"
455 (file-name (string-append name "-" version ".tar.gz"))
458 "1d1brhwfmlzgnphmdwlvn5wbcrxsdyzf1qfcf8nb89xqzznxs037"))))
464 (zero? (system* "autoreconf" "-vif")))
466 'configure 'patch-paths
467 (lambda* (#:key inputs #:allow-other-keys)
468 (let ((python (assoc-ref inputs "python"))
469 (mesa (assoc-ref inputs "mesa")))
470 (substitute* "src/gen_dispatch.py"
471 (("/usr/bin/env python") python))
472 (substitute* (find-files "." "\\.[ch]$")
473 (("libGL.so.1") (string-append mesa "/lib/libGL.so.1"))
474 (("libEGL.so.1") (string-append mesa "/lib/libEGL.so.1")))
476 ;; XXX On armhf systems, we must add "GLIBC_2.4" to the list of
477 ;; versions in test/dlwrap.c:dlwrap_real_dlsym. It would be
478 ;; better to make this a normal patch, but for now we do it here
479 ;; to prevent rebuilding on other platforms.
480 ,@(if (string-prefix? "arm" (or (%current-target-system)
482 '((substitute* '"test/dlwrap.c"
483 (("\"GLIBC_2\\.0\"") "\"GLIBC_2.0\", \"GLIBC_2.4\"")))
487 (build-system gnu-build-system)
489 `(("autoconf" ,autoconf)
490 ("automake" ,automake)
492 ("pkg-config" ,pkg-config)
496 (home-page "http://github.com/anholt/libepoxy/")
497 (synopsis "A library for handling OpenGL function pointer management")
499 "A library for handling OpenGL function pointer management.")
500 (license license:x11)))
508 ;; No versioned archive available.
509 (uri "http://www.lonesock.net/files/soil.zip")
512 "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52"))))
513 (build-system gnu-build-system)
515 '(#:tests? #f ; no tests
516 #:phases (modify-phases %standard-phases
518 (add-before 'build 'init-build
519 (lambda* (#:key outputs #:allow-other-keys)
520 (let ((out (assoc-ref outputs "out")))
521 (setenv "CFLAGS" "-fPIC") ; needed for shared library
522 ;; Use alternate Makefile
523 (copy-file "projects/makefile/alternate Makefile.txt"
526 (substitute* '("Makefile")
527 (("INCLUDEDIR = /usr/include/SOIL")
528 (string-append "INCLUDEDIR = " out "/include/SOIL"))
529 (("LIBDIR = /usr/lib")
530 (string-append "LIBDIR = " out "/lib"))
531 ;; Remove these flags from 'install' commands.
532 (("-o root -g root") ""))))))))
537 (home-page "http://www.lonesock.net/soil.html")
538 (synopsis "OpenGL texture loading library")
540 "SOIL is a tiny C library used primarily for uploading textures into
542 (license license:public-domain)))
550 (uri (string-append "https://github.com/glfw/glfw"
551 "/releases/download/" version
552 "/glfw-" version ".zip"))
555 "09kk5yc1zhss9add8ryqrngrr16hdmc94rszgng135bhw09mxmdp"))))
556 (build-system cmake-build-system)
558 '(#:tests? #f ; no test target
559 #:configure-flags '("-DBUILD_SHARED_LIBS=ON")))
561 `(("doxygen" ,doxygen)
566 ("libxrandr" ,libxrandr)
567 ("libxinerama" ,libxinerama)
568 ("libxcursor" ,libxcursor)))
569 (home-page "http://www.glfw.org")
570 (synopsis "OpenGL application development library")
572 "GLFW is a library for OpenGL, OpenGL ES and Vulkan development for
573 desktop computers. It provides a simple API for creating windows, contexts
574 and surfaces, receiving input and events.")
575 (license license:zlib)))