diff options
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/macosx')
8 files changed, 75 insertions, 61 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java index e9b543721..3cd2aa650 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java @@ -116,13 +116,13 @@ public abstract class MacOSXCGLContext extends GLContextImpl } } MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); - GLCapabilities capabilitiesRequested = (GLCapabilities)config.getRequestedCapabilities(); + GLCapabilitiesImmutable capabilitiesRequested = (GLCapabilitiesImmutable) config.getRequestedCapabilities(); GLProfile glProfile = capabilitiesRequested.getGLProfile(); if(glProfile.isGL3()) { throw new GLException("GL3 profile currently not supported on MacOSX, due to the lack of a OpenGL 3.1 implementation"); } // HACK .. bring in OnScreen/PBuffer selection to the DrawableFactory !! - GLCapabilities capabilities = (GLCapabilities) capabilitiesRequested.clone(); + GLCapabilities capabilities = (GLCapabilities) capabilitiesRequested.cloneMutable(); capabilities.setPBuffer(pbuffer); capabilities.setPbufferFloatingPointBuffers(floatingPoint); @@ -154,7 +154,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl CGL.setContextOpacity(contextHandle, 0); } - GLCapabilities caps = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(glProfile, pixelFormat); + GLCapabilitiesImmutable caps = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(glProfile, pixelFormat); config.setChosenCapabilities(caps); } finally { CGL.deletePixelFormat(pixelFormat); @@ -260,7 +260,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl protected void swapBuffers() { DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); - GLCapabilities caps = (GLCapabilities)config.getChosenCapabilities(); + GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)config.getChosenCapabilities(); if(caps.isOnscreen()) { if(isNSContext) { if (!CGL.flushBuffer(contextHandle)) { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java index a8a82b46a..71b99c2d5 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -151,9 +151,9 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { return new MacOSXPbufferCGLDrawable(this, target); } - protected NativeSurface createOffscreenSurfaceImpl(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) { + protected NativeSurface createOffscreenSurfaceImpl(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) { AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_MACOSX); - ProxySurface ns = new ProxySurface(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, screen, true)); + ProxySurface ns = new ProxySurface(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, true)); ns.setSize(width, height); return ns; } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java index d2be9d0de..b912efd1f 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java @@ -42,7 +42,8 @@ import javax.media.opengl.*; public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable { long pixelformat; - public MacOSXCGLGraphicsConfiguration(AbstractGraphicsScreen screen, GLCapabilities capsChosen, GLCapabilities capsRequested, + public MacOSXCGLGraphicsConfiguration(AbstractGraphicsScreen screen, + GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, long pixelformat) { super(screen, capsChosen, capsRequested); this.pixelformat=pixelformat; @@ -56,7 +57,7 @@ public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration this.pixelformat=pixelformat; } - protected void setChosenCapabilities(GLCapabilities caps) { + protected void setChosenCapabilities(GLCapabilitiesImmutable caps) { super.setChosenCapabilities(caps); } @@ -73,7 +74,7 @@ public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration CGL.NSOpenGLPFASampleBuffers, CGL.NSOpenGLPFASamples }; - protected static int[] GLCapabilities2AttribList(GLCapabilities caps) { + protected static int[] GLCapabilities2AttribList(GLCapabilitiesImmutable caps) { int[] ivalues = new int[cglInternalAttributeToken.length]; for (int idx = 0; idx < cglInternalAttributeToken.length; idx++) { @@ -130,20 +131,20 @@ public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration return ivalues; } - protected static long GLCapabilities2NSPixelFormat(GLCapabilities caps) { + protected static long GLCapabilities2NSPixelFormat(GLCapabilitiesImmutable caps) { int[] ivalues = GLCapabilities2AttribList(caps); return CGL.createPixelFormat(cglInternalAttributeToken, 0, cglInternalAttributeToken.length, ivalues, 0); } - protected static GLCapabilities NSPixelFormat2GLCapabilities(GLProfile glp, long pixelFormat) { + protected static GLCapabilitiesImmutable NSPixelFormat2GLCapabilities(GLProfile glp, long pixelFormat) { return PixelFormat2GLCapabilities(glp, pixelFormat, true); } - protected static GLCapabilities CGLPixelFormat2GLCapabilities(GLProfile glp, long pixelFormat) { + protected static GLCapabilitiesImmutable CGLPixelFormat2GLCapabilities(GLProfile glp, long pixelFormat) { return PixelFormat2GLCapabilities(glp, pixelFormat, false); } - private static GLCapabilities PixelFormat2GLCapabilities(GLProfile glp, long pixelFormat, boolean nsUsage) { + private static GLCapabilitiesImmutable PixelFormat2GLCapabilities(GLProfile glp, long pixelFormat, boolean nsUsage) { int[] ivalues = new int[cglInternalAttributeToken.length]; // On this platform the pixel format is associated with the diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java index 69bb245e1..f53fff168 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -32,12 +33,14 @@ package com.jogamp.opengl.impl.macosx.cgl; -import javax.media.nativewindow.*; -import javax.media.nativewindow.macosx.*; -import com.jogamp.nativewindow.impl.*; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.CapabilitiesChooser; +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.*; -import com.jogamp.opengl.impl.*; /** Subclass of GraphicsConfigurationFactory used when non-AWT tookits are used on OSX platforms. Toolkits will likely need to delegate @@ -52,20 +55,25 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GraphicsConfiguration } protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( - Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { - return chooseGraphicsConfigurationStatic(capabilities, chooser, absScreen, false); + CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, + CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { + return chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, absScreen, false); } - protected static MacOSXCGLGraphicsConfiguration chooseGraphicsConfigurationStatic(Capabilities capabilities, - CapabilitiesChooser chooser, - AbstractGraphicsScreen absScreen, boolean usePBuffer) { + protected static MacOSXCGLGraphicsConfiguration chooseGraphicsConfigurationStatic(CapabilitiesImmutable capsChosen, + CapabilitiesImmutable capsRequested, + CapabilitiesChooser chooser, + AbstractGraphicsScreen absScreen, boolean usePBuffer) { if (absScreen == null) { throw new IllegalArgumentException("AbstractGraphicsScreen is null"); } - if (capabilities != null && - !(capabilities instanceof GLCapabilities)) { - throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects"); + if (! (capsChosen instanceof GLCapabilitiesImmutable) ) { + throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - chosen"); + } + + if (! (capsRequested instanceof GLCapabilitiesImmutable) ) { + throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - requested"); } if (chooser != null && @@ -73,11 +81,6 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GraphicsConfiguration throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects"); } - if (capabilities == null) { - capabilities = new GLCapabilities(null); - } - - return new MacOSXCGLGraphicsConfiguration(absScreen, (GLCapabilities)capabilities, (GLCapabilities)capabilities, 0); + return new MacOSXCGLGraphicsConfiguration(absScreen, (GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested, 0); } } - diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java index 5dcc103b2..80a396a29 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java @@ -92,7 +92,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { if (0 == pixelFormat) { throw new GLException("Error: current pixelformat of current Context 0x"+Long.toHexString(contextHandle)+" is null"); } - GLCapabilities caps = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(glp, pixelFormat); + GLCapabilitiesImmutable caps = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(glp, pixelFormat); if(DEBUG) { System.err.println("MacOSXExternalCGLContext Create "+caps); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java index 5cf8c6eb9..93e5767b3 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java @@ -87,7 +87,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext { if (newCreated) { // Initialize render-to-texture support if requested DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); - GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities(); + GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities(); GL gl = getGL(); boolean rect = gl.isGL2GL3() && capabilities.getPbufferRenderToTextureRectangle(); if (rect) { @@ -136,7 +136,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext { protected boolean createImpl() throws GLException { DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); - GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities(); + GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities(); if (capabilities.getPbufferFloatingPointBuffers() && !isTigerOrLater) { throw new GLException("Floating-point pbuffers supported only on OS X 10.4 or later"); @@ -224,7 +224,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext { public boolean isNSContext() { return true; } public long create() { DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); - GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities(); + GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities(); if (capabilities.getPbufferFloatingPointBuffers() && !isTigerOrLater) { throw new GLException("Floating-point pbuffers supported only on OS X 10.4 or later"); @@ -288,7 +288,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext { int i = 0; attrs[i++] = CGL.kCGLPFAPBuffer; DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); - GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities(); + GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities(); if (capabilities.getPbufferFloatingPointBuffers()) attrs[i++] = CGL.kCGLPFAColorFloat; if (capabilities.getDoubleBuffered()) diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java index 14ed02918..37c6cfb70 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -110,7 +110,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { private void createPbuffer() { NativeSurface ns = getNativeSurface(); DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) ns.getGraphicsConfiguration().getNativeGraphicsConfiguration(); - GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities(); + GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities(); GLProfile glProfile = capabilities.getGLProfile(); int renderTarget; if (glProfile.isGL2GL3() && capabilities.getPbufferRenderToTextureRectangle()) { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java index af8841d3d..690e0466b 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -34,17 +35,24 @@ package com.jogamp.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.jogamp.opengl.impl.*; -import com.jogamp.opengl.impl.macosx.cgl.*; -import com.jogamp.nativewindow.impl.jawt.*; -import com.jogamp.nativewindow.impl.jawt.macosx.*; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.CapabilitiesChooser; +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.awt.AWTGraphicsConfiguration; +import javax.media.nativewindow.awt.AWTGraphicsDevice; +import javax.media.nativewindow.awt.AWTGraphicsScreen; +import javax.media.nativewindow.macosx.MacOSXGraphicsDevice; + +import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLException; + +import com.jogamp.opengl.impl.macosx.cgl.MacOSXCGLGraphicsConfiguration; public class MacOSXAWTCGLGraphicsConfigurationFactory extends GraphicsConfigurationFactory { protected static final boolean DEBUG = com.jogamp.opengl.impl.Debug.debug("GraphicsConfiguration"); @@ -54,7 +62,8 @@ public class MacOSXAWTCGLGraphicsConfigurationFactory extends GraphicsConfigurat } protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( - Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { + CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, + CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { GraphicsDevice device = null; if (absScreen != null && !(absScreen instanceof AWTGraphicsScreen)) { @@ -67,9 +76,12 @@ public class MacOSXAWTCGLGraphicsConfigurationFactory extends GraphicsConfigurat 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 ( !(capsChosen instanceof GLCapabilitiesImmutable) ) { + throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects - chosen"); + } + + if ( !(capsRequested instanceof GLCapabilitiesImmutable) ) { + throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects - requested"); } if (chooser != null && @@ -81,8 +93,6 @@ public class MacOSXAWTCGLGraphicsConfigurationFactory extends GraphicsConfigurat System.err.println("MacOSXAWTCGLGraphicsConfigurationFactory: got "+absScreen); } - long displayHandle = 0; - MacOSXGraphicsDevice macDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); DefaultGraphicsScreen macScreen = new DefaultGraphicsScreen(macDevice, awtScreen.getIndex()); if(DEBUG) { @@ -90,18 +100,18 @@ public class MacOSXAWTCGLGraphicsConfigurationFactory extends GraphicsConfigurat } GraphicsConfiguration gc = device.getDefaultConfiguration(); - AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capabilities, gc); + capsChosen = (GLCapabilitiesImmutable) AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capsChosen, gc); if(DEBUG) { - System.err.println("AWT Colormodel compatible: "+capabilities); + System.err.println("AWT Colormodel compatible: "+capsChosen); } MacOSXCGLGraphicsConfiguration macConfig = (MacOSXCGLGraphicsConfiguration) - GraphicsConfigurationFactory.getFactory(macDevice).chooseGraphicsConfiguration(capabilities, - chooser, - macScreen); + GraphicsConfigurationFactory.getFactory(macDevice).chooseGraphicsConfiguration(capsChosen, + capsRequested, + chooser, macScreen); if (macConfig == null) { - throw new GLException("Unable to choose a GraphicsConfiguration: "+capabilities+",\n\t"+chooser+"\n\t"+macScreen); + throw new GLException("Unable to choose a GraphicsConfiguration: "+capsChosen+",\n\t"+chooser+"\n\t"+macScreen); } // FIXME: we have nothing to match .. so choose the default |