summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/windows/wgl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-02-11 17:28:06 +0100
committerSven Gothel <[email protected]>2011-02-11 17:28:06 +0100
commitbff7e97c2f22673bb0457765696fb867d3e4f69d (patch)
tree2945281555067ee8ff0a76bed413548bac784905 /src/jogl/classes/jogamp/opengl/windows/wgl
parentbf75331124d6d0c53b74d5235ec03f5fcbc55cba (diff)
Win,ARB,GL-2.x: Fix pfd to caps conversion: !pbuffer / Cleanup
This fix enables the configuration win7 64bit chromium2.1 (virtual box 4.0.2 linux host) Querying unsupported pixel format attributes, ie pbuffer, will fail the ARB attribute query functions. Cleanup of SharedResource's, hold all reused flags in win32 impl, ie pbuffer, arb pixelformat, ..
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/windows/wgl')
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java19
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java56
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java89
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java38
5 files changed, 107 insertions, 99 deletions
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java
index 48838de53..97c63ea52 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2003 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
@@ -40,7 +41,6 @@
package jogamp.opengl.windows.wgl;
import javax.media.opengl.*;
-import jogamp.opengl.*;
public class WindowsPbufferWGLContext extends WindowsWGLContext {
// State for render-to-texture and render-to-texture-rectangle support
@@ -50,7 +50,7 @@ public class WindowsPbufferWGLContext extends WindowsWGLContext {
private int textureTarget; // e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_NV
private int texture; // actual texture object
- public WindowsPbufferWGLContext(WindowsPbufferWGLDrawable drawable,
+ protected WindowsPbufferWGLContext(WindowsPbufferWGLDrawable drawable,
GLContext shareWith) {
super(drawable, shareWith);
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
index 7be630187..83354a7fb 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -59,16 +59,15 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
private int floatMode;
- public WindowsPbufferWGLDrawable(GLDrawableFactory factory, NativeSurface target,
- WindowsWGLDrawable dummyDrawable,
- WindowsWGLContext sharedCtx) {
+ protected WindowsPbufferWGLDrawable(GLDrawableFactory factory, NativeSurface target,
+ WindowsWGLDrawableFactory.SharedResource sharedResource) {
super(factory, target, true);
if (DEBUG) {
System.out.println("Pbuffer config: " + getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration());
}
- createPbuffer(dummyDrawable.getNativeSurface().getSurfaceHandle(), sharedCtx);
+ createPbuffer(sharedResource);
if (DEBUG) {
System.err.println("Created pbuffer " + this);
@@ -125,13 +124,15 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
}
}
- private void createPbuffer(long parentHdc, WindowsWGLContext sharedCtx) {
+ private void createPbuffer(WindowsWGLDrawableFactory.SharedResource sharedResource) {
+ long parentHdc = sharedResource.getDrawable().getNativeSurface().getSurfaceHandle();
+ WGLExt wglExt = sharedResource.getContext().getWGLExt();
+
int[] iattributes = new int [2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS];
float[] fattributes = new float[1];
int[] floatModeTmp = new int[1];
int niattribs = 0;
int width, height;
- WGLExt wglExt = sharedCtx.getWGLExt();
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities();
@@ -143,7 +144,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
}
if(!WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList(chosenCaps,
- iattributes, sharedCtx, -1, floatModeTmp)){
+ iattributes, sharedResource, -1, floatModeTmp)){
throw new GLException("Pbuffer-related extensions not supported");
}
@@ -176,7 +177,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
if (DEBUG) {
System.err.println("" + nformats + " suitable pixel formats found");
for (int i = 0; i < nformats; i++) {
- WGLGLCapabilities dbgCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedCtx, parentHdc, pformats[i], glProfile, false, true);
+ WGLGLCapabilities dbgCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, parentHdc, pformats[i], glProfile, false, true);
System.err.println("pixel format " + pformats[i] + " (index " + i + "): " + dbgCaps);
}
}
@@ -240,7 +241,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
// Re-query chosen pixel format
{
- WGLGLCapabilities newCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedCtx, parentHdc, pfdid, glProfile, false, true);
+ WGLGLCapabilities newCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, parentHdc, pfdid, glProfile, false, true);
if(null == newCaps) {
throw new GLException("pbuffer creation error: unable to re-query chosen PFD ID: " + pfdid + ", hdc " + this.toHexString(tmpHdc));
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
index ba3044505..2c078dd98 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -167,25 +167,31 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
private AbstractGraphicsScreen screen;
private WindowsDummyWGLDrawable drawable;
private WindowsWGLContext context;
- private boolean canCreateGLPbuffer;
- private boolean readDrawableAvailable;
+ private boolean hasARBPixelFormat;
+ private boolean hasARBMultisample;
+ private boolean hasARBPBuffer;
+ private boolean hasARBReadDrawable;
SharedResource(WindowsGraphicsDevice dev, AbstractGraphicsScreen scrn, WindowsDummyWGLDrawable draw, WindowsWGLContext ctx,
- boolean readBufferAvail, boolean canPbuffer) {
+ boolean arbPixelFormat, boolean arbMultisample, boolean arbPBuffer, boolean arbReadDrawable) {
device = dev;
screen = scrn;
drawable = draw;
context = ctx;
- canCreateGLPbuffer = canPbuffer;
- readDrawableAvailable = readBufferAvail;
+ hasARBPixelFormat = arbPixelFormat;
+ hasARBMultisample = arbMultisample;
+ hasARBPBuffer = arbPBuffer;
+ hasARBReadDrawable = arbReadDrawable;
}
final public AbstractGraphicsDevice getDevice() { return device; }
final public AbstractGraphicsScreen getScreen() { return screen; }
- final public GLDrawableImpl getDrawable() { return drawable; }
- final public GLContextImpl getContext() { return context; }
+ final public WindowsWGLDrawable getDrawable() { return drawable; }
+ final public WindowsWGLContext getContext() { return context; }
- final boolean canCreateGLPbuffer() { return canCreateGLPbuffer; }
- final boolean isReadDrawableAvailable() { return readDrawableAvailable; }
+ final boolean hasARBPixelFormat() { return hasARBPixelFormat; }
+ final boolean hasARBMultisample() { return hasARBMultisample; }
+ final boolean hasARBPBuffer() { return hasARBPBuffer; }
+ final boolean hasReadDrawable() { return hasARBReadDrawable; }
}
class SharedResourceImplementation implements SharedResourceRunner.Implementation {
@@ -231,12 +237,16 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable);
}
sharedContext.setSynchronized(true);
- boolean canCreateGLPbuffer;
- boolean readDrawableAvailable;
+ boolean hasARBPixelFormat;
+ boolean hasARBMultisample;
+ boolean hasARBPBuffer;
+ boolean hasARBReadDrawableAvailable;
sharedContext.makeCurrent();
try {
- canCreateGLPbuffer = sharedContext.getGL().isExtensionAvailable(GL_ARB_pbuffer);
- readDrawableAvailable = sharedContext.isExtensionAvailable(WGL_ARB_make_current_read) &&
+ hasARBPixelFormat = sharedContext.isExtensionAvailable(WGL_ARB_pixel_format);
+ hasARBMultisample = sharedContext.isExtensionAvailable(WGL_ARB_multisample);
+ hasARBPBuffer = sharedContext.isExtensionAvailable(GL_ARB_pbuffer);
+ hasARBReadDrawableAvailable = sharedContext.isExtensionAvailable(WGL_ARB_make_current_read) &&
sharedContext.isFunctionAvailable(wglMakeContextCurrent);
} finally {
sharedContext.release();
@@ -245,10 +255,14 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
System.err.println("!!! SharedDevice: " + sharedDevice);
System.err.println("!!! SharedScreen: " + absScreen);
System.err.println("!!! SharedContext: " + sharedContext);
- System.err.println("!!! pbuffer avail: " + canCreateGLPbuffer);
- System.err.println("!!! readDrawable: " + readDrawableAvailable);
+ System.err.println("!!! pixelformat: " + hasARBPixelFormat);
+ System.err.println("!!! multisample: " + hasARBMultisample);
+ System.err.println("!!! pbuffer: " + hasARBPBuffer);
+ System.err.println("!!! readDrawable: " + hasARBReadDrawableAvailable);
}
- return new SharedResource(sharedDevice, absScreen, sharedDrawable, sharedContext, readDrawableAvailable, canCreateGLPbuffer);
+ return new SharedResource(sharedDevice, absScreen, sharedDrawable, sharedContext,
+ hasARBPixelFormat, hasARBMultisample,
+ hasARBPBuffer, hasARBReadDrawableAvailable);
} catch (Throwable t) {
throw new GLException("WindowsWGLDrawableFactory - Could not initialize shared resources for "+connection, t);
} finally {
@@ -299,6 +313,8 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
}
final static String GL_ARB_pbuffer = "GL_ARB_pbuffer";
+ final static String WGL_ARB_pixel_format = "WGL_ARB_pixel_format";
+ final static String WGL_ARB_multisample = "WGL_ARB_multisample";
final static String WGL_ARB_make_current_read = "WGL_ARB_make_current_read";
final static String wglMakeContextCurrent = "wglMakeContextCurrent";
@@ -384,9 +400,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
}
sr.context.makeCurrent();
try {
- GLDrawableImpl pbufferDrawable = new WindowsPbufferWGLDrawable(WindowsWGLDrawableFactory.this, target,
- sr.drawable,
- sr.context);
+ GLDrawableImpl pbufferDrawable = new WindowsPbufferWGLDrawable(WindowsWGLDrawableFactory.this, target, sr);
returnList.add(pbufferDrawable);
} finally {
sr.context.release();
@@ -407,7 +421,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
public final int isReadDrawableAvailable(AbstractGraphicsDevice device) {
SharedResource sr = (SharedResource) sharedResourceRunner.getOrCreateShared((null!=device)?device:defaultDevice);
if(null!=sr) {
- return sr.isReadDrawableAvailable() ? 1 : 0 ;
+ return sr.hasReadDrawable() ? 1 : 0 ;
}
return -1; // undefined
}
@@ -415,7 +429,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
public final boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
SharedResource sr = (SharedResource) sharedResourceRunner.getOrCreateShared((null!=device)?device:defaultDevice);
if(null!=sr) {
- return sr.canCreateGLPbuffer();
+ return sr.hasARBPBuffer();
}
return false;
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index a80f68377..ae07646b3 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -57,9 +57,6 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
// Keep this under the same debug flag as the drawable factory for convenience
protected static final boolean DEBUG = jogamp.opengl.Debug.debug("GraphicsConfiguration");
- final static String WGL_ARB_pixel_format = "WGL_ARB_pixel_format";
- final static String WGL_ARB_multisample = "WGL_ARB_multisample";
-
protected static final int MAX_PFORMATS = 256;
protected static final int MAX_ATTRIBS = 256;
@@ -99,13 +96,13 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
}
WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory) _factory;
AbstractGraphicsDevice device = screen.getDevice();
- WindowsWGLContext sharedContext = (WindowsWGLContext) factory.getOrCreateSharedContextImpl(device);
- boolean hasARB = null != sharedContext && sharedContext.isExtensionAvailable(WGL_ARB_pixel_format) ;
+ WindowsWGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResource(device);
+ boolean hasARB = null != sharedResource && sharedResource.hasARBPixelFormat();
WGLGLCapabilities caps = null;
if(hasARB) {
- caps = wglARBPFID2GLCapabilities(sharedContext, hdc, pfdID, glp, onscreen, true /* pbuffer */);
+ caps = wglARBPFID2GLCapabilities(sharedResource, hdc, pfdID, glp, onscreen, true /* pbuffer */);
} else {
caps = PFD2GLCapabilities(glp, hdc, pfdID, onscreen);
}
@@ -164,10 +161,12 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
public final int getPixelFormatID() { return isChosen ? ((WGLGLCapabilities)capabilitiesChosen).getPFDID() : 0; }
public final boolean isChoosenByARB() { return isChosen ? ((WGLGLCapabilities)capabilitiesChosen).isSetByARB() : false; }
- static int fillAttribsForGeneralWGLARBQuery(boolean haveWGLARBMultisample, int[] iattributes) {
+ static int fillAttribsForGeneralWGLARBQuery(WindowsWGLDrawableFactory.SharedResource sharedResource, int[] iattributes) {
int niattribs = 0;
iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_WINDOW_ARB;
- iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_PBUFFER_ARB;
+ if(sharedResource.hasARBPBuffer()) {
+ iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_PBUFFER_ARB;
+ }
iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_BITMAP_ARB;
iattributes[niattribs++] = WGLExt.WGL_ACCELERATION_ARB;
iattributes[niattribs++] = WGLExt.WGL_SUPPORT_OPENGL_ARB;
@@ -184,13 +183,15 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
iattributes[niattribs++] = WGLExt.WGL_ACCUM_GREEN_BITS_ARB;
iattributes[niattribs++] = WGLExt.WGL_ACCUM_BLUE_BITS_ARB;
iattributes[niattribs++] = WGLExt.WGL_ACCUM_ALPHA_BITS_ARB;
- if (haveWGLARBMultisample) {
+ if(sharedResource.hasARBMultisample()) {
iattributes[niattribs++] = WGLExt.WGL_SAMPLE_BUFFERS_ARB;
iattributes[niattribs++] = WGLExt.WGL_SAMPLES_ARB;
}
- // pbo float buffer
- iattributes[niattribs++] = WGLExt.WGL_PIXEL_TYPE_ARB; // ati
- iattributes[niattribs++] = WGLExt.WGL_FLOAT_COMPONENTS_NV; // nvidia
+ if(sharedResource.hasARBPBuffer()) {
+ // pbo float buffer
+ iattributes[niattribs++] = WGLExt.WGL_PIXEL_TYPE_ARB; // ati
+ iattributes[niattribs++] = WGLExt.WGL_FLOAT_COMPONENTS_NV; // nvidia
+ }
return niattribs;
}
@@ -236,21 +237,21 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
return pfdIDs;
}
- static WGLGLCapabilities wglARBPFID2GLCapabilities(WindowsWGLContext sharedCtx, long hdc, int pfdID,
+ static WGLGLCapabilities wglARBPFID2GLCapabilities(WindowsWGLDrawableFactory.SharedResource sharedResource,
+ long hdc, int pfdID,
GLProfile glp, boolean onscreen, boolean usePBuffer) {
- boolean haveWGLChoosePixelFormatARB = sharedCtx.isExtensionAvailable(WGL_ARB_pixel_format);
- if (!haveWGLChoosePixelFormatARB) {
+ if (!sharedResource.hasARBPixelFormat()) {
return null;
}
- boolean haveWGLARBMultisample = sharedCtx.isExtensionAvailable(WGL_ARB_multisample);
int[] iattributes = new int [2*MAX_ATTRIBS];
int[] iresults = new int [2*MAX_ATTRIBS];
- int niattribs = fillAttribsForGeneralWGLARBQuery(haveWGLARBMultisample, iattributes);
+ int niattribs = fillAttribsForGeneralWGLARBQuery(sharedResource, iattributes);
- if (!sharedCtx.getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdID, 0, niattribs, iattributes, 0, iresults, 0)) {
- throw new GLException("wglARBPFID2GLCapabilities: Error getting pixel format attributes for pixel format " + pfdID + " of device context");
+ if (!sharedResource.getContext().getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdID, 0, niattribs, iattributes, 0, iresults, 0)) {
+ throw new GLException("wglARBPFID2GLCapabilities: Error getting pixel format attributes for pixel format " + pfdID +
+ " of device context " + toHexString(hdc) + ", werr " + GDI.GetLastError());
}
ArrayList bucket = new ArrayList(1);
final int winattrbits = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer);
@@ -260,13 +261,13 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
return null;
}
- static int[] wglChoosePixelFormatARB(long hdc, WindowsWGLContext sharedContext,
+ static int[] wglChoosePixelFormatARB(long hdc, WindowsWGLDrawableFactory.SharedResource sharedResource,
GLCapabilitiesImmutable capabilities,
int[] iattributes, int accelerationMode, float[] fattributes)
{
if ( !WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList(capabilities,
- iattributes, sharedContext, accelerationMode, null))
+ iattributes, sharedResource, accelerationMode, null))
{
if (DEBUG) {
System.err.println("wglChoosePixelFormatARB: GLCapabilities2AttribList failed: " + GDI.GetLastError());
@@ -277,7 +278,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
int[] pformatsTmp = new int[WindowsWGLGraphicsConfiguration.MAX_PFORMATS];
int[] numFormatsTmp = new int[1];
- if ( !sharedContext.getWGLExt().wglChoosePixelFormatARB(hdc, iattributes, 0,
+ if ( !sharedResource.getContext().getWGLExt().wglChoosePixelFormatARB(hdc, iattributes, 0,
fattributes, 0,
WindowsWGLGraphicsConfiguration.MAX_PFORMATS,
pformatsTmp, 0, numFormatsTmp, 0))
@@ -299,7 +300,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
+ Integer.toHexString(accelerationMode) + ": " + numFormats);
for (int i = 0; i < numFormats; i++) {
WGLGLCapabilities dbgCaps0 = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(
- sharedContext, hdc, pformats[i],
+ sharedResource, hdc, pformats[i],
capabilities.getGLProfile(), capabilities.isOnscreen(), capabilities.isPBuffer());
System.err.println("pixel format " + pformats[i] + " (index " + i + "): " + dbgCaps0);
}
@@ -307,35 +308,33 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
return pformats;
}
- static List /*<GLCapabilitiesImmutable>*/ wglARBPFIDs2GLCapabilities(WindowsWGLContext sharedCtx, long hdc, int[] pfdIDs,
- GLProfile glp, boolean onscreen, boolean usePBuffer) {
+ static List /*<GLCapabilitiesImmutable>*/ wglARBPFIDs2GLCapabilities(WindowsWGLDrawableFactory.SharedResource sharedResource,
+ long hdc, int[] pfdIDs, GLProfile glp, boolean onscreen, boolean usePBuffer) {
final int winattrbits = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer);
- return wglARBPFIDs2GLCapabilitiesImpl(sharedCtx, hdc, pfdIDs, glp, winattrbits);
+ return wglARBPFIDs2GLCapabilitiesImpl(sharedResource, hdc, pfdIDs, glp, winattrbits);
}
- static List /*<GLCapabilitiesImmutable>*/ wglARBPFIDs2AllGLCapabilities(WindowsWGLContext sharedCtx, long hdc, int[] pfdIDs,
- GLProfile glp) {
- return wglARBPFIDs2GLCapabilitiesImpl(sharedCtx, hdc, pfdIDs, glp, GLGraphicsConfigurationUtil.ALL_BITS);
+ static List /*<GLCapabilitiesImmutable>*/ wglARBPFIDs2AllGLCapabilities(WindowsWGLDrawableFactory.SharedResource sharedResource,
+ long hdc, int[] pfdIDs, GLProfile glp) {
+ return wglARBPFIDs2GLCapabilitiesImpl(sharedResource, hdc, pfdIDs, glp, GLGraphicsConfigurationUtil.ALL_BITS);
}
- private static List /*<GLCapabilitiesImmutable>*/ wglARBPFIDs2GLCapabilitiesImpl(WindowsWGLContext sharedCtx, long hdc, int[] pfdIDs,
- GLProfile glp, int winattrbits) {
- boolean haveWGLChoosePixelFormatARB = sharedCtx.isExtensionAvailable(WGL_ARB_pixel_format);
- if (!haveWGLChoosePixelFormatARB) {
+ private static List /*<GLCapabilitiesImmutable>*/ wglARBPFIDs2GLCapabilitiesImpl(WindowsWGLDrawableFactory.SharedResource sharedResource,
+ long hdc, int[] pfdIDs, GLProfile glp, int winattrbits) {
+ if (!sharedResource.hasARBPixelFormat()) {
return null;
}
- boolean haveWGLARBMultisample = sharedCtx.isExtensionAvailable(WGL_ARB_multisample);
final int numFormats = pfdIDs.length;
int[] iattributes = new int [2*MAX_ATTRIBS];
int[] iresults = new int [2*MAX_ATTRIBS];
- int niattribs = fillAttribsForGeneralWGLARBQuery(haveWGLARBMultisample, iattributes);
+ int niattribs = fillAttribsForGeneralWGLARBQuery(sharedResource, iattributes);
ArrayList bucket = new ArrayList();
for(int i = 0; i<numFormats; i++) {
if ( pfdIDs[i] >= 1 &&
- sharedCtx.getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdIDs[i], 0, niattribs, iattributes, 0, iresults, 0) ) {
+ sharedResource.getContext().getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdIDs[i], 0, niattribs, iattributes, 0, iresults, 0) ) {
AttribList2GLCapabilities(bucket, glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, winattrbits);
} else if (DEBUG) {
System.err.println("wglARBPFIDs2GLCapabilities: Cannot get pixel format attributes for pixel format " +
@@ -348,17 +347,10 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
static boolean GLCapabilities2AttribList(GLCapabilitiesImmutable caps,
int[] iattributes,
- GLContextImpl sharedCtx,
+ WindowsWGLDrawableFactory.SharedResource sharedResource,
int accelerationValue,
int[] floatMode) throws GLException {
- boolean haveWGLChoosePixelFormatARB = sharedCtx.isExtensionAvailable(WGL_ARB_pixel_format);
- boolean haveWGLARBMultisample = sharedCtx.isExtensionAvailable(WGL_ARB_multisample);
- if(DEBUG) {
- System.err.println("HDC2GLCapabilities: ARB_pixel_format: "+haveWGLChoosePixelFormatARB);
- System.err.println("HDC2GLCapabilities: ARB_multisample : "+haveWGLARBMultisample);
- }
-
- if (!haveWGLChoosePixelFormatARB) {
+ if (!sharedResource.hasARBPixelFormat()) {
return false;
}
@@ -376,7 +368,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
if (onscreen) {
iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_WINDOW_ARB;
iattributes[niattribs++] = GL.GL_TRUE;
- } else if (pbuffer) {
+ } else if (pbuffer && sharedResource.hasARBPBuffer()) {
iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_PBUFFER_ARB;
iattributes[niattribs++] = GL.GL_TRUE;
} else {
@@ -429,7 +421,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
iattributes[niattribs++] = caps.getAccumAlphaBits();
}
- if (caps.getSampleBuffers() && haveWGLARBMultisample) {
+ if (caps.getSampleBuffers() && sharedResource.hasARBMultisample()) {
iattributes[niattribs++] = WGLExt.WGL_SAMPLE_BUFFERS_ARB;
iattributes[niattribs++] = GL.GL_TRUE;
iattributes[niattribs++] = WGLExt.WGL_SAMPLES_ARB;
@@ -440,12 +432,13 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
boolean rect = caps.getPbufferRenderToTextureRectangle();
boolean useFloat = caps.getPbufferFloatingPointBuffers();
boolean ati = false;
- if (pbuffer) {
+ if (pbuffer && sharedResource.hasARBPBuffer()) {
// Check some invariants and set up some state
if (rect && !rtt) {
throw new GLException("Render-to-texture-rectangle requires render-to-texture to be specified");
}
+ WindowsWGLContext sharedCtx = sharedResource.getContext();
if (rect) {
if (!sharedCtx.isExtensionAvailable("GL_NV_texture_rectangle")) {
throw new GLException("Render-to-texture-rectangle requires GL_NV_texture_rectangle extension");
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index d8b84d1cb..fdf10a5ef 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -106,13 +106,12 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
protected static List/*<WGLGLCapabilities>*/ getAvailableCapabilities(WindowsWGLDrawableFactory factory, AbstractGraphicsDevice device) {
- SharedResourceRunner.Resource sharedResource = factory.getOrCreateSharedResource(device);
+ WindowsWGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResource(device);
if(null == sharedResource) {
throw new GLException("Shared resource for device n/a: "+device);
}
- WindowsWGLDrawable sharedDrawable = (WindowsWGLDrawable) sharedResource.getDrawable();
+ WindowsWGLDrawable sharedDrawable = sharedResource.getDrawable();
GLCapabilitiesImmutable capsChosen = sharedDrawable.getChosenGLCapabilities();
- WindowsWGLContext sharedContext = (WindowsWGLContext) sharedResource.getContext();
List availableCaps = null;
sharedDrawable.lockSurface();
@@ -121,8 +120,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
if (0 == hdc) {
throw new GLException("Error: HDC is null");
}
- if (sharedContext.isExtensionAvailable(WindowsWGLGraphicsConfiguration.WGL_ARB_pixel_format)) {
- availableCaps = getAvailableGLCapabilitiesARB(hdc, sharedContext, capsChosen.getGLProfile());
+ if (sharedResource.hasARBPixelFormat()) {
+ availableCaps = getAvailableGLCapabilitiesARB(hdc, sharedResource, capsChosen.getGLProfile());
}
if( null == availableCaps || 0 == availableCaps.size() ) {
availableCaps = getAvailableGLCapabilitiesGDI(hdc, capsChosen.getGLProfile());
@@ -137,9 +136,9 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
return availableCaps;
}
- static List/*<WGLGLCapabilities>*/ getAvailableGLCapabilitiesARB(long hdc, WindowsWGLContext sharedContext, GLProfile glProfile) {
- int[] pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFIDs(sharedContext, hdc);
- return WindowsWGLGraphicsConfiguration.wglARBPFIDs2AllGLCapabilities(sharedContext, hdc, pformats, glProfile);
+ static List/*<WGLGLCapabilities>*/ getAvailableGLCapabilitiesARB(long hdc, WindowsWGLDrawableFactory.SharedResource sharedResource, GLProfile glProfile) {
+ int[] pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFIDs(sharedResource.getContext(), hdc);
+ return WindowsWGLGraphicsConfiguration.wglARBPFIDs2AllGLCapabilities(sharedResource, hdc, pformats, glProfile);
}
static List/*<WGLGLCapabilities>*/ getAvailableGLCapabilitiesGDI(long hdc, GLProfile glProfile) {
@@ -256,16 +255,17 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
private static boolean updateGraphicsConfigurationARB(long hdc, boolean extHDC, WindowsWGLGraphicsConfiguration config,
CapabilitiesChooser chooser, WindowsWGLDrawableFactory factory, int[] pformats) {
AbstractGraphicsDevice device = config.getScreen().getDevice();
- WindowsWGLContext sharedContext = (WindowsWGLContext) factory.getOrCreateSharedContextImpl(device);
- if (null == sharedContext) {
+ WindowsWGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResource(device);
+
+ if (null == sharedResource) {
if (DEBUG) {
- System.err.println("updateGraphicsConfigurationARB: SharedContext is null: "+device);
+ System.err.println("updateGraphicsConfigurationARB: SharedResource is null: "+device);
}
return false;
}
- if (!sharedContext.isExtensionAvailable(WindowsWGLGraphicsConfiguration.WGL_ARB_pixel_format)) {
+ if (!sharedResource.hasARBPixelFormat()) {
if (DEBUG) {
- System.err.println("updateGraphicsConfigurationARB: "+WindowsWGLGraphicsConfiguration.WGL_ARB_pixel_format+" not available");
+ System.err.println("updateGraphicsConfigurationARB: "+WindowsWGLDrawableFactory.WGL_ARB_pixel_format+" not available");
}
return false;
}
@@ -288,7 +288,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
+ ", pixelformat " + presetPFDID);
}
pixelFormatSet = true;
- pixelFormatCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedContext, hdc, presetPFDID, glProfile, onscreen, usePBuffer);
+ pixelFormatCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, hdc, presetPFDID, glProfile, onscreen, usePBuffer);
} else {
int recommendedIndex = -1; // recommended index
@@ -299,16 +299,16 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
int[] iattributes = new int[2 * WindowsWGLGraphicsConfiguration.MAX_ATTRIBS];
float[] fattributes = new float[1];
int accelerationMode = WGLExt.WGL_FULL_ACCELERATION_ARB;
- pformats = WindowsWGLGraphicsConfiguration.wglChoosePixelFormatARB(hdc, sharedContext, capsChosen,
+ pformats = WindowsWGLGraphicsConfiguration.wglChoosePixelFormatARB(hdc, sharedResource, capsChosen,
iattributes, accelerationMode, fattributes);
if (null == pformats) {
accelerationMode = WGLExt.WGL_GENERIC_ACCELERATION_ARB;
- pformats = WindowsWGLGraphicsConfiguration.wglChoosePixelFormatARB(hdc, sharedContext, capsChosen,
+ pformats = WindowsWGLGraphicsConfiguration.wglChoosePixelFormatARB(hdc, sharedResource, capsChosen,
iattributes, accelerationMode, fattributes);
}
if (null == pformats) {
accelerationMode = -1; // use what we are offered ..
- pformats = WindowsWGLGraphicsConfiguration.wglChoosePixelFormatARB(hdc, sharedContext, capsChosen,
+ pformats = WindowsWGLGraphicsConfiguration.wglChoosePixelFormatARB(hdc, sharedResource, capsChosen,
iattributes, accelerationMode, fattributes);
}
if (null != pformats) {
@@ -318,7 +318,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
System.err.println("updateGraphicsConfigurationARB: wglChoosePixelFormatARB failed with: "+capsChosen);
}
// 2nd choice: get all GLCapabilities available, no preferred recommendedIndex available
- pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFIDs(sharedContext, hdc);
+ pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFIDs(sharedResource.getContext(), hdc);
if (DEBUG) {
final int len = ( null != pformats ) ? pformats.length : 0;
System.err.println("updateGraphicsConfigurationARB: NumFormats (wglAllARBPFIDs) " + len);
@@ -333,7 +333,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
List /*<WGLGLCapabilities>*/ availableCaps =
- WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedContext, hdc, pformats,
+ WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedResource, hdc, pformats,
glProfile, onscreen, usePBuffer);
if( null == availableCaps || 0 == availableCaps.size() ) {
if (DEBUG) {