aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/sun
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-06-03 22:51:34 +0000
committerSven Gothel <[email protected]>2009-06-03 22:51:34 +0000
commit0c88b63fc45602d4ceabda377d03a6b9a4b289db (patch)
treef760fab5e7cd23cf7f2eebd21e85b608765f1afa /src/jogl/classes/com/sun
parentaf23607f257b01777d52c93f8908912d1ae8c8bb (diff)
Add MacOSX support / tested on one thread
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1923 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/jogl/classes/com/sun')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java9
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java8
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java112
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java3
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java6
5 files changed, 127 insertions, 11 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
index 36d9280e4..2c0891344 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -45,20 +45,29 @@ import java.util.*;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.sun.opengl.impl.*;
+import com.sun.nativewindow.impl.*;
public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
+ protected static final boolean DEBUG = com.sun.opengl.impl.Debug.debug("GraphicsConfiguration");
+
public MacOSXCGLDrawableFactory() {
super();
// Register our GraphicsConfigurationFactory implementations
// The act of constructing them causes them to be registered
new MacOSXCGLGraphicsConfigurationFactory();
+
+ try {
+ NWReflection.createInstance("com.sun.opengl.impl.macosx.cgl.awt.MacOSXAWTCGLGraphicsConfigurationFactory",
+ new Object[] {});
+ } catch (Throwable t) { }
}
public GLDrawable createGLDrawable(NativeWindow target) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
+ NativeWindowFactory factory = NativeWindowFactory.getFactory(target.getClass());
target = NativeWindowFactory.getNativeWindow(target, null);
return new MacOSXOnscreenCGLDrawable(this, target);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
index 8b33fefc4..3c797fb75 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
@@ -33,6 +33,7 @@
package com.sun.opengl.impl.macosx.cgl;
import javax.media.nativewindow.*;
+import javax.media.nativewindow.macosx.*;
import com.sun.nativewindow.impl.*;
import javax.media.opengl.*;
@@ -44,13 +45,10 @@ import com.sun.opengl.impl.*;
GraphicsDevice and GraphicsConfiguration abstractions. */
public class MacOSXCGLGraphicsConfigurationFactory extends GraphicsConfigurationFactory {
+ protected static final boolean DEBUG = com.sun.opengl.impl.Debug.debug("GraphicsConfiguration");
public MacOSXCGLGraphicsConfigurationFactory() {
- Class awtDeviceClass = NWReflection.getClass("javax.media.nativewindow.awt.AWTGraphicsDevice");
- if(null!=awtDeviceClass) {
- GraphicsConfigurationFactory.registerFactory(awtDeviceClass, this);
- }
- GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.AbstractGraphicsDevice.class, this);
+ GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.macosx.MacOSXGraphicsDevice.class, this);
}
public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
new file mode 100644
index 000000000..b1e37f12c
--- /dev/null
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.sun.opengl.impl.macosx.cgl.awt;
+
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.macosx.*;
+import javax.media.nativewindow.awt.*;
+import javax.media.opengl.*;
+import javax.media.opengl.awt.*;
+
+import com.sun.opengl.impl.*;
+import com.sun.opengl.impl.macosx.cgl.*;
+import com.sun.nativewindow.impl.jawt.*;
+import com.sun.nativewindow.impl.jawt.macosx.*;
+
+public class MacOSXAWTCGLGraphicsConfigurationFactory extends GraphicsConfigurationFactory {
+ protected static final boolean DEBUG = com.sun.opengl.impl.Debug.debug("GraphicsConfiguration");
+
+ public MacOSXAWTCGLGraphicsConfigurationFactory() {
+ GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, this);
+ }
+
+ public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
+ CapabilitiesChooser chooser,
+ AbstractGraphicsScreen absScreen) {
+ GraphicsDevice device = null;
+ if (absScreen != null &&
+ !(absScreen instanceof AWTGraphicsScreen)) {
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only AWTGraphicsScreen objects");
+ }
+
+ if(null==absScreen) {
+ absScreen = AWTGraphicsScreen.createScreenDevice(-1);
+ }
+ AWTGraphicsScreen awtScreen = (AWTGraphicsScreen) absScreen;
+ device = ((AWTGraphicsDevice)awtScreen.getDevice()).getGraphicsDevice();
+
+ if (capabilities != null &&
+ !(capabilities instanceof GLCapabilities)) {
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects");
+ }
+
+ if (chooser != null &&
+ !(chooser instanceof GLCapabilitiesChooser)) {
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilitiesChooser objects");
+ }
+
+ if(DEBUG) {
+ System.err.println("MacOSXAWTCGLGraphicsConfigurationFactory: got "+absScreen);
+ }
+
+ long displayHandle = 0;
+
+ MacOSXGraphicsDevice macDevice = new MacOSXGraphicsDevice();
+ DefaultGraphicsScreen macScreen = new DefaultGraphicsScreen(macDevice, awtScreen.getIndex());
+ if(DEBUG) {
+ System.err.println("MacOSXAWTCGLGraphicsConfigurationFactory: made "+macScreen);
+ }
+
+ MacOSXCGLGraphicsConfiguration macConfig = (MacOSXCGLGraphicsConfiguration)
+ GraphicsConfigurationFactory.getFactory(macDevice).chooseGraphicsConfiguration(capabilities,
+ chooser,
+ macScreen);
+ if (macConfig != null) {
+ // FIXME: we have nothing to match .. so choose the 1st
+ GraphicsConfiguration[] configs = device.getConfigurations();
+ if(configs.length>0) {
+ return new AWTGraphicsConfiguration(awtScreen, macConfig.getCapabilities(), configs[0], macConfig);
+ }
+ }
+
+ // Either we weren't able to reflectively introspect on the
+ // X11GraphicsConfig or something went wrong in the steps above;
+ // we're going to return null without signaling an error condition
+ // in this case (although we should distinguish between the two
+ // and possibly report more of an error in the latter case)
+ return null;
+ }
+}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 48ccaa8da..27568cbaa 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -50,8 +50,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
public X11GLXGraphicsConfigurationFactory() {
- GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.x11.X11GraphicsDevice.class,
- this);
+ GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.x11.X11GraphicsDevice.class, this);
}
public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
index 08ae19e17..e21bf96f9 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
@@ -52,8 +52,7 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration
protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
public X11AWTGLXGraphicsConfigurationFactory() {
- GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class,
- this);
+ GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, this);
}
public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
@@ -82,8 +81,7 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration
}
if(DEBUG) {
- Exception e = new Exception("X11AWTGLXGraphicsConfigurationFactory: got "+absScreen);
- e.printStackTrace();
+ System.err.println("X11AWTGLXGraphicsConfigurationFactory: got "+absScreen);
}
long displayHandle = 0;
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();