The ProteinShader program is compiled with Ant (Another Neat Tool). Ant uses the build.xml and build.properties files that are included with the source code distribution of the ProteinShader program (the source code is in the src subdirectory). Ant was originally developed by James Duncan Davidson, and is now an Apache open source community project. Most Linux, Macintosh OS X, and Windows XP machines with the Java SDK installed probably already have Ant, but if not, Ant can be downloaded for free from the Apache Ant Project web page at http://ant.apache.org. If you are not sure if Ant is already installed, type "ant -version" on the command line in a Terminal window (Linux or Macintosh OS X) or a Command Prompt window (Windows XP). If a message including something like "command not found" is printed, you probably need to download and install Ant.
To compile the Java source code in the src directory, change into the ProteinShader directory (where build.xml is found), and type "ant" on the command line. After placing the compiled code into the bin directory, Ant will use the compiled code to create a runnable JAR file, ProteinShader.jar, which will also be placed in the bin directory. By giving target arguments to Ant, Ant can be used to create new Javadoc html for the ProteinShader API or to clean up unwanted files, as shown in the following list of commands, where the "%" indicates the command line prompt:
The main target will compile the ProteinShader program and then package it into a runnable JAR file (may take a few to several seconds).
% ant compile
The compile target compiles the source code in the src directory and places it in the bin directory (may take a few to several seconds).
% ant compress
Uses the compiled code to create a runnable JAR file (so compile is a dependency that would get called automatically if compress is used). The manifest file will include Class-Main and Class-Path so that the JAR file is runnable.
% ant javadoc
Extracts all public comments in the Java source code and creates the Javadoc html for the ProteinShader API , which is placed in the docs directory.
% ant clean
Calls on the clean.classes and clean.jar targets. The entire bin directory is not deleted because there are dynamic libraries that need to remain there (".dll", ".jnilib", and ".so" files needed by jogl.jar).
% ant clean.classes
Removes org, the subdirectory of bin that holds the ".class" files.
% ant clean.jar
Removes the runnable JAR file in the bin directory.
The name=value pairs for properties used in the build.xml file are specified in the build.properties file to make them easy to change. For example, to use a different source code directory, "src=src" in the build.properties file could be changed to something like "src=src2". Alternatively, the property could be specified by using a command line argument of the form 'ant -Dsrc="src2"'.
Ant is much more powerful and flexible than the shell scripts I used to use. If you are not familiar with Ant and wish to learn more about it, I recommend "Ant: The Definitive Guide" by Steve Holzner, Second Editon, Oreilly ( www.oreilly.com/catalog/anttdg2).
To modify the graphics pipeline for custom lighting and texture mapping effects, the ProteinShader program uses small programs, known as vertex and fragment shaders, that are written using the OpenGL Shading Language. The vertex and fragment shaders (which always come in pairs) can be found in the shaders directory. The vertex and fragment shader pairs are compiled and linked by making calls to OpenGL, which runs over on the graphics card (i.e., shader binaries are not created and stored in advance, they are generated on demand for use with the particular graphics card that is present on the computer).
When the ProteinShader program starts up and first initializes the OpenGL state, a Java class called ShaderManager will ask an instance of the ShaderFactory class to read in the vertex and fragment shader files as long strings, and then pass those strings to the appropriate OpenGL command for compiling and linking. If a problem occurs, the information on the OpenGL error will be placed into a Java ShaderException. The ShaderFactory will compile and link as many shaders as it can, and afterwards any ShaderExceptions that occurred will be thrown upwards to the GUI so that the informtion can be displayed in a dialog box. The ProteinShader program will not exit. Instead it will use OpenGL's built-in lighting as a fall back position.