aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java3
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java5
-rw-r--r--src/jogl/classes/jogamp/opengl/GLStateTracker.java42
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java57
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java98
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java109
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java4
12 files changed, 236 insertions, 103 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java
index 7224d65a8..a89aec080 100644
--- a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java
+++ b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java
@@ -139,9 +139,12 @@ public interface GLCapabilitiesImmutable extends WriteCloneable, CapabilitiesImm
Object cloneMutable();
+ @Override
boolean equals(Object obj);
+ @Override
int hashCode();
+ @Override
String toString();
}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 086a17362..4e6c29e01 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -745,12 +745,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
@Override
public String toString() {
+ final int dw = (null!=drawable) ? drawable.getWidth() : -1;
+ final int dh = (null!=drawable) ? drawable.getHeight() : -1;
+
return "AWT-GLCanvas[Realized "+isRealized()+
",\n\t"+((null!=drawable)?drawable.getClass().getName():"null-drawable")+
",\n\tRealized "+isRealized()+
",\n\tFactory "+getFactory()+
",\n\thandle 0x"+Long.toHexString(getHandle())+
- ",\n\tDrawable size "+drawable.getWidth()+"x"+drawable.getHeight()+
+ ",\n\tDrawable size "+dw+"x"+dh+
",\n\tAWT pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
",\n\tvisible "+isVisible()+
",\n\t"+awtConfig+"]";
diff --git a/src/jogl/classes/jogamp/opengl/GLStateTracker.java b/src/jogl/classes/jogamp/opengl/GLStateTracker.java
index 35abc6faa..3bf06ac7a 100644
--- a/src/jogl/classes/jogamp/opengl/GLStateTracker.java
+++ b/src/jogl/classes/jogamp/opengl/GLStateTracker.java
@@ -42,7 +42,7 @@ package jogamp.opengl;
import javax.media.opengl.*;
import com.jogamp.common.util.IntIntHashMap;
import java.nio.IntBuffer;
-import java.util.LinkedList;
+import java.util.ArrayList;
/**
* Tracks as closely as possible OpenGL states.
@@ -52,13 +52,19 @@ import java.util.LinkedList;
*/
public class GLStateTracker {
-// private static final boolean DEBUG = Debug.debug("GLStateTracker");
-
+ /** Minimum value of MAX_CLIENT_ATTRIB_STACK_DEPTH */
+ public static final int MIN_CLIENT_ATTRIB_STACK_DEPTH = 16;
+
+ /** static size of pixel state map */
+ static final int PIXEL_STATE_MAP_SIZE = 16;
+ /** avoid rehash of static size pixel state map */
+ static final int PIXEL_STATE_MAP_CAPACITY = 32;
+
private volatile boolean enabled = true;
private IntIntHashMap pixelStateMap;
- private final LinkedList<SavedState> stack; // would be used as Deque interface in jdk6
-
+ private final ArrayList<SavedState> stack;
+
private static class SavedState {
/**
@@ -67,30 +73,26 @@ public class GLStateTracker {
private IntIntHashMap pixelStateMap;
/**
- * set (client) pixel-store state
+ * set (client) pixel-store state, deep copy
*/
- private void putPixelStateMap(IntIntHashMap pixelStateMap) {
- //TODO add copy constructor to primitive hashmaps
- this.pixelStateMap = new IntIntHashMap(Math.max(16, pixelStateMap.size()));
- this.pixelStateMap.setKeyNotFoundValue(-1);
- this.pixelStateMap.putAll(pixelStateMap);
+ private void setPixelStateMap(IntIntHashMap pixelStateMap) {
+ this.pixelStateMap = (IntIntHashMap) pixelStateMap.clone();
}
/**
- * get (client) pixel-store state
+ * get (client) pixel-store state, return reference
*/
private IntIntHashMap getPixelStateMap() { return pixelStateMap; }
}
- public GLStateTracker() {
-
- pixelStateMap = new IntIntHashMap(32);
+ public GLStateTracker() {
+ pixelStateMap = new IntIntHashMap(PIXEL_STATE_MAP_CAPACITY, 0.75f);
pixelStateMap.setKeyNotFoundValue(-1);
resetStates();
- stack = new LinkedList<SavedState>();
+ stack = new ArrayList<SavedState>(MIN_CLIENT_ATTRIB_STACK_DEPTH);
}
public void clearStates(boolean enable) {
@@ -143,9 +145,9 @@ public class GLStateTracker {
SavedState state = new SavedState(); // empty-slot
if( 0 != (flags&GL2.GL_CLIENT_PIXEL_STORE_BIT) ) {
// save client pixel-store state
- state.putPixelStateMap(pixelStateMap);
+ state.setPixelStateMap(pixelStateMap);
}
- stack.addFirst(state); // push
+ stack.add(stack.size(), state); // push
}
}
@@ -154,7 +156,8 @@ public class GLStateTracker {
if(stack.isEmpty()) {
throw new GLException("stack contains no elements");
}
- SavedState state = stack.pollFirst(); // pop
+ SavedState state = stack.remove(stack.size()-1); // pop
+
if(null==state) {
throw new GLException("null stack element (remaining stack size "+stack.size()+")");
}
@@ -169,6 +172,7 @@ public class GLStateTracker {
private void resetStates() {
pixelStateMap.clear();
+ // 16 values -> PIXEL_STATE_MAP_SIZE
pixelStateMap.put(GL.GL_PACK_ALIGNMENT, 4);
pixelStateMap.put(GL2GL3.GL_PACK_SWAP_BYTES, GL.GL_FALSE);
pixelStateMap.put(GL2GL3.GL_PACK_LSB_FIRST, GL.GL_FALSE);
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
index 78c0da6a5..bcaabfc48 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
@@ -125,7 +125,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
if (numConfigs[0] > 0) {
GLProfile glp = GLProfile.getDefault(device);
availableCaps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0], GLGraphicsConfigurationUtil.ALL_BITS);
- if( null != availableCaps ) {
+ if( null != availableCaps && availableCaps.size() > 1) {
Collections.sort(availableCaps, EglCfgIDComparator);
}
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
index a23c5a0bc..4b3cd0120 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
@@ -140,11 +140,16 @@ public class WGLGLCapabilities extends GLCapabilities {
break;
case WGLExt.WGL_PIXEL_TYPE_ARB:
- // Fail softly with unknown results here
- if (iresults[i] == WGLExt.WGL_TYPE_RGBA_ARB ||
- iresults[i] == WGLExt.WGL_TYPE_RGBA_FLOAT_ARB) {
+ if(iresults[i] == WGLExt.WGL_TYPE_COLORINDEX_ARB) {
+ return false; // color index not supported
+ }
+
+ if (iresults[i] == WGLExt.WGL_TYPE_RGBA_FLOAT_ARB) {
setPbufferFloatingPointBuffers(true);
}
+
+ // normal RGBA FB: WGLExt.WGL_TYPE_RGBA_ARB
+ // ignore unknown results here
break;
case WGLExt.WGL_FLOAT_COMPONENTS_NV:
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java
index 0e2575bd9..632b373af 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java
@@ -92,11 +92,12 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
// Workaround: Use a fake default configuration
final int werr = GDI.GetLastError();
cfg = WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(new GLCapabilities(GLProfile.getDefault()), aScreen);
+ cfg.markExternal();
if(DEBUG) {
System.err.println("WindowsExternalWGLContext invalid hdc/pfd werr "+werr+", using default cfg: " + cfg);
}
} else {
- cfg = WindowsWGLGraphicsConfiguration.createFromCurrent(factory, hdc, pfdID, glp, aScreen, true);
+ cfg = WindowsWGLGraphicsConfiguration.createFromExternal(factory, hdc, pfdID, glp, aScreen, true);
if(DEBUG) {
System.err.println("WindowsExternalWGLContext valid hdc/pfd, retrieved cfg: " + cfg);
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java
index 7666ae350..ede504735 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java
@@ -69,7 +69,7 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable {
}
AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS);
- WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.createFromCurrent(factory, hdc, pfdID, glp, aScreen, true);
+ WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.createFromExternal(factory, hdc, pfdID, glp, aScreen, true);
return new WindowsExternalWGLDrawable(factory, new WrappedSurface(cfg, hdc));
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
index 3cbef2569..248dfa482 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -55,6 +55,7 @@ import javax.media.nativewindow.ProxySurface;
import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.windows.WindowsGraphicsDevice;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.opengl.GL;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLContext;
@@ -64,8 +65,10 @@ import javax.media.opengl.GLProfile;
import com.jogamp.common.JogampRuntimeException;
import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.common.os.Platform;
import com.jogamp.common.util.ReflectionUtil;
-import javax.media.opengl.GLCapabilities;
+import com.jogamp.common.util.VersionNumber;
+
import jogamp.nativewindow.WrappedSurface;
import jogamp.nativewindow.windows.GDI;
import jogamp.nativewindow.windows.GDISurface;
@@ -164,6 +167,12 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
}
}
+ /**
+ * http://msdn.microsoft.com/en-us/library/ms724832%28v=vs.85%29.aspx
+ * Windows XP 5.1
+ */
+ static final VersionNumber winXPVersionNumber = new VersionNumber ( 5, 1, 0);
+
static class SharedResource implements SharedResourceRunner.Resource {
private WindowsGraphicsDevice device;
private AbstractGraphicsScreen screen;
@@ -173,9 +182,13 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
private boolean hasARBMultisample;
private boolean hasARBPBuffer;
private boolean hasARBReadDrawable;
+ private String vendor;
+ private boolean isVendorATI;
+ private boolean isVendorNVIDIA;
+ private boolean needsCurrenContext4ARBPFDQueries;
SharedResource(WindowsGraphicsDevice dev, AbstractGraphicsScreen scrn, WindowsDummyWGLDrawable draw, WindowsWGLContext ctx,
- boolean arbPixelFormat, boolean arbMultisample, boolean arbPBuffer, boolean arbReadDrawable) {
+ boolean arbPixelFormat, boolean arbMultisample, boolean arbPBuffer, boolean arbReadDrawable, String glVendor) {
device = dev;
screen = scrn;
drawable = draw;
@@ -184,7 +197,27 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
hasARBMultisample = arbMultisample;
hasARBPBuffer = arbPBuffer;
hasARBReadDrawable = arbReadDrawable;
+ vendor = glVendor;
+ if(null != vendor) {
+ isVendorNVIDIA = vendor.startsWith("NVIDIA") ;
+ isVendorATI = vendor.startsWith("ATI") ;
+ }
+
+ if ( isVendorATI() ) {
+ final VersionNumber winVersion = new VersionNumber(Platform.getOSVersion(), ".");
+ final boolean isWinXPOrLess = winVersion.compareTo(winXPVersionNumber) <= 0;
+ if(DEBUG) {
+ System.err.println("needsCurrenContext4ARBPFDQueries: "+winVersion+" <= "+winXPVersionNumber+" = "+isWinXPOrLess+" - "+Platform.getOSVersion());
+ }
+ needsCurrenContext4ARBPFDQueries = isWinXPOrLess;
+ } else {
+ if(DEBUG) {
+ System.err.println("needsCurrenContext4ARBPFDQueries: false");
+ }
+ needsCurrenContext4ARBPFDQueries = false;
+ }
}
+
final public AbstractGraphicsDevice getDevice() { return device; }
final public AbstractGraphicsScreen getScreen() { return screen; }
final public WindowsWGLDrawable getDrawable() { return drawable; }
@@ -194,6 +227,20 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
final boolean hasARBMultisample() { return hasARBMultisample; }
final boolean hasARBPBuffer() { return hasARBPBuffer; }
final boolean hasReadDrawable() { return hasARBReadDrawable; }
+
+ final String vendor() { return vendor; }
+ final boolean isVendorATI() { return isVendorATI; }
+ final boolean isVendorNVIDIA() { return isVendorNVIDIA; }
+
+ /**
+ * Solves bug #480
+ *
+ * TODO: Validate if bug is actually relates to the 'old' ATI Windows driver for old GPU's like X300 etc
+ * and unrelated to the actual Windows version !
+ *
+ * @return true if GL_VENDOR is ATI _and_ platform is Windows version XP or less!
+ */
+ final boolean needsCurrentContext4ARBPFDQueries() { return needsCurrenContext4ARBPFDQueries; }
}
class SharedResourceImplementation implements SharedResourceRunner.Implementation {
@@ -245,6 +292,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
boolean hasARBMultisample;
boolean hasARBPBuffer;
boolean hasARBReadDrawableAvailable;
+ String vendor;
sharedContext.makeCurrent();
try {
hasARBPixelFormat = sharedContext.isExtensionAvailable(WGL_ARB_pixel_format);
@@ -252,6 +300,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
hasARBPBuffer = sharedContext.isExtensionAvailable(GL_ARB_pbuffer);
hasARBReadDrawableAvailable = sharedContext.isExtensionAvailable(WGL_ARB_make_current_read) &&
sharedContext.isFunctionAvailable(wglMakeContextCurrent);
+ vendor = sharedContext.getGL().glGetString(GL.GL_VENDOR);
} finally {
sharedContext.release();
}
@@ -263,10 +312,11 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
System.err.println("!!! multisample: " + hasARBMultisample);
System.err.println("!!! pbuffer: " + hasARBPBuffer);
System.err.println("!!! readDrawable: " + hasARBReadDrawableAvailable);
+ System.err.println("!!! vendor: " + vendor);
}
return new SharedResource(sharedDevice, absScreen, sharedDrawable, sharedContext,
hasARBPixelFormat, hasARBMultisample,
- hasARBPBuffer, hasARBReadDrawableAvailable);
+ hasARBPBuffer, hasARBReadDrawableAvailable, vendor);
} catch (Throwable t) {
throw new GLException("WindowsWGLDrawableFactory - Could not initialize shared resources for "+connection, t);
} finally {
@@ -319,6 +369,7 @@ 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_NV_float_buffer = "WGL_NV_float_buffer";
final static String WGL_ARB_make_current_read = "WGL_ARB_make_current_read";
final static String wglMakeContextCurrent = "wglMakeContextCurrent";
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index ae07646b3..1899f5212 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -50,7 +50,6 @@ import javax.media.opengl.GLProfile;
import jogamp.nativewindow.windows.GDI;
import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR;
-import jogamp.opengl.GLContextImpl;
import jogamp.opengl.GLGraphicsConfigurationUtil;
public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable {
@@ -61,14 +60,15 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
protected static final int MAX_ATTRIBS = 256;
private GLCapabilitiesChooser chooser;
- private boolean isChosen = false;
+ private boolean isDetermined = false;
+ private boolean isExternal = false;
WindowsWGLGraphicsConfiguration(AbstractGraphicsScreen screen,
GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested,
GLCapabilitiesChooser chooser) {
super(screen, capsChosen, capsRequested);
this.chooser=chooser;
- this.isChosen = false;
+ this.isDetermined = false;
}
WindowsWGLGraphicsConfiguration(AbstractGraphicsScreen screen,
@@ -79,7 +79,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
}
- static WindowsWGLGraphicsConfiguration createFromCurrent(GLDrawableFactory _factory, long hdc, int pfdID,
+ static WindowsWGLGraphicsConfiguration createFromExternal(GLDrawableFactory _factory, long hdc, int pfdID,
GLProfile glp, AbstractGraphicsScreen screen, boolean onscreen)
{
if(_factory==null) {
@@ -111,7 +111,9 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
", pfdID "+pfdID+", onscreen "+onscreen+", hasARB "+hasARB);
}
- return new WindowsWGLGraphicsConfiguration(screen, caps, caps);
+ WindowsWGLGraphicsConfiguration cfg = new WindowsWGLGraphicsConfiguration(screen, caps, caps);
+ cfg.markExternal();
+ return cfg;
}
public Object clone() {
@@ -128,6 +130,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
* @param pfIDs optional pool of preselected PixelFormat IDs, maybe null for unrestricted selection
*
* @see #isDetermined()
+ * @see #isExternal()
*/
public final void updateGraphicsConfiguration(GLDrawableFactory factory, NativeSurface ns, int[] pfIDs) {
WindowsWGLGraphicsConfigurationFactory.updateGraphicsConfiguration(chooser, factory, ns, pfIDs);
@@ -148,18 +151,58 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
WindowsWGLGraphicsConfigurationFactory.preselectGraphicsConfiguration(chooser, factory, device, this, pfdIDs);
}
+ /**
+ * Sets the hdc's PixelFormat, this configuration's capabilities and marks it as determined.
+ */
+ final void setPixelFormat(long hdc, WGLGLCapabilities caps) {
+ if (0 == hdc) {
+ throw new GLException("Error: HDC is null");
+ }
+
+ if (!GDI.SetPixelFormat(hdc, caps.getPFDID(), caps.getPFD())) {
+ throw new GLException("Unable to set pixel format " + caps +
+ " for device context " + toHexString(hdc) +
+ ": error code " + GDI.GetLastError());
+ }
+ if (DEBUG) {
+ System.err.println("!!! setPixelFormat (ARB): hdc "+toHexString(hdc) +", "+caps);
+ }
+ setCapsPFD(caps);
+ }
+
+ /**
+ * Only sets this configuration's capabilities and marks it as determined,
+ * the actual pixelformat is not set.
+ */
final void setCapsPFD(WGLGLCapabilities caps) {
setChosenCapabilities(caps);
- this.isChosen=true;
+ this.isDetermined = true;
if (DEBUG) {
System.err.println("*** setCapsPFD: "+caps);
}
}
- public final boolean isDetermined() { return isChosen; }
- public final PIXELFORMATDESCRIPTOR getPixelFormat() { return isChosen ? ((WGLGLCapabilities)capabilitiesChosen).getPFD() : null; }
- public final int getPixelFormatID() { return isChosen ? ((WGLGLCapabilities)capabilitiesChosen).getPFDID() : 0; }
- public final boolean isChoosenByARB() { return isChosen ? ((WGLGLCapabilities)capabilitiesChosen).isSetByARB() : false; }
+ /**
+ * External configuration's HDC pixelformat shall not be modified
+ */
+ public final boolean isExternal() { return isExternal; }
+
+ final void markExternal() {
+ this.isExternal=true;
+ }
+
+ /**
+ * Determined configuration states set target capabilties via {@link #setCapsPFD(WGLGLCapabilities)},
+ * but does not imply a set pixelformat.
+ *
+ * @see #setPixelFormat(long, WGLGLCapabilities)
+ * @see #setCapsPFD(WGLGLCapabilities)
+ */
+ public final boolean isDetermined() { return isDetermined; }
+
+ public final PIXELFORMATDESCRIPTOR getPixelFormat() { return isDetermined ? ((WGLGLCapabilities)capabilitiesChosen).getPFD() : null; }
+ public final int getPixelFormatID() { return isDetermined ? ((WGLGLCapabilities)capabilitiesChosen).getPFDID() : 0; }
+ public final boolean isChoosenByARB() { return isDetermined ? ((WGLGLCapabilities)capabilitiesChosen).isSetByARB() : false; }
static int fillAttribsForGeneralWGLARBQuery(WindowsWGLDrawableFactory.SharedResource sharedResource, int[] iattributes) {
int niattribs = 0;
@@ -187,15 +230,18 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
iattributes[niattribs++] = WGLExt.WGL_SAMPLE_BUFFERS_ARB;
iattributes[niattribs++] = WGLExt.WGL_SAMPLES_ARB;
}
+
if(sharedResource.hasARBPBuffer()) {
- // pbo float buffer
- iattributes[niattribs++] = WGLExt.WGL_PIXEL_TYPE_ARB; // ati
- iattributes[niattribs++] = WGLExt.WGL_FLOAT_COMPONENTS_NV; // nvidia
+ WindowsWGLContext sharedCtx = sharedResource.getContext();
+ if(null != sharedCtx && sharedCtx.isExtensionAvailable(WindowsWGLDrawableFactory.WGL_NV_float_buffer)) {
+ // pbo float buffer
+ iattributes[niattribs++] = WGLExt.WGL_FLOAT_COMPONENTS_NV; // nvidia
+ }
}
return niattribs;
}
-
+
static boolean wglARBPFIDValid(WindowsWGLContext sharedCtx, long hdc, int pfdID) {
int[] in = new int[1];
int[] out = new int[1];
@@ -432,6 +478,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
boolean rect = caps.getPbufferRenderToTextureRectangle();
boolean useFloat = caps.getPbufferFloatingPointBuffers();
boolean ati = false;
+ boolean nvidia = false;
if (pbuffer && sharedResource.hasARBPBuffer()) {
// Check some invariants and set up some state
if (rect && !rtt) {
@@ -446,21 +493,21 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
}
if (useFloat) {
- if (!sharedCtx.isExtensionAvailable("WGL_ATI_pixel_format_float") &&
- !sharedCtx.isExtensionAvailable("WGL_NV_float_buffer")) {
- throw new GLException("Floating-point pbuffers not supported by this hardware");
- }
-
// Prefer NVidia extension over ATI
- if (sharedCtx.isExtensionAvailable("WGL_NV_float_buffer")) {
- ati = false;
+ nvidia = sharedCtx.isExtensionAvailable(WindowsWGLDrawableFactory.WGL_NV_float_buffer);
+ if(nvidia) {
floatMode[0] = GLPbuffer.NV_FLOAT;
} else {
- ati = true;
- floatMode[0] = GLPbuffer.ATI_FLOAT;
+ ati = sharedCtx.isExtensionAvailable("WGL_ATI_pixel_format_float");
+ if(ati) {
+ floatMode[0] = GLPbuffer.ATI_FLOAT;
+ } else {
+ throw new GLException("Floating-point pbuffers not supported by this hardware");
+ }
}
+
if (DEBUG) {
- System.err.println("Using " + (ati ? "ATI" : "NVidia") + " floating-point extension");
+ System.err.println("Using " + (ati ? "ATI" : ( nvidia ? "NVidia" : "NONE" ) ) + " floating-point extension");
}
}
@@ -483,7 +530,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
}
}
- if (useFloat && !ati) {
+ if (useFloat && nvidia) {
iattributes[niattribs++] = WGLExt.WGL_FLOAT_COMPONENTS_NV;
iattributes[niattribs++] = GL.GL_TRUE;
}
@@ -491,6 +538,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
if (rtt) {
if (useFloat) {
assert(!ati);
+ assert(nvidia);
if (!rect) {
throw new GLException("Render-to-floating-point-texture only supported on NVidia hardware with render-to-texture-rectangle");
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index fdf10a5ef..8c1f5e87c 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -44,6 +44,7 @@ import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindowFactory;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
@@ -52,7 +53,6 @@ import jogamp.nativewindow.windows.GDI;
import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR;
import jogamp.opengl.GLGraphicsConfigurationFactory;
import jogamp.opengl.GLGraphicsConfigurationUtil;
-import jogamp.opengl.SharedResourceRunner;
import java.util.ArrayList;
import java.util.Collections;
@@ -112,9 +112,16 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
WindowsWGLDrawable sharedDrawable = sharedResource.getDrawable();
GLCapabilitiesImmutable capsChosen = sharedDrawable.getChosenGLCapabilities();
+ WindowsWGLContext sharedContext = sharedResource.getContext();
List availableCaps = null;
-
- sharedDrawable.lockSurface();
+
+ if ( sharedResource.needsCurrentContext4ARBPFDQueries() ) {
+ if(GLContext.CONTEXT_NOT_CURRENT == sharedContext.makeCurrent()) {
+ throw new GLException("Could not make Shared Context current: "+device);
+ }
+ } else {
+ sharedDrawable.lockSurface();
+ }
try {
long hdc = sharedDrawable.getHandle();
if (0 == hdc) {
@@ -123,14 +130,18 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
if (sharedResource.hasARBPixelFormat()) {
availableCaps = getAvailableGLCapabilitiesARB(hdc, sharedResource, capsChosen.getGLProfile());
}
- if( null == availableCaps || 0 == availableCaps.size() ) {
+ if( null == availableCaps || availableCaps.isEmpty() ) {
availableCaps = getAvailableGLCapabilitiesGDI(hdc, capsChosen.getGLProfile());
}
} finally {
- sharedDrawable.unlockSurface();
+ if ( sharedResource.needsCurrentContext4ARBPFDQueries() ) {
+ sharedContext.release();
+ } else {
+ sharedDrawable.unlockSurface();
+ }
}
- if( null != availableCaps ) {
+ if( null != availableCaps && availableCaps.size() > 1 ) {
Collections.sort(availableCaps, PfdIDComparator);
}
return availableCaps;
@@ -180,25 +191,26 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- if(!config.isDetermined()) {
- updateGraphicsConfiguration(config, chooser, factory, hdc, false, pfdIDs);
- } else {
- // set PFD if not set yet
- int pfdID = -1;
- boolean set = false;
- if ( 1 > ( pfdID = GDI.GetPixelFormat(hdc) ) ) {
- if (!GDI.SetPixelFormat(hdc, config.getPixelFormatID(), config.getPixelFormat())) {
- throw new GLException("Unable to set pixel format " + config.getPixelFormatID() +
- " for device context " + toHexString(hdc) +
- ": error code " + GDI.GetLastError());
- }
- set = true;
- pfdID = config.getPixelFormatID();
- }
- if (DEBUG) {
- System.err.println("!!! setPixelFormat (post): hdc "+toHexString(hdc) +", "+config.getPixelFormatID()+" -> "+pfdID+", set: "+set);
- Thread.dumpStack();
- }
+ if( !config.isExternal() ) {
+ if( !config.isDetermined() ) {
+ updateGraphicsConfiguration(config, chooser, factory, hdc, false, pfdIDs);
+ } else {
+ // set PFD if not set yet
+ int pfdID = -1;
+ boolean set = false;
+ if ( 1 > ( pfdID = GDI.GetPixelFormat(hdc) ) ) {
+ if (!GDI.SetPixelFormat(hdc, config.getPixelFormatID(), config.getPixelFormat())) {
+ throw new GLException("Unable to set pixel format " + config.getPixelFormatID() +
+ " for device context " + toHexString(hdc) +
+ ": error code " + GDI.GetLastError());
+ }
+ set = true;
+ }
+ if (DEBUG) {
+ System.err.println("!!! setPixelFormat (post): hdc "+toHexString(hdc) +", "+pfdID+" -> "+config.getPixelFormatID()+", set: "+set);
+ Thread.dumpStack();
+ }
+ }
}
} finally {
ns.unlockSurface();
@@ -247,8 +259,23 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
System.err.println("!!! user chosen caps " + config.getChosenCapabilities());
}
- if( !updateGraphicsConfigurationARB(hdc, extHDC, config, chooser, (WindowsWGLDrawableFactory)factory, pfdIDs) ) {
- updateGraphicsConfigurationGDI(hdc, extHDC, config, chooser, pfdIDs);
+ AbstractGraphicsDevice device = config.getScreen().getDevice();
+ WindowsWGLDrawableFactory.SharedResource sharedResource = ((WindowsWGLDrawableFactory)factory).getOrCreateSharedResource(device);
+ WindowsWGLContext sharedContext = null;
+ if (null != sharedResource && sharedResource.needsCurrentContext4ARBPFDQueries()) {
+ sharedContext = sharedResource.getContext();
+ if(GLContext.CONTEXT_NOT_CURRENT == sharedContext.makeCurrent()) {
+ throw new GLException("Could not make Shared Context current: "+device);
+ }
+ }
+ try {
+ if( !updateGraphicsConfigurationARB(hdc, extHDC, config, chooser, (WindowsWGLDrawableFactory)factory, pfdIDs) ) {
+ updateGraphicsConfigurationGDI(hdc, extHDC, config, chooser, pfdIDs);
+ }
+ } finally {
+ if (null != sharedContext) {
+ sharedContext.release();
+ }
}
}
@@ -373,16 +400,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
if ( !extHDC && !pixelFormatSet ) {
- if (!GDI.SetPixelFormat(hdc, pixelFormatCaps.getPFDID(), pixelFormatCaps.getPFD())) {
- throw new GLException("Unable to set pixel format " + pixelFormatCaps.getPFDID() +
- " for device context " + toHexString(hdc) +
- ": error code " + GDI.GetLastError());
- }
- if (DEBUG) {
- System.err.println("!!! setPixelFormat (ARB): hdc "+toHexString(hdc) +", "+config.getPixelFormatID()+" -> "+pixelFormatCaps.getPFDID());
- }
+ config.setPixelFormat(hdc, pixelFormatCaps);
+ } else {
+ config.setCapsPFD(pixelFormatCaps);
}
- config.setCapsPFD(pixelFormatCaps);
return true;
}
@@ -398,7 +419,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
boolean onscreen = capsChosen.isOnscreen();
GLProfile glProfile = capsChosen.getGLProfile();
- ArrayList/*<WGLGLCapabilities>*/ availableCaps = new ArrayList();
+ ArrayList<WGLGLCapabilities> availableCaps = new ArrayList<WGLGLCapabilities>();
int pfdID; // chosen or preset PFD ID
WGLGLCapabilities pixelFormatCaps = null; // chosen or preset PFD ID's caps
boolean pixelFormatSet = false; // indicates a preset PFD ID [caps]
@@ -447,7 +468,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
return false;
}
- pixelFormatCaps = (WGLGLCapabilities) availableCaps.get(chosenIndex);
+ pixelFormatCaps = availableCaps.get(chosenIndex);
if (DEBUG) {
System.err.println("!!! chosen pfdID (GDI): native recommended "+ (recommendedIndex+1) +
", caps " + pixelFormatCaps);
@@ -455,16 +476,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
if ( !extHDC && !pixelFormatSet ) {
- if (!GDI.SetPixelFormat(hdc, pixelFormatCaps.getPFDID(), pixelFormatCaps.getPFD())) {
- throw new GLException("Unable to set pixel format " + pixelFormatCaps.getPFDID() +
- " for device context " + toHexString(hdc) +
- ": error code " + GDI.GetLastError());
- }
- if (DEBUG) {
- System.err.println("!!! setPixelFormat (GDI): hdc "+toHexString(hdc) +", "+config.getPixelFormatID()+" -> " + pixelFormatCaps.getPFDID());
- }
+ config.setPixelFormat(hdc, pixelFormatCaps);
+ } else {
+ config.setCapsPFD(pixelFormatCaps);
}
- config.setCapsPFD(pixelFormatCaps);
return true;
}
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
index c3d4563ea..109311123 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
@@ -271,6 +271,9 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
if(GLX.GLX_BAD_ATTRIBUTE == GLX.glXGetFBConfigAttrib(display, fbcfg, GLX.GLX_RENDER_TYPE, tmp, 0)) {
return false;
}
+ if( 0 == ( GLX.GLX_RGBA_BIT & tmp[0] ) ) {
+ return false; // no RGBA -> color index not supported
+ }
GLCapabilities res = new X11GLCapabilities(visualInfo, fbcfg, fbcfgid, glp);
res.setDoubleBuffered(glXGetFBConfig(display, fbcfg, GLX.GLX_DOUBLEBUFFER, tmp, 0) != 0);
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 319a52c07..b984f1633 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -111,10 +111,10 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF
if( sharedResource.isGLXVersionGreaterEqualOneThree() ) {
availableCaps = getAvailableGLCapabilitiesFBConfig(sharedScreen, glp);
}
- if( null == availableCaps || 0 == availableCaps.size() ) {
+ if( null == availableCaps || availableCaps.isEmpty() ) {
availableCaps = getAvailableGLCapabilitiesXVisual(sharedScreen, glp);
}
- if( null != availableCaps ) {
+ if( null != availableCaps && availableCaps.size() > 1 ) {
Collections.sort(availableCaps, XVisualIDComparator);
}
return availableCaps;