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 David Thompson <davet@gnu.org>
5 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
7 ;;; This file is part of GNU Guix.
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22 (define-module (gnu packages gl)
23 #:use-module (ice-9 match)
24 #:use-module (guix build utils)
25 #:use-module ((guix licenses) #:prefix l:)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix packages)
30 #:use-module (guix utils)
31 #:use-module (gnu packages autotools)
32 #:use-module (gnu packages bison)
33 #:use-module (gnu packages flex)
34 #:use-module (gnu packages pkg-config)
35 #:use-module (gnu packages gettext)
36 #:use-module (gnu packages linux)
37 #:use-module (gnu packages python)
38 #:use-module (gnu packages xorg)
39 #:use-module (gnu packages xml)
40 #:use-module (gnu packages fontutils)
41 #:use-module (gnu packages guile)
42 #:use-module (gnu packages video)
43 #:use-module (gnu packages xdisorg)
44 #:use-module (gnu packages zip))
52 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/glu/glu-"
55 (base32 "0r72yyhj09x3krn3kn629jqbwyq50ji8w5ri2pn6zwrk35m4g1s3"))))
56 (build-system gnu-build-system)
58 `(("mesa" ,mesa))) ; according to glu.pc
59 (home-page "http://www.opengl.org/archives/resources/faq/technical/glu.htm")
60 (synopsis "Mesa OpenGL Utility library")
62 "GLU, or OpenGL Utility Library provides some higher-level functionality
63 not provided by just OpenGL itself. Some of GLU's Features
64 include: Scaling of 2D images and creation of mipmap pyramids,
65 Transformation of object coordinates into device coordinates and
66 vice versa, Support for NURBS surfaces, Support for tessellation
67 of concave or bow tie polygonal primitives, Specialty transformation
68 matrices for creating perspective and orthographic projections,
69 positioning a camera, and selection/picking, Rendering of disk,
70 cylinder, and sphere primitives, Interpreting OpenGL error values
72 (license (l:x11-style "http://directory.fsf.org/wiki/License:SGIFreeBv2"))))
74 (define-public freeglut
80 (uri (string-append "mirror://sourceforge/project/freeglut/freeglut/"
81 version "/freeglut-" version ".tar.gz"))
83 (base32 "16lrxxxd9ps9l69y3zsw6iy0drwjsp6m26d1937xj71alqk6dr6x"))))
84 (build-system gnu-build-system)
85 (inputs `(("mesa" ,mesa)
88 ("libxrandr" ,libxrandr)
89 ("libxxf86vm" ,libxxf86vm)
90 ("inputproto" ,inputproto)
93 ;; Headers from Mesa and GLU are needed.
96 (home-page "http://freeglut.sourceforge.net/")
97 (synopsis "Alternative to the OpenGL Utility Toolkit (GLUT)")
99 "Freeglut is a completely Free/OpenSourced alternative to
100 the OpenGL Utility Toolkit (GLUT) library. GLUT was originally
101 written by Mark Kilgard to support the sample programs in the
102 second edition OpenGL 'RedBook'. Since then, GLUT has been used
103 in a wide variety of practical applications because it is simple,
104 widely available and highly portable.
106 GLUT (and hence freeglut) allows the user to create and manage windows
107 containing OpenGL contexts on a wide range of platforms and also read
108 the mouse, keyboard and joystick functions. Freeglut is released under
109 the X-Consortium license.")
115 (version "2.1.3-rc5")
118 (uri (string-append "mirror://sourceforge/project/ftgl/FTGL%20Source/2.1.3~rc5/ftgl-"
121 (base32 "0nsn4s6vnv5xcgxcw6q031amvh2zfj2smy1r5mbnjj2548hxcn2l"))))
122 (build-system gnu-build-system)
123 (inputs `(("freetype" ,freetype)
127 (home-page "http://ftgl.sourceforge.net")
128 (synopsis "Font rendering library for OpenGL applications")
130 "FTGL is a font rendering library for OpenGL applications. Supported
131 rendering modes are: Bitmaps, Anti-aliased pixmaps, Texture maps, Outlines,
132 Polygon meshes, and Extruded polygon meshes")
143 "https://github.com/divVerent/s2tc/archive/v" version ".tar.gz"))
145 (base32 "0ibfdib277fhbqvxzan0bmglwnsl1y1rw2g8skvz82l1sfmmn752"))
146 (file-name (string-append name "-" version ".tar.gz"))))
147 (build-system gnu-build-system)
149 `(("autoconf" ,autoconf)
150 ("automake" ,automake)
151 ("libtool" ,libtool)))
153 `(("mesa-headers" ,mesa-headers)))
156 (modify-phases %standard-phases
157 (add-after 'unpack 'autogen
159 (zero? (system* "sh" "autogen.sh")))))))
160 (home-page "https://github.com/divVerent/s2tc")
161 (synopsis "S3 Texture Compression implementation")
163 "S2TC is a patent-free implementation of S3 Texture Compression (S3TC,
164 also known as DXTn or DXTC) for Mesa.")
167 ;;; Mesa needs LibVA headers to build its Gallium-based VA API implementation;
168 ;;; LibVA itself depends on Mesa. We use the following to solve the circular
170 (define libva-without-mesa
171 ;; Delay to work around circular import problem.
175 (name "libva-without-mesa")
176 (inputs (alist-delete "mesa" (package-inputs libva)))
178 (strip-keyword-arguments
180 (substitute-keyword-arguments (package-arguments libva)
181 ((#:configure-flags flags)
182 '(list "--disable-glx" "--disable-egl"))))))))
191 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
192 version "/mesa-" version ".tar.xz"))
195 "00v89jna7m6r2w1yrnx09isc97r2bd1hkn4jib445n1078zp47mm"))))
196 (build-system gnu-build-system)
198 `(("glproto" ,glproto)
199 ;; The following are in the Requires.private field of gl.pc.
202 ("libxdamage" ,libxdamage)
203 ("libxfixes" ,libxfixes)
204 ("libxshmfence" ,libxshmfence)
205 ("libxxf86vm" ,libxxf86vm)))
209 ("dri2proto" ,dri2proto)
210 ("dri3proto" ,dri3proto)
211 ("presentproto" ,presentproto)
213 ("libva" ,(force libva-without-mesa))
215 ;; TODO: Add 'libxml2-python' for OpenGL ES 1.1 and 2.0 support
217 ("makedepend" ,makedepend)
220 `(("pkg-config" ,pkg-config)))
223 '(;; drop r300 from default gallium drivers, as it requires llvm
224 "--with-gallium-drivers=r600,svga,swrast,nouveau"
225 ;; Enable various optional features. TODO: opencl requires libclc,
226 ;; omx requires libomxil-bellagio
227 "--with-egl-platforms=x11,drm"
228 "--enable-glx-tls" ;Thread Local Storage, improves performance
234 ;; on non-intel systems, drop i915 and i965
235 ;; from the default dri drivers
236 ,@(match (%current-system)
237 ((or "x86_64-linux" "i686-linux")
240 '("--with-dri-drivers=nouveau,r200,radeon,swrast"))))
241 #:phases (alist-cons-after
242 'unpack 'patch-create_test_cases
244 (substitute* "src/glsl/tests/lower_jumps/create_test_cases.py"
245 (("/usr/bin/env bash") (which "bash"))))
247 'build 'fix-dlopen-libnames
248 (lambda* (#:key inputs outputs #:allow-other-keys)
249 (let ((s2tc (assoc-ref inputs "s2tc"))
250 (udev (assoc-ref inputs "udev"))
251 (out (assoc-ref outputs "out")))
252 ;; Remain agnostic to .so.X.Y.Z versions while doing
253 ;; the substitutions so we're future-safe.
255 '("src/gallium/auxiliary/util/u_format_s3tc.c"
256 "src/mesa/main/texcompress_s3tc.c")
257 (("\"libtxc_dxtn\\.so")
258 (string-append "\"" s2tc "/lib/libtxc_dxtn.so")))
259 (substitute* "src/gallium/targets/egl-static/egl_st.c"
261 (string-append "\"" out "/lib/libglapi\"")))
262 (substitute* "src/loader/loader.c"
263 (("dlopen\\(\"libudev\\.so")
264 (string-append "dlopen(\"" udev "/lib/libudev.so")))
265 (substitute* "src/glx/dri_common.c"
266 (("dlopen\\(\"libGL\\.so")
267 (string-append "dlopen(\"" out "/lib/libGL.so")))
268 (substitute* "src/egl/drivers/dri2/egl_dri2.c"
270 (string-append "\"" out "/lib/libglapi.so")))
271 (substitute* "src/gbm/main/backend.c"
272 ;; No need to patch the gbm_gallium_drm.so reference;
273 ;; it's never installed since Mesa removed its
274 ;; egl_gallium support.
276 (string-append "\"" out "/lib/dri/gbm_dri.so")))))
278 (home-page "http://mesa3d.org/")
279 (synopsis "OpenGL implementation")
280 (description "Mesa is a free implementation of the OpenGL specification -
281 a system for rendering interactive 3D graphics. A variety of device drivers
282 allows Mesa to be used in many different environments ranging from software
283 emulation to complete hardware acceleration for modern GPUs.")
286 (define-public mesa-headers
289 (name "mesa-headers")
290 (propagated-inputs '())
295 (modify-phases %standard-phases
300 (lambda* (#:key outputs #:allow-other-keys)
301 (copy-recursively "include" (string-append
302 (assoc-ref outputs "out")
305 ;;; The mesa-demos distribution contains non-free files, many files with no
306 ;;; clear license information, and many demos that aren't useful for most
307 ;;; people, so we just use this for the mesa-utils package below, and possibly
308 ;;; other packages in the future. This is modeled after Debian's solution.
309 (define (mesa-demos-source version)
312 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/demos/" version
313 "/mesa-demos-" version ".tar.bz2"))
314 (sha256 (base32 "14msj0prbl3ljwd24yaqv9pz1xzicdmqgg616xxlppbdh6syrgz4"))))
316 (define-public mesa-utils
320 (source (mesa-demos-source version))
321 (build-system gnu-build-system)
327 `(("pkg-config" ,pkg-config)))
330 (modify-phases %standard-phases
333 (lambda* (#:key outputs #:allow-other-keys)
334 (let ((out (assoc-ref outputs "out")))
335 (mkdir-p (string-append out "/bin"))
338 (copy-file file (string-append out "/bin/" (basename file))))
339 '("src/xdemos/glxdemo" "src/xdemos/glxgears"
340 "src/xdemos/glxinfo" "src/xdemos/glxheads"))))))))
341 (home-page "http://mesa3d.org/")
342 (synopsis "Utility tools for Mesa")
344 "The mesa-utils package contains several utility tools for Mesa: glxdemo,
345 glxgears, glxheads, and glxinfo.")
346 ;; glxdemo is public domain; others expat.
347 (license (list l:expat l:public-domain))))
356 "mirror://sourceforge/glew/glew-"
361 "1mhkllxz49l1x680dmzrv2i82qjrq017sykah3xc90f2d8qcxfv9"))
362 (modules '((guix build utils)))
364 '(substitute* "config/Makefile.linux"
366 (("/lib64") "/lib")))))
367 (build-system gnu-build-system)
369 '(#:phases (alist-delete 'configure %standard-phases)
370 #:make-flags (list (string-append "GLEW_PREFIX="
371 (assoc-ref %outputs "out"))
372 (string-append "GLEW_DEST="
373 (assoc-ref %outputs "out")))
374 #:tests? #f)) ;no 'check' target
381 ;; <GL/glew.h> includes <GL/glu.h>.
382 (propagated-inputs `(("glu" ,glu)))
384 (home-page "http://glew.sourceforge.net/")
385 (synopsis "OpenGL extension loading library for C and C++")
387 "The OpenGL Extension Wrangler Library (GLEW) is a C/C++ extension
388 loading library. GLEW provides efficient run-time mechanisms for determining
389 which OpenGL extensions are supported on the target platform. OpenGL core and
390 extension functionality is exposed in a single header file.")
393 (define-public guile-opengl
395 (name "guile-opengl")
399 (uri (string-append "mirror://gnu/guile-opengl/guile-opengl-"
403 "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim"))))
404 (build-system gnu-build-system)
405 (native-inputs `(("pkg-config" ,pkg-config)))
406 (inputs `(("guile" ,guile-2.0)
409 ("freeglut" ,freeglut)))
411 '(#:phases (alist-cons-before
412 'build 'patch-dynamic-link
413 (lambda* (#:key inputs outputs #:allow-other-keys)
414 (define (dynamic-link-substitute file lib input)
416 (("dynamic-link \"lib([a-zA-Z]+)\"" _ lib)
417 (string-append "dynamic-link \""
418 (assoc-ref inputs input)
419 "/lib/lib" lib "\""))))
420 ;; Replace dynamic-link calls for libGL, libGLU, and
421 ;; libglut with absolute paths to the store.
422 (dynamic-link-substitute "glx/runtime.scm" "GL" "mesa")
423 (dynamic-link-substitute "glu/runtime.scm" "GLU" "glu")
424 (dynamic-link-substitute "glut/runtime.scm" "glut"
427 (home-page "http://gnu.org/s/guile-opengl")
428 (synopsis "Guile binding for the OpenGL graphics API")
430 "Guile-OpenGL is a library for Guile that provides bindings to the
431 OpenGL graphics API.")
434 (define-public libepoxy
441 "https://github.com/anholt/libepoxy/archive/v"
444 (file-name (string-append name "-" version ".tar.gz"))
447 "1xp8g6b7xlbym2rj4vkbl6xpb7ijq7glpv656mc7k9b01x22ihs2"))))
453 (zero? (system* "autoreconf" "-vif")))
455 'configure 'patch-paths
456 (lambda* (#:key inputs #:allow-other-keys)
457 (let ((python (assoc-ref inputs "python"))
458 (mesa (assoc-ref inputs "mesa")))
459 (substitute* "src/gen_dispatch.py"
460 (("/usr/bin/env python") python))
461 (substitute* (find-files "." "\\.[ch]$")
462 (("libGL.so.1") (string-append mesa "/lib/libGL.so.1"))
463 (("libEGL.so.1") (string-append mesa "/lib/libEGL.so.1")))
465 ;; XXX On armhf systems, we must add "GLIBC_2.4" to the list of
466 ;; versions in test/dlwrap.c:dlwrap_real_dlsym. It would be
467 ;; better to make this a normal patch, but for now we do it here
468 ;; to prevent rebuilding on other platforms.
469 ,@(if (string-prefix? "arm" (or (%current-target-system)
471 '((substitute* '"test/dlwrap.c"
472 (("\"GLIBC_2\\.0\"") "\"GLIBC_2.0\", \"GLIBC_2.4\"")))
476 (build-system gnu-build-system)
478 `(("autoconf" ,autoconf)
479 ("automake" ,automake)
481 ("pkg-config" ,pkg-config)
485 (home-page "http://github.com/anholt/libepoxy/")
486 (synopsis "A library for handling OpenGL function pointer management")
488 "A library for handling OpenGL function pointer management.")
497 ;; No versioned archive available.
498 (uri "http://www.lonesock.net/files/soil.zip")
501 "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52"))))
502 (build-system gnu-build-system)
504 '(#:tests? #f ; no tests
505 #:phases (modify-phases %standard-phases
507 (add-before 'build 'init-build
508 (lambda* (#:key outputs #:allow-other-keys)
509 (let ((out (assoc-ref outputs "out")))
510 (setenv "CFLAGS" "-fPIC") ; needed for shared library
511 ;; Use alternate Makefile
512 (copy-file "projects/makefile/alternate Makefile.txt"
515 (substitute* '("Makefile")
516 (("INCLUDEDIR = /usr/include/SOIL")
517 (string-append "INCLUDEDIR = " out "/include/SOIL"))
518 (("LIBDIR = /usr/lib")
519 (string-append "LIBDIR = " out "/lib"))
520 ;; Remove these flags from 'install' commands.
521 (("-o root -g root") ""))))))))
526 (home-page "http://www.lonesock.net/soil.html")
527 (synopsis "OpenGL texture loading library")
529 "SOIL is a tiny C library used primarily for uploading textures into
531 (license l:public-domain)))