diff options
author | Kevin Rushforth <[email protected]> | 2007-03-09 22:19:39 +0000 |
---|---|---|
committer | Kevin Rushforth <[email protected]> | 2007-03-09 22:19:39 +0000 |
commit | 7cf07413d825903f5c3f3c20858fe0432f89c88b (patch) | |
tree | 1ab22b40e07f4671043f9c6a6866d63da0415f31 /src/classes | |
parent | 57eed97fba0f6c94ac4247f55f9600ff26082218 (diff) |
Fixed the Mac OS X build, which was broken as a result of an earlier putback.
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@796 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/classes')
-rw-r--r-- | src/classes/share/javax/media/j3d/Pipeline.java | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/src/classes/share/javax/media/j3d/Pipeline.java b/src/classes/share/javax/media/j3d/Pipeline.java index dd413ef..f20628a 100644 --- a/src/classes/share/javax/media/j3d/Pipeline.java +++ b/src/classes/share/javax/media/j3d/Pipeline.java @@ -14,15 +14,13 @@ package javax.media.j3d; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; +import java.lang.reflect.Method; /** * Abstract pipeline class for rendering pipeline methods. All rendering * pipeline methods are defined here. */ abstract class Pipeline { - // Singleton pipeline instance - private static Pipeline pipeline; - // Supported rendering pipelines enum Type { // Native rendering pipelines using OGL or D3D library @@ -36,9 +34,20 @@ abstract class Pipeline { NOOP, } + private static final String CLASSNAME_NATIVE = "javax.media.j3d.NativePipeline"; + private static final String CLASSNAME_JOGL = "javax.media.j3d.JoglPipeline"; + private static final String CLASSNAME_NOOP = "javax.media.j3d.NoopPipeline"; + + // Singleton pipeline instance + private static Pipeline pipeline; + // Type of rendering pipeline (as defined above) private Type pipelineType = null; + /** + * An instance of a specific Pipeline subclass should only be constructed + * // from the createPipeline method. + */ protected Pipeline() { } @@ -48,7 +57,7 @@ abstract class Pipeline { */ static boolean useNativeOgl(boolean isWindowsVista, boolean nativeOglRequested) { // Get the OpenGL vendor string. - String vendorString = NativePipeline.getSupportedOglVendor(); + String vendorString = getSupportedOglVendor(); // A null vendor string means OpenGL 1.2+ support unavailable. if (vendorString == null) { @@ -63,6 +72,37 @@ abstract class Pipeline { // Check OS type and vendor string to see whether OGL is preferred return preferOgl(isWindowsVista, vendorString); } + + /** + * Wrapper method that calls the corresponding NativePipeline method via + * reflection. We use reflection to avoid initializing the NativePipeline + * class uless we are actually going to call it. + */ + private static String getSupportedOglVendor() { + try { + Method nativeMethod = (Method) + java.security.AccessController.doPrivileged(new + java.security.PrivilegedAction() { + public Object run() { + try { + Class pipelineClass = Class.forName(CLASSNAME_NATIVE); + return pipelineClass.getDeclaredMethod("getSupportedOglVendor"); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + }); + + String vendorString = (String) nativeMethod.invoke(null); + return vendorString; + } catch (Exception ex) { + System.err.println(ex); + } catch (Error ex) { + System.err.println(ex); + } + + return null; + } // Returns a flag inticating whether the specified vendor prefers OpenGL. private static boolean preferOgl(boolean isWindowsVista, String vendorString) { @@ -103,13 +143,13 @@ abstract class Pipeline { switch (pipelineType) { case NATIVE_OGL: case NATIVE_D3D: - className = "javax.media.j3d.NativePipeline"; + className = CLASSNAME_NATIVE; break; case JOGL: - className = "javax.media.j3d.JoglPipeline"; + className = CLASSNAME_JOGL; break; case NOOP: - className = "javax.media.j3d.NoopPipeline"; + className = CLASSNAME_NOOP; break; default: // Should not get here |