org.jrabbit.base.directory
Class LWJGLNatives

java.lang.Object
  extended by org.jrabbit.base.directory.LWJGLNatives

public class LWJGLNatives
extends java.lang.Object

The Java Rabbit Engine uses LWJGL for its rendering. To run, LWJGL requires particular native libraries be on the user's computer, available for the OS. These natives are automatically packaged into the jRabbit jar file. At startup, a desktop game attempts to use the natives from a folder within the main jRabbit directory. If the libraries are not present, they are extracted into that location. If the folder exists but the game crashes on startup because of a problem with LWJGL, try deleting the folder where the natives are kept. On the next startup, everything will be re-extracted, and it should work.

Author:
Chris Molini

Field Summary
private static java.lang.String embedLoc
          The path to the natives that are embedded within jRabbit.
private static java.lang.String folderName
          The name of the folder where the natives are kept.
 
Constructor Summary
LWJGLNatives()
           
 
Method Summary
private static void extractFiles(java.lang.String source, java.lang.String target, java.lang.String... files)
          Moves the indicated files from one location to another.
private static void extractNatives(java.io.File target)
          Extracts the natives to the target file.
static java.io.File getLibrary()
          Accesses a File reference to the library containing the natives.
static java.lang.String getLibraryName()
          Learns the name of the folder where the natives will be stored.
static void load()
          Handles the extracting/loading/accessing of the required natives so that LWJGL can function.
static void setLibraryName(java.lang.String name)
          Changes the library name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

folderName

private static java.lang.String folderName
The name of the folder where the natives are kept.


embedLoc

private static java.lang.String embedLoc
The path to the natives that are embedded within jRabbit.

Constructor Detail

LWJGLNatives

public LWJGLNatives()
Method Detail

getLibrary

public static java.io.File getLibrary()
Accesses a File reference to the library containing the natives.

Returns:
A File that points to the location of the library to extract to.

getLibraryName

public static java.lang.String getLibraryName()
Learns the name of the folder where the natives will be stored.

Returns:
The name of the folder where the natives are extracted to.

setLibraryName

public static void setLibraryName(java.lang.String name)
Changes the library name.

Parameters:
name - The new name of the folder where libraries will be stored.

extractNatives

private static void extractNatives(java.io.File target)
Extracts the natives to the target file. This automatically extracts the appropriate natives depending on the OS. In case the JVM is a different bitness (32 vs. 64) than the OS, both 32 bit and 64 bit natives are extracted.

Parameters:
target - The file that the natives will end up in.

extractFiles

private static void extractFiles(java.lang.String source,
                                 java.lang.String target,
                                 java.lang.String... files)
Moves the indicated files from one location to another.

Parameters:
source - The beginning location of the file.
target - The target folder to place the file in.
files - The list of filename to copy.

load

public static void load()
Handles the extracting/loading/accessing of the required natives so that LWJGL can function.