3. Install Software

3.1. Install XFree86

Installation of the software packages requires root login, which can be obtained easily via the superuser/setuser command: "su -" (see, man su).

If you have a version of XFree86 installed already, you may want to move it or delete it:

		cd /usr
		mv X11R6 X11R6-old
		cd /etc
		mv X11 X11-old
	

If these locations are not correct for your distribution of Linux, you will have to look around your filesystem a bit - try looking in /var


	cd /usr/src
	mkdir release
	cd release
	tar -xvzf X402src-1.tgz
	tar -xvzf X402src-2.tgz
	tar -xvzf X402src-3.tgz
	tar -xvzf doctools-1.2.tar.gz

	-- unpack the man pages (actually, glx pages are already present)
        cd /usr/src
	tar -xvzf mangl.tar.Z
	tar -xvzf manglu.tar.Z
	

A file has to be edited to allow these man pages to compile/install with the rest of the distribution:

	cd /usr/src/release/xc/doc/man/GL
	Edit the file: Imakefile
		SUBDIRS = glx gl glu
	

When you unpacked the man*.tar.Z files above, two new directories where added: gl glu


	cd /usr/src/release
	cd doctools
	make
	make install
	cd ..
	cd xc/config/cf
	vi host.def
	-- add the following two lines to host.def:
	--	#define HasSgmlFmt YES
	--	#define BuildAllDocs YES

	cd /usr/src/release/xc
	make World
	-- before installing, make sure you have moved
	-- or deleted prior installation of X
	-- unless you are sure you want to just overwrite
	make install
	make install.man

        -- make symlinks
        cd /usr/include
        ln -s ../X11R6/include/DPS DPS
        ln -s ../X11R6/include/GL GL
        ln -s ../X11R6/include/X11 X11
        ln -s ../X11R6/include/bitmaps bitmaps
        cd ..
        ls -s X11R6 X11
	

Add /usr/X11R6/lib to your /etc/ld.so.conf file, then run "ldconfig" to update /etc/ld.so.cache so the libraries will be visible.

The GL/GLX/GLU HTML documentation is located at /usr/src/release/xc/doc/hardcopy/GL. This directory can be copied as follows:

                cd /usr/src/release/xc/doc/hardcopy
                cp -r GL /usr/X11R6/lib/X11/doc/html
        
You might notice broken symlinks in /usr/X11R6/lib/X11/doc/html. This seems to be a bug in the XFree86 build/install. The manindex3.html file is also corrupted. The broken symlinks can simply be deleted.

                cd /usr/X11R6/lib/X11/doc/html
                rm *3x.html

                -- if you want to play with mass renaming files, you can
                -- use a command like the following:
                for afile in *3.html; do export afile; mv "$afile" "`awk 'BEGIN {print gensub("3.html","3x.html","G",ENVIRON["afile"]) }'`"; done;
        
Hopefully this HTML doc problem will be fixed soon!

When X is up and running (later), try using the xman program to see that the gl,glx,glu and glut man pages are in section 3. If you have KDE2, khelpcenter allows manpage browsing.

3.2. Install Mesa

Note: This gives you the libGLU* and libglut* files that are missing in XFree86. XFree86 only comes with the OpenGL core library, libGL (based on Mesa). This also installs Mesa's libGL, but we will delete that since it is to be replaced by the Nvidia libGL.

To completely uninstall any Mesa libs that may have come with Slackware:

		removepkg mesa
	
Procedures vary for other distributions. If there is no clear way to uninstall an existing Mesa, then at least confirm where it is installed: normally either under /usr or /usr/local. The example below assumes that Mesa is installed (or going to get installed) under /usr. Installing over an old version is probably harmless. Look for /usr/lib/libMesa* or /usr/local/lib/libMesa* and delete them unless you have programs that need them.


	-- IF you are going to use the project GLUT distribution of GLUT, then
        -- unpack the Glut-3.7 packages ...
	-- Mesa's compile looks for it
	cd /usr/src
	tar -xvzf glut-3.7.tar.gz
	tar -xvzf glut_data-3.7.tar.gz
        -- IF you are using this GLUT, use the --with-glut=/usr/src/glut-3.7
        -- parameter with Mesa's ./configure below in addition to the --prefix

	cd /usr/src
	tar -xvzf MesaLib-3.4.tar.gz
        tar -xvzf MesaDemos-3.4.tar.gz
	cd Mesa-3.4
	./configure --prefix=/usr
	make
	make install
        ldconfig
	

At this point, Mesa installed its own version of the glx.h include files over the ones that XFree86 installed. This will cause some programs to fail to compile and is corrected by copying the XFree86 GL include files from the X source back to your system:

	cp /usr/src/release/xc/include/GL/*.h /usr/X11R6/include/GL
	

3.3. Install Nvidia OpenGL drivers


	-- delete the libGL.* files that come with XFree86 / Mesa 3.4 ...
	-- the nvidia libGL.* should replace them
	cd /usr/X11R6/lib
	rm libGL.*
	cd modules/extensions
	rm libGL*
	rm libglx*
	cd /usr/lib
	rm libGL.*

	cd /usr/src
	tar -xvzf NVIDIA_kernel-0.9-5.tar.gz
	tar -xvzf NVIDIA_GLX-0.9-5.tar.gz
	cd NVIDIA_kernel-0.9-5
	make
	cd ..
	cd NVIDIA_GLX-0.9-5
	make
        ldconfig
	cd
	-- make a basic X config file
	xf86config
		follow the prompts and fill in the information it asks for
	cd /etc/X11
	You must edit XF86Config and set the following:
	vi XF86Config
		Load "glx"
		Replace 'driver "nv"' with 'driver "nvidia"'
		Put "1600x1200" first (or your preferred screen resolution)
		Copy ttf fonts from Windows into a font directory and add a font path.
                Use ttmkfdir (check freshmeat.net) to a fonts.dir file.

	-- Nvidia drivers do NOT use the dri module - don't load it.

        -- you may like to edit /etc/X11/xinit/xinitrc to have it "startkde"
        -- or "gnome-session" instead of twm.

	-- note, /usr/include/GL should be a symlink to /usr/X11R6/include/GL
	

Specifying "nvidia" for the driver in the XF86Config makes that take effect each time you startx. But the NVdriver kernel driver will have to be loaded each time your system boots using:

		insmod NVdriver
	
You can place this command in one of the system startup files, like /etc/rc.d/rc.modules. But this may not be necessary if the following line is present in /etc/modules.conf:

                alias char-major-195 NVdriver
        
If this line is present, NVdriver is loaded automatically when X is started (autoclean). You can check if its loaded using the command, lsmod.

3.4. Install Qt


        -- for Qt, there is no "make install", just place the source
        -- where you want it to live:
	cd /usr/local
	tar -xvzf qt-x11-2.2.3.tar.gz
	ls -s qt-2.2.3 qt
	cd qt
	

Read the INSTALL file about environment variables to setup before you try to build Qt. You can add the following to /etc/profile:

                QTDIR=/usr/local/qt
                PATH=$PATH:$QTDIR/bin
                MANPATH=$MANPATH:$QTDIR/man
                LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$QTDIR/lib
                export QTDIR PATH MANPATH LD_LIBRARY_PATH
        
LD_LIBRARY_PATH is optional if you include an entry in /etc/ld.so.conf for the library path: /usr/local/qt/lib, then run "ldconfig" to update /etc/ld.so.cache.


        -- note: configure has some options you can try, to see them
        -- see ./configure --help
	./configure

        -- NOTE: when you run make as suggested on the next line, you may
        -- encounter a make error that halts the build IF you run make
        -- from outside X.  The program $QTDIR/bin/uic (the User Interface Compiler)
        -- may Segmentation Fault when run from a Linux console.  You can run
        -- "startx" and use the twm (tiny window manager) and xterm (or whatever you
        -- might have setup for X) to run the rest of the Qt build.  If for some
        -- reason twm is not even available, then you can run "XFree86 &", use
        -- "CTRL-ALT-F1" to get to a console, start an xterm as
        --  "xterm -display localhost:0.0 &", then switch back to X with "ALT-F7".

	make

        -- Only for old versions of Qt before 2.1.0 or so ...
	-- compile the opengl extension
	-- Note that in qt 2.2.0 on, the OpenGL support has been moved out of extensions
	-- and is now a standard part of the library that is installed if configure
	-- finds OpenGL installed on your system.  If you were to not want OpenGL
	-- support in Qt, you'd have to pass the -no-opengl option to configure.
	cd extensions/opengl/src
	-- Check the Makefile and ensure there are not Mesa references.
	make


	ldconfig
        cd ../examples
        -- Try compiling and running the examples.
	

3.5. Install GLUT 3.7 Distribution (optional)

If you installed the MesaDemos package along the Mesa 3.4, then you have already installed GLUT 3.7 since it is included with MesaDemos. However, you may be interested in installing the GLUT manpages and you can skip right to the "Install GLUT manual pages", below ...

Installing GLUT is a bit tricky. I'm not too familiar with imake, the program that it uses to manage the Makefiles, and didn't quite see how to get GLUT to install to where I wanted it (/usr/lib, but MesaDemos will do this without any trouble though). It can be done manually anyhow:


	cd /usr/src
	tar -xvzf glut-3.7.tar.gz
	cd glut-3.7

	Read the file: README.linux
	cd linux
	READ the file: README
	cp Glut.cf ..
	cd ..
	Edit Glut.cf: remove any Mesa references.
	Replace any -lMesaGL -lMesaGLU with -lGL -lGLU if needed.
	In particular, replace:
		OPENGL = $(TOP)/../lib/libMesaGL.so
		GLU = $(TOP)/../lib/libMesaGLU.so
	with:
		OPENGL = -lGL
		GLU = -lGLU

	./mkmkfiles.imake
	cd lib/glut
	cp /usr/src/glut-3.7/linux/Makefile .
	Edit the Makefile: remove any Mesa references.
	Replace any -lMesaGL -lMesaGLU with -lGL -lGLU if needed.
	In particular, replace:
		OPENGL = $(TOP)/../lib/libMesaGL.so
		GLU = $(TOP)/../lib/libMesaGLU.so
	with:
		OPENGL = -lGL
		GLU = -lGLU

	make
	ln -s libglut.so.3.7 libglut.so
	ln -s libglut.so.3.7 libglut.so.3
	cp -d libglut.* /usr/lib
	cd ..
	cd gle
	-- make a shared lib for libgle
	make
	gcc -shared -o libgle.so.3.7 *.o
	ln -s libgle.so.3.7 libgle.so
	ln -s libgle.so.3.7 libgle.so.3
	cp -d libgle.* /usr/lib
	cd ..
	cd mui
	-- make a shared lib for libmui
	make
	gcc -shared -o libmui.so.3.7 *.o
	ln -s libmui.so.3.7 libmui.so
	ln -s libmui.so.3.7 libmui.so.3
	cp -d libmui.* /usr/lib

        -- Install the GLUT manual pages (not included with MesaDemos)
	cd /usr/src/glut-3.7
	make SUBDIRS=man Makefile
	cd man/glut
	make install.man
	ldconfig

	cd ../../progs/demos/ideas
	-- edit the Makefile, change OPENGL = -lGL and GLU = -lGLU
	make
	./ideas
	-- test compiling some demos
	-- take a look at which libraries have to be linked (-lX11 ...) in
	-- the Makefiles.  Qt's tmake program available at www.troll.no
	-- is a quick way to make a Makefile but you have to edit it
	-- and add the -l needed.
	

3.6. Install Java 3D (optional)

If you already have a Java JDK/SDK or JRE, that is, a Java/Software Development Kit or Java Runtime Environment, installed, then you may have to take care to uninstall them or leave them alone!

It is recommended that you have the lastest version of Netscape 4.7x, which at this time of writing, is 4.76, if you plan to install the Java PlugIn for netscape. It works, but you may (or may not) experience Segmentation Faults when leaving a page that contained a Java 3D applet.

Assuming your are logged in as root and have downloaded the Java packages from blackdown.org into the root home directory, /root, do:

Install the Java 2 SDK (1.2.2) and Java 3D (1.2) extension:

                cd /usr/local
                tar -xvyf ~/j2sdk-1.2.2-FCS-linux-i386-glibc-2.1.3.tar.bz2
                ln -s jdk1.2.2 jdk
                cd jdk
                tar -xvyf ~/java3d1_2-FCS-linux-i386-sdk.tar.bz2
                cd jre/lib/ext
                cp j3d* ..
                cp vecmath.jar ..
                cd /usr/local
                chown -R root:root jdk1.2.2
        

Edit /etc/profile, add:

                JAVA_HOME=/usr/local/jdk
                PATH=$PATH:$JAVA_HOME/bin
                export JAVA_HOME PATH
        
This completes the installation of the Java 2 SDK, which includes the JRE, and the Java 3D 1.2 extension.

Install the Java PlugIn for netscape:
                -- source profile to set JAVA_HOME and PATH
                source /etc/profile
                cd
                chmod u+x JavaPlugIn-1.2.2-FCS-linux-i386-glibc-2.1.3.run
                ./JavaPlugIn-1.2.2-FCS-linux-i386-glibc-2.1.3.run
                -- each user has to run this file to install the plugin
		-- it is per user, not global
                netscape &
        
When netscape loads, go to Edit/Preferences/Advanced and Enable Java and Enable Java Plugin, then exit netscape.

The next step is to configure the Java PlugIn. It comes with a configuration applet.

                netscape ~/.netscape/java/ControlPanel.html &
                -- the Control Panel for JavaPlugIn should load
        
Again, netscape will load. Click the "Advanced" tab, select "Other ..." and type for Path:

                /usr/local/jdk1.2.2/jre
        
Then click "Apply" and exit Netscape. By changing this, it tells the Plugin to use the system Java Runtime Environment instead of the JRE it installed under ~/.netscape. The system JRE is where the Java 3D API extension is installed.

Test Java 3D demos:

                cd $JAVA_HOME/demo/java3d/GearTest
                java GearBox &
                -- runs as normal java application
                netscape GearBox_plugin.html &
                -- runs in netscape as an applet
        

If all works well, you should have a complete Java Developement and Runtime Environment for both normal apps and high-performance 3D apps. See http://java.sun.com/ for further information about Java and the Java 3D extension.