All classes use Sys.initialize now

This commit is contained in:
Elias Naur 2004-03-27 13:48:58 +00:00
parent c093f3ace1
commit b98677fb47
14 changed files with 1285 additions and 1308 deletions

View File

@ -75,7 +75,7 @@ public final class Display {
public static final int PLATFORM_AGL = 2;
static {
System.loadLibrary(Sys.getLibraryName());
Sys.initialize();
init();
Sys.log("Adapter: "+getAdapter()+" Version: "+getVersion());
}

View File

@ -87,6 +87,8 @@ public final class Sys {
*/
public static final boolean DEBUG = Boolean.getBoolean("org.lwjgl.Sys.debug");
private static boolean initialized = false;
static {
initialize();
@ -123,7 +125,10 @@ public final class Sys {
/**
* Initialization.
*/
private static void initialize() {
public static void initialize() {
if (initialized)
return;
initialized = true;
System.loadLibrary(LIBRARY_NAME);
setDebug(DEBUG);
setTime(0);

View File

@ -146,7 +146,9 @@ public class Controller {
* Static initialization
*/
private static void initialize() {
System.loadLibrary(Sys.getLibraryName());
if (initialized)
return;
Sys.initialize();
initIDs();
// Assign names to all the buttons
@ -166,9 +168,7 @@ public class Controller {
public static void create() throws Exception {
if (!Window.isCreated())
throw new IllegalStateException("Window must be created before you can create Controller");
if (!initialized) {
initialize();
}
initialize();
if (created) {
return;

View File

@ -49,10 +49,6 @@ import org.lwjgl.Sys;
*/
public class Cursor {
/** Lazy initialization */
private static boolean initialized = false;
/** First element to display */
private CursorElement[] cursors = null;
@ -86,10 +82,7 @@ public class Cursor {
if (yHotspot >= height || yHotspot < 0)
throw new IllegalArgumentException("yHotspot > height || yHotspot < 0");
// initialize
if (!initialized) {
initialize();
}
Sys.initialize();
// Hmm
yHotspot = height - 1 - yHotspot;
@ -98,14 +91,6 @@ public class Cursor {
createCursors(width, height, xHotspot, yHotspot, numImages, images, delays);
}
/**
* Initializes the cursor class
*/
private static void initialize() {
System.loadLibrary(Sys.getLibraryName());
initialized = true;
}
/**
* Creates the actual cursor, using a platform specific class
*/

View File

@ -268,7 +268,9 @@ public class Keyboard {
* Static initialization
*/
private static void initialize() {
System.loadLibrary(Sys.getLibraryName());
if (initialized)
return;
Sys.initialize();
initIDs();
initialized = true;
}

View File

@ -217,7 +217,7 @@ public class Mouse {
* Static initialization
*/
private static void initialize() {
System.loadLibrary(Sys.getLibraryName());
Sys.initialize();
initIDs();
// Assign names to all the buttons
@ -245,9 +245,7 @@ public class Mouse {
if (!Window.isCreated())
throw new IllegalStateException("Window must be created prior to creating mouse");
if (!initialized) {
initialize();
}
initialize();
if (created) {
return;
}

View File

@ -77,14 +77,7 @@ public abstract class AL {
protected static boolean created;
static {
initialize();
}
/**
* Static initialization
*/
private static void initialize() {
System.loadLibrary(org.lwjgl.Sys.getLibraryName());
Sys.initialize();
}
/**

View File

@ -34,6 +34,8 @@ package org.lwjgl.openal;
import java.nio.Buffer;
import java.nio.IntBuffer;
import org.lwjgl.Sys;
/**
* $Id$
*
@ -140,7 +142,7 @@ public class ALC {
public static final int ALC_OUT_OF_MEMORY = 0xA005;
static {
initialize();
Sys.initialize();
}
/** Creates a new instance of ALC */
@ -153,13 +155,6 @@ public class ALC {
protected static void init() {
}
/**
* Static initialization
*/
private static void initialize() {
System.loadLibrary(org.lwjgl.Sys.getLibraryName());
}
/**
* Creates the ALC instance
*

View File

@ -29,7 +29,10 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.openal.eax;
package org.lwjgl.openal.eax;
import org.lwjgl.Sys;
/**
* $Id$
@ -40,65 +43,57 @@
* @version $Revision$
*/
public class EAX {
/** Has the EAX object been created? */
protected static boolean created;
static {
Sys.initialize();
}
/** Has the EAX object been created? */
protected static boolean created;
static {
initialize();
}
/**
* Loads the EAX functions
*
* @throws Exception if the EAX extensions couldn't be loaded
*/
public static void create() throws Exception {
if (created) {
return;
}
/**
* Static initialization
*/
private static void initialize() {
System.loadLibrary(org.lwjgl.Sys.getLibraryName());
}
if (!nCreate()) {
throw new Exception("EAX instance could not be created.");
}
EAX20.init();
created = true;
}
/**
* Loads the EAX functions
*
* @throws Exception if the EAX extensions couldn't be loaded
*/
public static void create() throws Exception {
if (created) {
return;
}
/**
* Native method to create EAX instance
*
* @return true if the EAX extensions could be found
*/
protected static native boolean nCreate();
if (!nCreate()) {
throw new Exception("EAX instance could not be created.");
}
EAX20.init();
created = true;
}
/**
* "Destroy" the EAX object
*/
public static void destroy() {
if (!created) {
return;
}
created = false;
nDestroy();
}
/**
* Native method to create EAX instance
*
* @return true if the EAX extensions could be found
*/
protected static native boolean nCreate();
/**
* "Destroy" the EAX object
*/
public static void destroy() {
if (!created) {
return;
}
created = false;
nDestroy();
}
/**
* Native method the destroy the EAX
*/
protected static native void nDestroy();
/**
* @return true if EAX has been created
*/
public static boolean isCreated() {
return created;
}
}
/**
* Native method the destroy the EAX
*/
protected static native void nDestroy();
/**
* @return true if EAX has been created
*/
public static boolean isCreated() {
return created;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -167,7 +167,7 @@ public final class GLContext {
public static boolean OpenGL15;
static {
System.loadLibrary(Sys.getLibraryName());
Sys.initialize();
}
/**

View File

@ -155,7 +155,7 @@ public final class Pbuffer {
private final int height;
static {
System.loadLibrary(Sys.getLibraryName());
Sys.initialize();
}
/**

View File

@ -56,7 +56,7 @@ import org.lwjgl.input.Mouse;
public final class Window {
static {
System.loadLibrary(Sys.getLibraryName());
Sys.initialize();
}
/** X coordinate of the window */