The org.lwjgl.Sys allows the developer to access a series of system dependent operations in a controlled manner.
The Sys class allows you to display system error message when things go wrong. This is useful for all out error cases such as not being able to find a valid display mode or corrupt installations.
Sys.alert("Something Went Wrong", "Something went wrong and we don't know what to do!");
In addition to open alert dialogs the Sys class supports opening a web URL in the standard system browser. This is often useful for Nag screens or registration pages.
// note the operation can fail if the system can't manage to open a URL. if (!Sys.openURL("http://www.lwjgl.org")) { Sys.alert("Failed to open browser, please browse to: http://www.lwjgl.org"); }
Finally the Sys class allows access to the system clipboard. Although this is possible in normal Java it can be a bit tricky. The following simple utility method gets the contents of the clipboard or returns null if there is no clipboard on the current system.
String contents = Sys.getClipboard(); System.out.println("Clipboard contents were: " + contents);
In most games a crucial element is accurate timing. However, until Java 1.5 the Java SDK did not provide a way to get millisecond accurate timing. While System.currentTimeMillis() would appear to give this on windows the implementation was prone to be much less than millisecond resolution - in the range of 16ms.
The timer provided by LWJGL gives accurate timing on all platforms.
The timer returns the time in “ticks” which are entirely system dependent. To convert from this value to milliseconds the following code can be used:
/** * Get the accurate system time * * @return The system time in milliseconds */ public static long getTime() { return (Sys.getTime() * 1000) / Sys.getTimerResolution(); }