gnu: glew: Update to 2.0.0.
[jackhill/guix/guix.git] / gnu / packages / gl.scm
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>
7 ;;;
8 ;;; This file is part of GNU Guix.
9 ;;;
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.
14 ;;;
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.
19 ;;;
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/>.
22
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))
48
49 (define-public glu
50 (package
51 (name "glu")
52 (version "9.0.0")
53 (source (origin
54 (method url-fetch)
55 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/glu/glu-"
56 version ".tar.gz"))
57 (sha256
58 (base32
59 "0r72yyhj09x3krn3kn629jqbwyq50ji8w5ri2pn6zwrk35m4g1s3"))))
60 (build-system gnu-build-system)
61 (propagated-inputs
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")
65 (description
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
75 as ASCII text.")
76 (license (license:x11-style "http://directory.fsf.org/wiki/License:SGIFreeBv2"))))
77
78 (define-public freeglut
79 (package
80 (name "freeglut")
81 (version "3.0.0")
82 (source (origin
83 (method url-fetch)
84 (uri (string-append
85 "mirror://sourceforge/freeglut/freeglut/"
86 version "/freeglut-" version ".tar.gz"))
87 (sha256
88 (base32
89 "18knkyczzwbmyg8hr4zh8a1i5ga01np2jzd1rwmsh7mh2n2vwhra"))))
90 (build-system cmake-build-system)
91 (arguments '(#:tests? #f)) ; no test target
92 (inputs `(("mesa" ,mesa)
93 ("libx11" ,libx11)
94 ("libxi" ,libxi)
95 ("libxrandr" ,libxrandr)
96 ("libxxf86vm" ,libxxf86vm)
97 ("inputproto" ,inputproto)
98 ("xinput" ,xinput)))
99 (propagated-inputs
100 ;; Headers from Mesa and GLU are needed.
101 `(("glu" ,glu)
102 ("mesa" ,mesa)))
103 (home-page "http://freeglut.sourceforge.net/")
104 (synopsis "Alternative to the OpenGL Utility Toolkit (GLUT)")
105 (description
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.
112
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)))
118
119 (define-public ftgl
120 (package
121 (name "ftgl")
122 (version "2.1.3-rc5")
123 (source (origin
124 (method url-fetch)
125 (uri (string-append
126 "mirror://sourceforge/ftgl/FTGL%20Source/2.1.3~rc5/"
127 "ftgl-" version ".tar.gz"))
128 (sha256
129 (base32
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)
135 ("mesa" ,mesa)
136 ("glu" ,glu)))
137 (home-page "http://ftgl.sourceforge.net")
138 (synopsis "Font rendering library for OpenGL applications")
139 (description
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)))
144
145 (define-public s2tc
146 (package
147 (name "s2tc")
148 (version "1.0")
149 (source
150 (origin
151 (method url-fetch)
152 (uri (string-append
153 "https://github.com/divVerent/s2tc/archive/v" version ".tar.gz"))
154 (sha256
155 (base32 "0ibfdib277fhbqvxzan0bmglwnsl1y1rw2g8skvz82l1sfmmn752"))
156 (file-name (string-append name "-" version ".tar.gz"))))
157 (build-system gnu-build-system)
158 (native-inputs
159 `(("autoconf" ,autoconf)
160 ("automake" ,automake)
161 ("libtool" ,libtool)))
162 (inputs
163 `(("mesa-headers" ,mesa-headers)))
164 (arguments
165 '(#:phases
166 (modify-phases %standard-phases
167 (add-after 'unpack 'autogen
168 (lambda _
169 (zero? (system* "sh" "autogen.sh")))))))
170 (home-page "https://github.com/divVerent/s2tc")
171 (synopsis "S3 Texture Compression implementation")
172 (description
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)))
176
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
179 ;;; dependency.
180 (define libva-without-mesa
181 ;; Delay to work around circular import problem.
182 (delay
183 (package
184 (inherit libva)
185 (name "libva-without-mesa")
186 (inputs (alist-delete "mesa" (package-inputs libva)))
187 (arguments
188 (strip-keyword-arguments
189 '(#:make-flags)
190 (substitute-keyword-arguments (package-arguments libva)
191 ((#:configure-flags flags)
192 '(list "--disable-glx" "--disable-egl"))))))))
193
194 (define-public mesa
195 (package
196 (name "mesa")
197 (version "11.0.9")
198 (source
199 (origin
200 (method url-fetch)
201 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
202 version "/mesa-" version ".tar.xz"))
203 (sha256
204 (base32
205 "009b3nq8ly5nzy9cxi9cxf4qasrhggjz0v0q87rwq5kaqvqjy9m1"))))
206 (build-system gnu-build-system)
207 (propagated-inputs
208 `(("glproto" ,glproto)
209 ;; The following are in the Requires.private field of gl.pc.
210 ("libdrm" ,libdrm)
211 ("libx11" ,libx11)
212 ("libxdamage" ,libxdamage)
213 ("libxfixes" ,libxfixes)
214 ("libxshmfence" ,libxshmfence)
215 ("libxxf86vm" ,libxxf86vm)))
216 ;; TODO: Add vdpau.
217 (inputs
218 `(("udev" ,eudev)
219 ("dri2proto" ,dri2proto)
220 ("dri3proto" ,dri3proto)
221 ("presentproto" ,presentproto)
222 ("expat" ,expat)
223 ("libva" ,(force libva-without-mesa))
224 ("libxml2" ,libxml2)
225 ;; TODO: Add 'libxml2-python' for OpenGL ES 1.1 and 2.0 support
226 ("libxvmc" ,libxvmc)
227 ("makedepend" ,makedepend)
228 ("s2tc" ,s2tc)))
229 (native-inputs
230 `(("pkg-config" ,pkg-config)))
231 (arguments
232 `(#:configure-flags
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
239 ;; "--enable-opencl"
240 ;; "--enable-omx"
241 "--enable-osmesa"
242 "--enable-xa"
243
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")
248 '())
249 (_
250 '("--with-dri-drivers=nouveau,r200,radeon,swrast"))))
251 #:phases (alist-cons-after
252 'unpack 'patch-create_test_cases
253 (lambda _
254 (substitute* "src/glsl/tests/lower_jumps/create_test_cases.py"
255 (("/usr/bin/env bash") (which "bash"))))
256 (alist-cons-before
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.
264 (substitute*
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"
277 (("\"libglapi\\.so")
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.
283 (("\"gbm_dri\\.so")
284 (string-append "\"" out "/lib/dri/gbm_dri.so")))))
285 %standard-phases))))
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)))
293
294 (define-public mesa-headers
295 (package
296 (inherit mesa)
297 (name "mesa-headers")
298 (propagated-inputs '())
299 (inputs '())
300 (native-inputs '())
301 (arguments
302 '(#:phases
303 (modify-phases %standard-phases
304 (delete 'configure)
305 (delete 'build)
306 (delete 'check)
307 (replace 'install
308 (lambda* (#:key outputs #:allow-other-keys)
309 (copy-recursively "include" (string-append
310 (assoc-ref outputs "out")
311 "/include")))))))))
312
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)
318 (origin
319 (method url-fetch)
320 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/demos/" version
321 "/mesa-demos-" version ".tar.bz2"))
322 (sha256 (base32 "1vqb7s5m3fcg2csbiz45mha1pys2xx6rhw94fcyvapqdpm5iawy1"))))
323
324 (define-public mesa-utils
325 (package
326 (name "mesa-utils")
327 (version "8.3.0")
328 (source (mesa-demos-source version))
329 (build-system gnu-build-system)
330 (inputs
331 `(("mesa" ,mesa)
332 ("glut" ,freeglut)
333 ("glew" ,glew)))
334 (native-inputs
335 `(("pkg-config" ,pkg-config)))
336 (arguments
337 '(#:phases
338 (modify-phases %standard-phases
339 (replace
340 'install
341 (lambda* (#:key outputs #:allow-other-keys)
342 (let ((out (assoc-ref outputs "out")))
343 (mkdir-p (string-append out "/bin"))
344 (for-each
345 (lambda (file)
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")
351 (description
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))))
356
357 (define-public glew
358 (package
359 (name "glew")
360 (version "2.0.0")
361 (source (origin
362 (method url-fetch)
363 (uri (string-append "mirror://sourceforge/glew/glew/" version
364 "/glew-" version ".tgz"))
365 (sha256
366 (base32
367 "0r37fg2s1f0jrvwh6c8cz5x6v4wqmhq42qm15cs9qs349q5c6wn5"))
368 (modules '((guix build utils)))
369 (snippet
370 '(substitute* "config/Makefile.linux"
371 (("= cc") "= gcc")
372 (("/lib64") "/lib")))))
373 (build-system gnu-build-system)
374 (arguments
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
381 (inputs
382 `(("libxi" ,libxi)
383 ("libxmu" ,libxmu)
384 ("libx11" ,libx11)
385 ("mesa" ,mesa)))
386
387 ;; <GL/glew.h> includes <GL/glu.h>.
388 (propagated-inputs `(("glu" ,glu)))
389
390 (home-page "http://glew.sourceforge.net/")
391 (synopsis "OpenGL extension loading library for C and C++")
392 (description
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)))
398
399 (define-public guile-opengl
400 (package
401 (name "guile-opengl")
402 (version "0.1.0")
403 (source (origin
404 (method url-fetch)
405 (uri (string-append "mirror://gnu/guile-opengl/guile-opengl-"
406 version ".tar.gz"))
407 (sha256
408 (base32
409 "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim"))))
410 (build-system gnu-build-system)
411 (native-inputs `(("pkg-config" ,pkg-config)))
412 (inputs `(("guile" ,guile-2.0)
413 ("mesa" ,mesa)
414 ("glu" ,glu)
415 ("freeglut" ,freeglut)))
416 (arguments
417 '(#:phases (modify-phases %standard-phases
418 (add-after 'configure 'patch-makefile
419 (lambda _
420 ;; Install compiled Guile files in the expected place.
421 (substitute* '("Makefile")
422 (("^godir = .*$")
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)
427 (substitute* file
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"
437 "freeglut"))))))
438 (home-page "https://gnu.org/s/guile-opengl")
439 (synopsis "Guile binding for the OpenGL graphics API")
440 (description
441 "Guile-OpenGL is a library for Guile that provides bindings to the
442 OpenGL graphics API.")
443 (license license:lgpl3+)))
444
445 (define-public libepoxy
446 (package
447 (name "libepoxy")
448 (version "1.3.1")
449 (source (origin
450 (method url-fetch)
451 (uri (string-append
452 "https://github.com/anholt/libepoxy/archive/v"
453 version
454 ".tar.gz"))
455 (file-name (string-append name "-" version ".tar.gz"))
456 (sha256
457 (base32
458 "1d1brhwfmlzgnphmdwlvn5wbcrxsdyzf1qfcf8nb89xqzznxs037"))))
459 (arguments
460 `(#:phases
461 (alist-cons-after
462 'unpack 'autoreconf
463 (lambda _
464 (zero? (system* "autoreconf" "-vif")))
465 (alist-cons-before
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")))
475
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)
481 (%current-system)))
482 '((substitute* '"test/dlwrap.c"
483 (("\"GLIBC_2\\.0\"") "\"GLIBC_2.0\", \"GLIBC_2.4\"")))
484 '())
485 #t))
486 %standard-phases))))
487 (build-system gnu-build-system)
488 (native-inputs
489 `(("autoconf" ,autoconf)
490 ("automake" ,automake)
491 ("libtool" ,libtool)
492 ("pkg-config" ,pkg-config)
493 ("python" ,python)))
494 (inputs
495 `(("mesa" ,mesa)))
496 (home-page "http://github.com/anholt/libepoxy/")
497 (synopsis "A library for handling OpenGL function pointer management")
498 (description
499 "A library for handling OpenGL function pointer management.")
500 (license license:x11)))
501
502 (define-public soil
503 (package
504 (name "soil")
505 (version "1.0.7")
506 (source (origin
507 (method url-fetch)
508 ;; No versioned archive available.
509 (uri "http://www.lonesock.net/files/soil.zip")
510 (sha256
511 (base32
512 "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52"))))
513 (build-system gnu-build-system)
514 (arguments
515 '(#:tests? #f ; no tests
516 #:phases (modify-phases %standard-phases
517 (delete 'configure)
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"
524 "src/Makefile")
525 (chdir "src")
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") ""))))))))
533 (native-inputs
534 `(("unzip" ,unzip)))
535 (inputs
536 `(("mesa" ,mesa)))
537 (home-page "http://www.lonesock.net/soil.html")
538 (synopsis "OpenGL texture loading library")
539 (description
540 "SOIL is a tiny C library used primarily for uploading textures into
541 OpenGL.")
542 (license license:public-domain)))
543
544 (define-public glfw
545 (package
546 (name "glfw")
547 (version "3.2.1")
548 (source (origin
549 (method url-fetch)
550 (uri (string-append "https://github.com/glfw/glfw"
551 "/releases/download/" version
552 "/glfw-" version ".zip"))
553 (sha256
554 (base32
555 "09kk5yc1zhss9add8ryqrngrr16hdmc94rszgng135bhw09mxmdp"))))
556 (build-system cmake-build-system)
557 (arguments
558 '(#:tests? #f ; no test target
559 #:configure-flags '("-DBUILD_SHARED_LIBS=ON")))
560 (native-inputs
561 `(("doxygen" ,doxygen)
562 ("unzip" ,unzip)))
563 (inputs
564 `(("mesa" ,mesa)
565 ("libx11" ,libx11)
566 ("libxrandr" ,libxrandr)
567 ("libxinerama" ,libxinerama)
568 ("libxcursor" ,libxcursor)))
569 (home-page "http://www.glfw.org")
570 (synopsis "OpenGL application development library")
571 (description
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)))