Remove the rest of the implementation reflection

This commit is contained in:
Elias Naur 2007-01-17 12:58:38 +00:00
parent 7742185e34
commit 083137884b
4 changed files with 17 additions and 52 deletions

View File

@ -108,7 +108,6 @@ public final class Sys {
} }
private static SysImplementation createImplementation() { private static SysImplementation createImplementation() {
String class_name;
switch (LWJGLUtil.getPlatform()) { switch (LWJGLUtil.getPlatform()) {
case LWJGLUtil.PLATFORM_LINUX: case LWJGLUtil.PLATFORM_LINUX:
return new LinuxSysImplementation(); return new LinuxSysImplementation();

View File

@ -86,30 +86,20 @@ public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener,
static { static {
Sys.initialize(); Sys.initialize();
String class_name; implementation = createImplementation();
}
private static AWTCanvasImplementation createImplementation() {
switch (LWJGLUtil.getPlatform()) { switch (LWJGLUtil.getPlatform()) {
case LWJGLUtil.PLATFORM_LINUX: case LWJGLUtil.PLATFORM_LINUX:
class_name = "org.lwjgl.opengl.LinuxCanvasImplementation"; return new LinuxCanvasImplementation();
break;
case LWJGLUtil.PLATFORM_WINDOWS: case LWJGLUtil.PLATFORM_WINDOWS:
class_name = "org.lwjgl.opengl.WindowsCanvasImplementation"; return new WindowsCanvasImplementation();
break;
case LWJGLUtil.PLATFORM_MACOSX: case LWJGLUtil.PLATFORM_MACOSX:
class_name = "org.lwjgl.opengl.MacOSXCanvasImplementation"; return new MacOSXCanvasImplementation();
break;
default: default:
throw new IllegalStateException("Unsupported platform"); throw new IllegalStateException("Unsupported platform");
} }
try {
Class impl_class = Class.forName(class_name);
implementation = (AWTCanvasImplementation)impl_class.newInstance();
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
}
} }
/** /**

View File

@ -73,30 +73,20 @@ final class Context {
static { static {
Sys.initialize(); Sys.initialize();
String class_name; implementation = createImplementation();
}
private static ContextImplementation createImplementation() {
switch (LWJGLUtil.getPlatform()) { switch (LWJGLUtil.getPlatform()) {
case LWJGLUtil.PLATFORM_LINUX: case LWJGLUtil.PLATFORM_LINUX:
class_name = "org.lwjgl.opengl.LinuxContextImplementation"; return new LinuxContextImplementation();
break;
case LWJGLUtil.PLATFORM_WINDOWS: case LWJGLUtil.PLATFORM_WINDOWS:
class_name = "org.lwjgl.opengl.WindowsContextImplementation"; return new WindowsContextImplementation();
break;
case LWJGLUtil.PLATFORM_MACOSX: case LWJGLUtil.PLATFORM_MACOSX:
class_name = "org.lwjgl.opengl.MacOSXContextImplementation"; return new MacOSXContextImplementation();
break;
default: default:
throw new IllegalStateException("Unsupported platform"); throw new IllegalStateException("Unsupported platform");
} }
try {
Class impl_class = Class.forName(class_name);
implementation = (ContextImplementation)impl_class.newInstance();
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
}
} }
PeerInfo getPeerInfo() { PeerInfo getPeerInfo() {

View File

@ -133,30 +133,16 @@ public final class Display {
} }
private static DisplayImplementation createDisplayImplementation() { private static DisplayImplementation createDisplayImplementation() {
String class_name;
switch (LWJGLUtil.getPlatform()) { switch (LWJGLUtil.getPlatform()) {
case LWJGLUtil.PLATFORM_LINUX: case LWJGLUtil.PLATFORM_LINUX:
class_name = "org.lwjgl.opengl.LinuxDisplay"; return new LinuxDisplay();
break;
case LWJGLUtil.PLATFORM_WINDOWS: case LWJGLUtil.PLATFORM_WINDOWS:
class_name = "org.lwjgl.opengl.WindowsDisplay"; return new WindowsDisplay();
break;
case LWJGLUtil.PLATFORM_MACOSX: case LWJGLUtil.PLATFORM_MACOSX:
class_name = "org.lwjgl.opengl.MacOSXDisplay"; return new MacOSXDisplay();
break;
default: default:
throw new IllegalStateException("Unsupported platform"); throw new IllegalStateException("Unsupported platform");
} }
try {
Class display_class = Class.forName(class_name);
return (DisplayImplementation)display_class.newInstance();
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
}
} }
/** /**