summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2006-01-28 00:41:16 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2006-01-28 00:41:16 +0000
commit7f74c406c4dab2a4aa9c3c818c14f59b3d28829d (patch)
tree2f97649d9768700393d489a5a1924112c38c4e87
parent3263d078dd4e6476deef256cc835a5cdd30feab3 (diff)
downloadnixlib-7f74c406c4dab2a4aa9c3c818c14f59b3d28829d.tar
nixlib-7f74c406c4dab2a4aa9c3c818c14f59b3d28829d.tar.gz
nixlib-7f74c406c4dab2a4aa9c3c818c14f59b3d28829d.tar.bz2
nixlib-7f74c406c4dab2a4aa9c3c818c14f59b3d28829d.tar.lz
nixlib-7f74c406c4dab2a4aa9c3c818c14f59b3d28829d.tar.xz
nixlib-7f74c406c4dab2a4aa9c3c818c14f59b3d28829d.tar.zst
nixlib-7f74c406c4dab2a4aa9c3c818c14f59b3d28829d.zip
* In Quake 3, by default use Mesa as the OpenGL implementation. But
  allow the OpenGL implementation to be overriden through the
  OPENGL_DRIVER environment variable.  If it is not set, we use the
  implementation installed in the profile
  /nix/var/nix/profiles/opengl, allowing easy late binding by the
  user, e.g.,

    $ nix-env -p /nix/var/nix/profiles/opengl -i nvidia-sys-opengl

  might install the NVidia OpenGL implementation.

  The code that does this is not specific to Quake 3: it has been
  factored out into build-support/opengl/mesa-switch.sh.  Presumably
  any application that requires hardware-accelerated OpenGL needs it.

* Add the Quake 3 demo to the cache.

svn path=/nixpkgs/trunk/; revision=4612
-rw-r--r--pkgs/build-support/opengl/mesa-switch.sh41
-rw-r--r--pkgs/games/quake3/wrapper/builder.sh5
-rw-r--r--pkgs/games/quake3/wrapper/default.nix6
-rw-r--r--pkgs/system/all-packages-generic.nix3
-rw-r--r--pkgs/system/populate-cache.nix2
5 files changed, 53 insertions, 4 deletions
diff --git a/pkgs/build-support/opengl/mesa-switch.sh b/pkgs/build-support/opengl/mesa-switch.sh
new file mode 100644
index 000000000000..bc9445319dd9
--- /dev/null
+++ b/pkgs/build-support/opengl/mesa-switch.sh
@@ -0,0 +1,41 @@
+profileName=opengl
+profileDir=/nix/var/nix/profiles
+profile=$profileDir/$profileName
+
+if test -z "$OPENGL_DRIVER"; then
+    if test -d "$profile/lib"; then
+        OPENGL_DRIVER=$profile
+    fi
+fi
+
+if test -z "$OPENGL_DRIVER"; then
+
+    cat <<EOF
+======================================================================
+This program uses OpenGL for 3D graphics.  For best performance, you
+should use a hardware-accelerated implementation of OpenGL.  Since you
+have not enabled one, a software implementation (Mesa) will be used.
+This will probably be quite slow.
+
+This program will look for a hardware-accelerated implementation of
+OpenGL in the "$profileName" profile of your Nix installation.  For
+instance, to enable NVidia's accelerated driver on non-NixOS systems,
+try
+
+  $ nix-env -p $profile -i nvidia-sys-opengl
+
+Alternatively, you can set the OPENGL_DRIVER environment variable to
+point at the package containing the OpenGL implementation.
+======================================================================
+
+EOF
+
+    OPENGL_DRIVER=$mesa
+fi
+
+export LD_LIBRARY_PATH=$LD_LIBRARY_PATH${LD_LIBRARY_PATH:+:}$OPENGL_DRIVER/lib
+
+hook="$OPENGL_DRIVER/nix-support/opengl-hook"
+if test -e "$hook"; then
+    source "$hook"
+fi
diff --git a/pkgs/games/quake3/wrapper/builder.sh b/pkgs/games/quake3/wrapper/builder.sh
index 6162adfa824c..3042e7548f09 100644
--- a/pkgs/games/quake3/wrapper/builder.sh
+++ b/pkgs/games/quake3/wrapper/builder.sh
@@ -12,8 +12,13 @@ done
 ensureDir $out/bin
 
 cat >$out/bin/quake3 <<EOF
+mesa=$mesa
+
+$(cat $mesaSwitch)
+
 exec $game/ioquake3.i386 \
     +set fs_basepath $out \
+    +set r_allowSoftwareGL 1 \
     "\$@"
 EOF
 
diff --git a/pkgs/games/quake3/wrapper/default.nix b/pkgs/games/quake3/wrapper/default.nix
index 512ff21d7ce4..315516f037f4 100644
--- a/pkgs/games/quake3/wrapper/default.nix
+++ b/pkgs/games/quake3/wrapper/default.nix
@@ -1,7 +1,7 @@
-{stdenv, fetchurl, game, paks}:
+{stdenv, fetchurl, game, paks, mesa, name}:
 
 stdenv.mkDerivation {
-  name = "quake3";
   builder = ./builder.sh;
-  inherit game paks;
+  inherit game paks mesa name;
+  mesaSwitch = ../../../build-support/opengl/mesa-switch.sh;
 }
diff --git a/pkgs/system/all-packages-generic.nix b/pkgs/system/all-packages-generic.nix
index ed135cebe5bb..631051f43da3 100644
--- a/pkgs/system/all-packages-generic.nix
+++ b/pkgs/system/all-packages-generic.nix
@@ -2095,7 +2095,8 @@ rec {
   };
 
   quake3demo = import ../games/quake3/wrapper {
-    inherit fetchurl stdenv;
+    name = "quake3-demo";
+    inherit fetchurl stdenv mesa;
     game = quake3game;
     paks = [quake3demodata];
   };
diff --git a/pkgs/system/populate-cache.nix b/pkgs/system/populate-cache.nix
index 489c1324620d..c5146391a755 100644
--- a/pkgs/system/populate-cache.nix
+++ b/pkgs/system/populate-cache.nix
@@ -128,6 +128,8 @@ let {
     ecj
     jre
     jetty
+
+    quake3demo
   ;};
 
   i686FreeBSDPkgs = {inherit (allPackages {system = "i686-freebsd";})