aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/impl/windows
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-11-17 21:53:16 +0100
committerSven Gothel <[email protected]>2010-11-17 21:53:16 +0100
commit29e3b223eae9f5775d1dd34f2aaeeb3db6d9233c (patch)
treeeae2c7d60a4cdbcdacd4057b020044bd42fb30b8 /src/jogl/classes/com/jogamp/opengl/impl/windows
parent64aa219406c1aa1d6022fedce7a52c8c19d0e35d (diff)
Finishing Immutable changes including GLCapabiltiesImmutable.
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/windows')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java20
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java8
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java9
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java39
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java62
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java56
9 files changed, 117 insertions, 87 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
index 3f7028d56..054c01fdb 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
@@ -40,7 +40,6 @@
package com.jogamp.opengl.impl.windows.wgl;
-import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLProfile;
@@ -48,12 +47,14 @@ import javax.media.opengl.GLProfile;
import com.jogamp.nativewindow.impl.ProxySurface;
import com.jogamp.nativewindow.impl.windows.GDI;
import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
private long hwnd, hdc;
- public WindowsDummyWGLDrawable(GLDrawableFactory factory, GLProfile glp) {
- super(factory, new ProxySurface(WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(glp, null, true, true)), true);
+ protected WindowsDummyWGLDrawable(GLDrawableFactory factory, GLCapabilitiesImmutable caps) {
+ super(factory, new ProxySurface(WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(caps, null)), true);
// All entries to CreateDummyWindow must synchronize on one object
// to avoid accidentally registering the dummy window class twice
synchronized (WindowsDummyWGLDrawable.class) {
@@ -64,9 +65,7 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
ns.setSurfaceHandle(hdc);
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
// Choose a (hopefully hardware-accelerated) OpenGL pixel format for this device context
- GLCapabilities caps = (GLCapabilities) config.getChosenCapabilities();
- caps.setDepthBits(16);
- PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps);
+ PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.GLCapabilities2PFD((GLCapabilitiesImmutable)config.getChosenCapabilities());
int pixelFormat = GDI.ChoosePixelFormat(hdc, pfd);
if ((pixelFormat == 0) ||
(!GDI.SetPixelFormat(hdc, pixelFormat, pfd))) {
@@ -74,6 +73,15 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
}
}
+ public static WindowsDummyWGLDrawable create(GLDrawableFactory factory, GLProfile glp) {
+ GLCapabilities caps = new GLCapabilities(glp);
+ caps.setDepthBits(16);
+ caps.setDoubleBuffered(true);
+ caps.setOnscreen (true);
+ caps.setPBuffer (true);
+ return new WindowsDummyWGLDrawable(factory, caps);
+ }
+
public void setSize(int width, int height) {
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
index 8bb781a45..3452d3b55 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
@@ -42,7 +42,6 @@ package com.jogamp.opengl.impl.windows.wgl;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.SurfaceChangeable;
-import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLException;
@@ -50,6 +49,7 @@ import javax.media.opengl.GLException;
import com.jogamp.nativewindow.impl.windows.BITMAPINFO;
import com.jogamp.nativewindow.impl.windows.BITMAPINFOHEADER;
import com.jogamp.nativewindow.impl.windows.GDI;
+import javax.media.opengl.GLCapabilitiesImmutable;
public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
private long origbitmap;
@@ -75,7 +75,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
private void create() {
NativeSurface ns = getNativeSurface();
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getRequestedCapabilities();
+ GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getRequestedCapabilities();
int width = getWidth();
int height = getHeight();
BITMAPINFO info = BITMAPINFO.create();
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
index abbaf5004..db86b3232 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
@@ -89,7 +89,7 @@ public class WindowsPbufferWGLContext extends WindowsWGLContext {
protected void makeCurrentImpl(boolean newCreated) throws GLException {
super.makeCurrentImpl(newCreated);
if (newCreated) {
- GLCapabilities capabilities = drawable.getChosenGLCapabilities();
+ GLCapabilitiesImmutable capabilities = drawable.getChosenGLCapabilities();
// Initialize render-to-texture support if requested
GL gl = getGL();
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
index a5631aded..751ae5380 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -43,7 +43,6 @@ package com.jogamp.opengl.impl.windows.wgl;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.SurfaceChangeable;
import javax.media.opengl.GL;
-import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLException;
@@ -52,6 +51,7 @@ import javax.media.opengl.GLProfile;
import com.jogamp.nativewindow.impl.windows.GDI;
import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR;
+import javax.media.opengl.GLCapabilitiesImmutable;
public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
private WGLExt cachedWGLExt; // cached WGLExt instance from parent GLCanvas,
@@ -134,7 +134,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
int width, height;
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getRequestedCapabilities();
+ GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getRequestedCapabilities();
GLProfile glProfile = capabilities.getGLProfile();
if (DEBUG) {
@@ -302,7 +302,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_PBUFFER_ARB;
int[] ivalues = new int[niattribs];
if (wglExt.wglGetPixelFormatAttribivARB(parentHdc, pformats[whichFormat], 0, niattribs, iattributes, 0, ivalues, 0)) {
- GLCapabilities newCaps = WindowsWGLGraphicsConfiguration.AttribList2GLCapabilities(glProfile, iattributes, niattribs, ivalues, true, false, true);
+ GLCapabilitiesImmutable newCaps = WindowsWGLGraphicsConfiguration.AttribList2GLCapabilities(glProfile, iattributes, niattribs, ivalues, true, false, true);
PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor();
if (GDI.DescribePixelFormat(parentHdc, pformats[whichFormat], pfd.size(), pfd) == 0) {
if (DEBUG) {
@@ -318,7 +318,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
if (GDI.DescribePixelFormat(parentHdc, pformats[whichFormat], pfd.size(), pfd) == 0) {
throw new GLException("Unable to describe pixel format " + pformats[whichFormat]);
}
- GLCapabilities newCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, pfd, false, true);
+ GLCapabilitiesImmutable newCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, pfd, false, true);
if(newCaps.isOnscreen()) {
throw new GLException("Error: Selected Onscreen Caps for PBuffer: "+newCaps+"\n\t"+newCaps);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
index 529fda2c9..816532262 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -46,7 +46,6 @@ import java.util.Map;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
-import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLException;
@@ -56,6 +55,7 @@ import com.jogamp.nativewindow.impl.windows.GDI;
import com.jogamp.opengl.impl.GLContextImpl;
import com.jogamp.opengl.impl.GLContextShareSet;
import com.jogamp.opengl.impl.GLDrawableImpl;
+import javax.media.opengl.GLCapabilitiesImmutable;
public class WindowsWGLContext extends GLContextImpl {
@@ -232,7 +232,7 @@ public class WindowsWGLContext extends GLContextImpl {
AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
AbstractGraphicsDevice device = config.getScreen().getDevice();
WindowsWGLContext sharedContext = (WindowsWGLContext) factory.getOrCreateSharedContextImpl(device);
- GLCapabilities glCaps = drawable.getChosenGLCapabilities();
+ GLCapabilitiesImmutable glCaps = drawable.getChosenGLCapabilities();
// Windows can set up sharing of display lists after creation time
WindowsWGLContext other = (WindowsWGLContext) GLContextShareSet.getShareContext(this);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
index 462079913..51c5875cc 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -55,7 +55,6 @@ import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.windows.WindowsGraphicsDevice;
-import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawable;
@@ -66,11 +65,11 @@ import com.jogamp.common.JogampRuntimeException;
import com.jogamp.common.util.ReflectionUtil;
import com.jogamp.nativewindow.impl.ProxySurface;
import com.jogamp.nativewindow.impl.windows.GDI;
-import com.jogamp.opengl.impl.Debug;
import com.jogamp.opengl.impl.DesktopGLDynamicLookupHelper;
import com.jogamp.opengl.impl.GLDrawableFactoryImpl;
import com.jogamp.opengl.impl.GLDrawableImpl;
import com.jogamp.opengl.impl.GLDynamicLookupHelper;
+import javax.media.opengl.GLCapabilitiesImmutable;
public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
private static final DesktopGLDynamicLookupHelper windowsWGLDynamicLookupHelper;
@@ -157,7 +156,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
addDeviceTried(connection);
NativeWindowFactory.getDefaultToolkitLock().lock(); // OK
try {
- WindowsDummyWGLDrawable sharedDrawable = new WindowsDummyWGLDrawable(this, null);
+ WindowsDummyWGLDrawable sharedDrawable = WindowsDummyWGLDrawable.create(this, null);
WindowsWGLContext ctx = (WindowsWGLContext) sharedDrawable.createContext(null);
ctx.makeCurrent();
boolean canCreateGLPbuffer = ctx.getGL().isExtensionAvailable("GL_ARB_pbuffer");
@@ -276,10 +275,10 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
return (GLDrawableImpl) returnList.get(0);
}
- protected final NativeSurface createOffscreenSurfaceImpl(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
+ protected final NativeSurface createOffscreenSurfaceImpl(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) {
AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS);
ProxySurface ns = new ProxySurface(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
- capabilities, chooser, screen) );
+ capsChosen, capsRequested, chooser, screen) );
ns.setSize(width, height);
return ns;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index 6c006577e..f714c7719 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -49,6 +49,7 @@ import javax.media.opengl.GLProfile;
import com.jogamp.nativewindow.impl.windows.GDI;
import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR;
import com.jogamp.opengl.impl.GLContextImpl;
+import javax.media.opengl.GLCapabilitiesImmutable;
public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable {
// Keep this under the same debug flag as the drawable factory for convenience
@@ -63,7 +64,8 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
private GLCapabilitiesChooser chooser;
private boolean choosenByWGLPixelFormat=false;
- public WindowsWGLGraphicsConfiguration(AbstractGraphicsScreen screen, GLCapabilities capsChosen, GLCapabilities capsRequested,
+ public WindowsWGLGraphicsConfiguration(AbstractGraphicsScreen screen,
+ GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested,
PIXELFORMATDESCRIPTOR pixelfmt, int pixelfmtID, GLCapabilitiesChooser chooser) {
super(screen, capsChosen, capsRequested);
this.chooser=chooser;
@@ -85,7 +87,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
throw new GLException("Unable to describe pixel format " + pfdID);
}
- GLCapabilities caps = PFD2GLCapabilities(glp, pfd, onscreen, usePBuffer);
+ GLCapabilitiesImmutable caps = PFD2GLCapabilities(glp, pfd, onscreen, usePBuffer);
if(null==caps) {
throw new GLException("Couldn't choose Capabilities by: HDC 0x"+Long.toHexString(hdc)+", pfdID "+pfdID);
}
@@ -108,7 +110,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
protected void updateCapabilitiesByWGL(GLContextImpl context) {
if(choosenByWGLPixelFormat) return; // already done ..
- GLCapabilities capabilities = (GLCapabilities) getRequestedCapabilities();
+ GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable) getRequestedCapabilities();
boolean onscreen = capabilities.isOnscreen();
boolean usePBuffer = capabilities.isPBuffer();
GLProfile glp = capabilities.getGLProfile();
@@ -118,13 +120,13 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
NativeSurface ns = drawable.getNativeSurface();
long hdc = ns.getSurfaceHandle();
- GLCapabilities[] caps = HDC2GLCapabilities(wglExt, hdc, getPixelFormatID(), glp, true, onscreen, usePBuffer);
+ GLCapabilitiesImmutable[] caps = HDC2GLCapabilities(wglExt, hdc, getPixelFormatID(), glp, true, onscreen, usePBuffer);
if(null!=caps && null!=caps[0]) {
setCapsPFD(caps[0], getPixelFormat(), getPixelFormatID(), true);
}
}
- protected void setCapsPFD(GLCapabilities caps, PIXELFORMATDESCRIPTOR pfd, int pfdID, boolean choosenByWGLPixelFormat) {
+ protected void setCapsPFD(GLCapabilitiesImmutable caps, PIXELFORMATDESCRIPTOR pfd, int pfdID, boolean choosenByWGLPixelFormat) {
this.pixelfmt = pfd;
this.pixelfmtID = pfdID;
setChosenCapabilities(caps);
@@ -146,8 +148,8 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
private static int haveWGLChoosePixelFormatARB = -1;
private static int haveWGLARBMultisample = -1;
- public static GLCapabilities[] HDC2GLCapabilities(WGLExt wglExt, long hdc, int pfdIDOnly,
- GLProfile glp, boolean relaxed, boolean onscreen, boolean usePBuffer) {
+ public static GLCapabilitiesImmutable[] HDC2GLCapabilities(WGLExt wglExt, long hdc, int pfdIDOnly,
+ GLProfile glp, boolean relaxed, boolean onscreen, boolean usePBuffer) {
if(haveWGLChoosePixelFormatARB<0) {
haveWGLChoosePixelFormatARB = wglExt.isExtensionAvailable("WGL_ARB_pixel_format")?1:0;
@@ -168,7 +170,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
// "HardwareAccelerated" bit, which is basically
// meaningless, and put in whether it can render to a
// window, to a pbuffer, or to a pixmap)
- GLCapabilities[] availableCaps = null;
+ GLCapabilitiesImmutable[] availableCaps = null;
int numFormats = 0;
int niattribs = 0;
int[] iattributes = new int [2*MAX_ATTRIBS];
@@ -212,14 +214,14 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
}
if(pfdIDOnly>0) {
- availableCaps = new GLCapabilities[1];
+ availableCaps = new GLCapabilitiesImmutable[1];
if (!wglExt.wglGetPixelFormatAttribivARB(hdc, pfdIDOnly, 0, niattribs, iattributes, 0, iresults, 0)) {
throw new GLException("Error getting pixel format attributes for pixel format " + pfdIDOnly + " of device context");
}
availableCaps[0] = AttribList2GLCapabilities(glp, iattributes, niattribs, iresults,
relaxed, onscreen, usePBuffer);
} else {
- availableCaps = new GLCapabilities[numFormats];
+ availableCaps = new GLCapabilitiesImmutable[numFormats];
for (int i = 0; i < numFormats; i++) {
if (!wglExt.wglGetPixelFormatAttribivARB(hdc, i+1, 0, niattribs, iattributes, 0, iresults, 0)) {
throw new GLException("Error getting pixel format attributes for pixel format " + (i + 1) + " of device context");
@@ -238,11 +240,11 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
return availableCaps;
}
- public static boolean GLCapabilities2AttribList(GLCapabilities caps,
- int[] iattributes,
- WGLExt wglExt,
- boolean pbuffer,
- int[] floatMode) throws GLException {
+ public static boolean GLCapabilities2AttribList(GLCapabilitiesImmutable caps,
+ int[] iattributes,
+ WGLExt wglExt,
+ boolean pbuffer,
+ int[] floatMode) throws GLException {
if (!wglExt.isExtensionAvailable("WGL_ARB_pixel_format")) {
return false;
}
@@ -436,7 +438,8 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
return res;
}
- public static GLCapabilities AttribList2GLCapabilities(GLProfile glp, int[] iattribs,
+ public static GLCapabilitiesImmutable AttribList2GLCapabilities(
+ GLProfile glp, int[] iattribs,
int niattribs,
int[] iresults,
boolean relaxed, boolean onscreen, boolean usePBuffer) {
@@ -552,7 +555,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
// PIXELFORMAT
- public static GLCapabilities PFD2GLCapabilities(GLProfile glp, PIXELFORMATDESCRIPTOR pfd, boolean onscreen, boolean usePBuffer) {
+ public static GLCapabilitiesImmutable PFD2GLCapabilities(GLProfile glp, PIXELFORMATDESCRIPTOR pfd, boolean onscreen, boolean usePBuffer) {
if ((pfd.getDwFlags() & GDI.PFD_SUPPORT_OPENGL) == 0) {
return null;
}
@@ -586,7 +589,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
return res;
}
- public static PIXELFORMATDESCRIPTOR GLCapabilities2PFD(GLCapabilities caps) {
+ public static PIXELFORMATDESCRIPTOR GLCapabilities2PFD(GLCapabilitiesImmutable caps) {
int colorDepth = (caps.getRedBits() +
caps.getGreenBits() +
caps.getBlueBits());
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index 1d8f14d94..46b169343 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -36,7 +36,6 @@ package com.jogamp.opengl.impl.windows.wgl;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.AbstractGraphicsScreen;
-import javax.media.nativewindow.Capabilities;
import javax.media.nativewindow.CapabilitiesChooser;
import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.GraphicsConfigurationFactory;
@@ -51,6 +50,8 @@ import javax.media.opengl.GLProfile;
import com.jogamp.nativewindow.impl.windows.GDI;
import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR;
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.opengl.GLCapabilitiesImmutable;
/** Subclass of GraphicsConfigurationFactory used when non-AWT tookits
are used on Windows platforms. Toolkits will likely need to delegate
@@ -65,36 +66,44 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
- Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
- GLCapabilities caps = (GLCapabilities)capabilities;
- return chooseGraphicsConfigurationStatic(caps, chooser, absScreen);
- }
+ CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
+
+ if (! (capsChosen instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - chosen");
+ }
- protected static WindowsWGLGraphicsConfiguration createDefaultGraphicsConfiguration(GLProfile glp, AbstractGraphicsScreen absScreen, boolean onscreen, boolean usePBuffer) {
- GLCapabilities caps = new GLCapabilities(glp);
- caps.setDoubleBuffered(onscreen); // FIXME DBLBUFOFFSCRN
- caps.setOnscreen (onscreen);
- caps.setPBuffer (usePBuffer);
+ if (! (capsRequested instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - requested");
+ }
+
+ return chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested, chooser, absScreen);
+ }
+ protected static WindowsWGLGraphicsConfiguration createDefaultGraphicsConfiguration(GLCapabilitiesImmutable caps,
+ AbstractGraphicsScreen absScreen) {
if(null==absScreen) {
absScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS);
}
return new WindowsWGLGraphicsConfiguration(absScreen, caps, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps), -1, null);
-
}
- protected static WindowsWGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilities caps,
+ protected static WindowsWGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilitiesImmutable capsChosen,
+ GLCapabilitiesImmutable capsReq,
CapabilitiesChooser chooser,
AbstractGraphicsScreen absScreen) {
if(null==absScreen) {
absScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS);
}
- GLCapabilities caps2 = (GLCapabilities) caps.clone();
- if(!caps2.isOnscreen()) {
+
+ if(!capsChosen.isOnscreen() && capsChosen.getDoubleBuffered()) {
// OFFSCREEN !DOUBLE_BUFFER // FIXME DBLBUFOFFSCRN
+ GLCapabilities caps2 = (GLCapabilities) capsChosen.cloneMutable();
caps2.setDoubleBuffered(false);
+ capsChosen = caps2;
}
- return new WindowsWGLGraphicsConfiguration(absScreen, caps2, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps2), -1,
+
+ return new WindowsWGLGraphicsConfiguration(absScreen, capsChosen, capsReq,
+ WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(capsChosen), -1,
(GLCapabilitiesChooser)chooser);
}
@@ -117,7 +126,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
throw new InternalError("SharedContext is null: "+device);
}
boolean choosenBywGLPixelFormat = false;
- GLCapabilities capabilities = (GLCapabilities) config.getRequestedCapabilities();
+ GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable) config.getChosenCapabilities();
boolean onscreen = capabilities.isOnscreen();
boolean usePBuffer = capabilities.isPBuffer();
GLProfile glProfile = capabilities.getGLProfile();
@@ -134,7 +143,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
PIXELFORMATDESCRIPTOR pfd = null;
int pixelFormat = -1; // 1-based pixel format
boolean pixelFormatSet = false;
- GLCapabilities chosenCaps = null;
+ GLCapabilitiesImmutable chosenCaps = null;
if (onscreen) {
if ((pixelFormat = GDI.GetPixelFormat(hdc)) != 0) {
@@ -149,7 +158,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
pixelFormatSet = true;
}
- GLCapabilities[] availableCaps = null;
+ GLCapabilitiesImmutable[] availableCaps = null;
int numFormats = 0;
pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor();
// Produce a recommended pixel format selection for the GLCapabilitiesChooser.
@@ -234,7 +243,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
throw new GLException("Unable to enumerate pixel formats of window " +
toHexString(hdc) + " for GLCapabilitiesChooser (LastError: "+GDI.GetLastError()+")");
}
- availableCaps = new GLCapabilities[numFormats];
+ availableCaps = new GLCapabilitiesImmutable[numFormats];
for (int i = 0; i < numFormats; i++) {
if (GDI.DescribePixelFormat(hdc, 1 + i, pfd.size(), pfd) == 0) {
throw new GLException("Error describing pixel format " + (1 + i) + " of device context");
@@ -255,7 +264,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
pixelFormat = chooser.chooseCapabilities(capabilities, availableCaps, recommendedPixelFormat) + 1;
} catch (NativeWindowException e) {
if(DEBUG) {
- e.printStackTrace();
+ e.printStackTrace();
}
pixelFormat = -1;
}
@@ -315,11 +324,12 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
config.setCapsPFD(capabilities, pfd, pixelFormat, choosenBywGLPixelFormat);
}
- protected static String getThreadName() {
- return Thread.currentThread().getName();
- }
- public static String toHexString(long hex) {
- return "0x" + Long.toHexString(hex);
- }
+ protected static String getThreadName() {
+ return Thread.currentThread().getName();
+ }
+
+ public static String toHexString(long hex) {
+ return "0x" + Long.toHexString(hex);
+ }
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
index 48850440d..363881ef0 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
@@ -32,19 +32,27 @@
package com.jogamp.opengl.impl.windows.wgl.awt;
+
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.windows.*;
-import javax.media.nativewindow.awt.*;
-import javax.media.opengl.*;
-import javax.media.opengl.awt.*;
-
-import com.jogamp.opengl.impl.*;
-import com.jogamp.opengl.impl.windows.wgl.*;
-import com.jogamp.nativewindow.impl.jawt.*;
-import com.jogamp.nativewindow.impl.jawt.windows.*;
+
+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.windows.WindowsGraphicsDevice;
+
+import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLException;
+
+import com.jogamp.opengl.impl.windows.wgl.WindowsWGLGraphicsConfiguration;
public class WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigurationFactory {
protected static final boolean DEBUG = com.jogamp.opengl.impl.Debug.debug("GraphicsConfiguration");
@@ -54,7 +62,8 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigura
}
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 WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigura
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,13 +93,11 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigura
System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: got "+absScreen);
}
GraphicsConfiguration gc = device.getDefaultConfiguration();
- AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capabilities, gc);
+ capsChosen = AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capsChosen, gc);
if(DEBUG) {
- System.err.println("AWT Colormodel compatible: "+capabilities);
+ System.err.println("AWT Colormodel compatible: "+capsChosen);
}
- long displayHandle = 0;
-
WindowsGraphicsDevice winDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
DefaultGraphicsScreen winScreen = new DefaultGraphicsScreen(winDevice, awtScreen.getIndex());
if(DEBUG) {
@@ -95,12 +105,12 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigura
}
WindowsWGLGraphicsConfiguration winConfig = (WindowsWGLGraphicsConfiguration)
- GraphicsConfigurationFactory.getFactory(winDevice).chooseGraphicsConfiguration(capabilities,
- chooser,
- winScreen);
+ GraphicsConfigurationFactory.getFactory(winDevice).chooseGraphicsConfiguration(capsChosen,
+ capsRequested,
+ chooser, winScreen);
if (winConfig == null) {
- throw new GLException("Unable to choose a GraphicsConfiguration: "+capabilities+",\n\t"+chooser+"\n\t"+winScreen);
+ throw new GLException("Unable to choose a GraphicsConfiguration: "+capsChosen+",\n\t"+chooser+"\n\t"+winScreen);
}
if(DEBUG) {