* 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
This commit is contained in:
Eelco Dolstra 2006-01-28 00:41:16 +00:00
parent 3263d078dd
commit 7f74c406c4
5 changed files with 53 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -2095,7 +2095,8 @@ rec {
};
quake3demo = import ../games/quake3/wrapper {
inherit fetchurl stdenv;
name = "quake3-demo";
inherit fetchurl stdenv mesa;
game = quake3game;
paks = [quake3demodata];
};

View File

@ -128,6 +128,8 @@ let {
ecj
jre
jetty
quake3demo
;};
i686FreeBSDPkgs = {inherit (allPackages {system = "i686-freebsd";})