From 7c159772fad5445d296ad0f06f07272a59325003 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 18 Nov 2010 00:41:57 +0100 Subject: NEWT: Adding CapabilitiesChooser setter and using it in createNativeImpl() .. --- src/newt/classes/com/jogamp/newt/Window.java | 9 +++++++++ .../classes/com/jogamp/newt/impl/OffscreenWindow.java | 2 +- src/newt/classes/com/jogamp/newt/impl/WindowImpl.java | 8 ++++++++ src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java | 15 ++++++++++----- src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java | 2 +- .../classes/com/jogamp/newt/impl/intel/gdl/Window.java | 3 ++- .../classes/com/jogamp/newt/impl/macosx/MacWindow.java | 2 +- .../com/jogamp/newt/impl/opengl/broadcom/egl/Window.java | 2 +- .../classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java | 2 +- .../com/jogamp/newt/impl/windows/WindowsWindow.java | 2 +- src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java | 2 +- src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 4 ++++ 12 files changed, 40 insertions(+), 13 deletions(-) (limited to 'src/newt/classes/com/jogamp') diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 13cc0e098..8b9e7bb4e 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -33,6 +33,7 @@ import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.event.ScreenModeListener; import com.jogamp.newt.impl.Debug; +import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.SurfaceUpdatedListener; @@ -78,6 +79,14 @@ public interface Window extends NativeWindow, ScreenModeListener { */ Screen getScreen(); + /** + * Set the CapabilitiesChooser to help determine the native visual type. + * + * @param chooser the new CapabilitiesChooser + * @return the previous CapabilitiesChooser + */ + CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser); + /** * Gets an immutable set of requested capabilities. * diff --git a/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java b/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java index 6e827dd77..44aa9b440 100644 --- a/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java +++ b/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java @@ -55,7 +55,7 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { } AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); config = GraphicsConfigurationFactory.getFactory(aScreen.getDevice()).chooseGraphicsConfiguration( - capsRequested, capsRequested, null, aScreen); + capsRequested, capsRequested, capabilitiesChooser, aScreen); if (config == null) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } diff --git a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java index 30b17c575..098c84da5 100644 --- a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java +++ b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java @@ -56,6 +56,7 @@ import java.util.ArrayList; import java.lang.reflect.Method; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindow; @@ -79,6 +80,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod private long parentWindowHandle; protected AbstractGraphicsConfiguration config; protected CapabilitiesImmutable capsRequested; + protected CapabilitiesChooser capabilitiesChooser = null; // default null -> default protected boolean fullscreen, visible, hasFocus; protected int width, height, x, y; protected int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen dimensions .. @@ -1145,6 +1147,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod return reparentActionStrategy; } + public CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser) { + CapabilitiesChooser old = this.capabilitiesChooser; + this.capabilitiesChooser = chooser; + return old; + } + public final CapabilitiesImmutable getChosenCapabilities() { return config.getNativeGraphicsConfiguration().getChosenCapabilities(); } diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java index 169b7bc3a..f17e530d5 100644 --- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java +++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java @@ -50,17 +50,19 @@ public class AWTCanvas extends Canvas { private GraphicsConfiguration chosen; private AWTGraphicsConfiguration awtConfig; + private CapabilitiesChooser chooser=null; private CapabilitiesImmutable capabilities; private boolean displayConfigChanged=false; - public AWTCanvas(CapabilitiesImmutable capabilities) { + public AWTCanvas(CapabilitiesImmutable capabilities, CapabilitiesChooser chooser) { super(); if(null==capabilities) { throw new NativeWindowException("Capabilities null"); } this.capabilities=capabilities; + this.chooser=chooser; } public AWTGraphicsConfiguration getAWTGraphicsConfiguration() { @@ -86,7 +88,7 @@ public class AWTCanvas extends Canvas { /* * Save the chosen capabilities for use in getGraphicsConfiguration(). */ - awtConfig = chooseGraphicsConfiguration(capabilities, capabilities, device); + awtConfig = chooseGraphicsConfiguration(capabilities, capabilities, chooser, device); if(Window.DEBUG_IMPLEMENTATION) { Exception e = new Exception("Info: Created Config: "+awtConfig); e.printStackTrace(); @@ -174,7 +176,8 @@ public class AWTCanvas extends Canvas { * block, both devices should have the same visual list, and the * same configuration should be selected here. */ - AWTGraphicsConfiguration config = chooseGraphicsConfiguration(awtConfig.getChosenCapabilities(), awtConfig.getRequestedCapabilities(), gc.getDevice()); + AWTGraphicsConfiguration config = chooseGraphicsConfiguration( + awtConfig.getChosenCapabilities(), awtConfig.getRequestedCapabilities(), chooser, gc.getDevice()); final GraphicsConfiguration compatible = (null!=config)?config.getGraphicsConfiguration():null; if(Window.DEBUG_IMPLEMENTATION) { Exception e = new Exception("Info: Call Stack: "+Thread.currentThread().getName()); @@ -227,11 +230,13 @@ public class AWTCanvas extends Canvas { private static AWTGraphicsConfiguration chooseGraphicsConfiguration(CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, + CapabilitiesChooser chooser, GraphicsDevice device) { AbstractGraphicsScreen aScreen = AWTGraphicsScreen.createScreenDevice(device, AbstractGraphicsDevice.DEFAULT_UNIT); AWTGraphicsConfiguration config = (AWTGraphicsConfiguration) - GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class).chooseGraphicsConfiguration(capsChosen, capsRequested, - null, aScreen); + GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class).chooseGraphicsConfiguration(capsChosen, + capsRequested, + chooser, aScreen); if (config == null) { throw new NativeWindowException("Error: Couldn't fetch AWTGraphicsConfiguration"); } diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java index 7aa5874c4..ec1ae1c8a 100644 --- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java +++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java @@ -119,7 +119,7 @@ public class AWTWindow extends WindowImpl { frame.setTitle(getTitle()); } container.setLayout(new BorderLayout()); - canvas = new AWTCanvas(capsRequested); + canvas = new AWTCanvas(capsRequested, AWTWindow.this.capabilitiesChooser); addWindowListener(new LocalWindowListener()); diff --git a/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java b/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java index 613d9eb02..c9a322942 100644 --- a/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java +++ b/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java @@ -53,7 +53,8 @@ public class Window extends com.jogamp.newt.impl.WindowImpl { AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); AbstractGraphicsDevice aDevice = getScreen().getDisplay().getGraphicsDevice(); - config = GraphicsConfigurationFactory.getFactory(aDevice).chooseGraphicsConfiguration(capsRequested, capsRequested, null, aScreen); + config = GraphicsConfigurationFactory.getFactory(aDevice).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, aScreen); if (config == null) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } diff --git a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java index 3d1f52eed..c01139b78 100644 --- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java +++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java @@ -144,7 +144,7 @@ public class MacWindow extends WindowImpl { protected void createNativeImpl() { config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration( - capsRequested, capsRequested, null, getScreen().getGraphicsScreen()); + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen()); if (config == null) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } diff --git a/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java b/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java index 6548cf6c4..cfc5bd5a9 100644 --- a/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java +++ b/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java @@ -54,7 +54,7 @@ public class Window extends com.jogamp.newt.impl.WindowImpl { // query a good configuration .. even thought we drop this one // and reuse the EGLUtil choosen one later. config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration( - capsRequested, capsRequested, null, getScreen().getGraphicsScreen()); + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen()); if (config == null) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } diff --git a/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java b/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java index eb03dc9dc..b49b6f7b7 100644 --- a/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java +++ b/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java @@ -55,7 +55,7 @@ public class KDWindow extends WindowImpl { throw new RuntimeException("Window parenting not supported (yet)"); } config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration( - capsRequested, capsRequested, null, getScreen().getGraphicsScreen()); + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen()); if (config == null) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } diff --git a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java index b188a580e..5d7bcd7b3 100644 --- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java +++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java @@ -93,7 +93,7 @@ public class WindowsWindow extends WindowImpl { WindowsScreen screen = (WindowsScreen) getScreen(); WindowsDisplay display = (WindowsDisplay) screen.getDisplay(); config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration( - capsRequested, capsRequested, null, screen.getGraphicsScreen()); + capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen()); if (config == null) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } diff --git a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java index e81acee3e..73c6eb351 100644 --- a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java +++ b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java @@ -53,7 +53,7 @@ public class X11Window extends WindowImpl { X11Screen screen = (X11Screen) getScreen(); X11Display display = (X11Display) screen.getDisplay(); config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration( - capsRequested, capsRequested, null, screen.getGraphicsScreen()); + capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen()); if (config == null) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index d6da09bec..6c0635006 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -140,6 +140,10 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer { // Window Access // + public CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser) { + return window.setCapabilitiesChooser(chooser); + } + public final CapabilitiesImmutable getChosenCapabilities() { if (drawable == null) { return window.getChosenCapabilities(); -- cgit v1.2.3