aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-07-31 11:52:46 -0700
committerSven Gothel <[email protected]>2009-07-31 11:52:46 -0700
commit786b056afb90311a8c06a57fc24f242f8df713e1 (patch)
tree90c6ef96491209a08eabac62e3eb0602db79e34f /src
parent8b40dbcd98bbe0b7b9c0dfb321e3e1e4c1810dd5 (diff)
Gluegen:
- Fix array element type name and const qualifier JOGL: - GL3: Set ArgumentIsString for GL3.1 methods - JAR file creation: Add 'filesonly' option - GLU: Static check of available impl., better fallback for GL2 without GLUgl2. - WGL: (Performance + Java2D/GL FBO works again) - Refactor WGL_ARB_pixel_format's HDC -> GLCapabilities: HDC2Caps - Revert change where we always create a dummy drawable/context for WGL selection (HDC2Caps). In case of no multisampling, use PFD2Caps only. - Update config using HDC2Caps (WGL_ARB_pixel_format) after context creation, if not done already -> updateCapabilitiesByWGL(). - profile.jogl: Add debug jars
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java6
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java7
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java5
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java149
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java112
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java7
8 files changed, 187 insertions, 107 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
index 15ccc0f96..81fc0b78b 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
@@ -140,10 +140,10 @@ public abstract class GLDrawableImpl implements GLDrawable {
public String toString() {
return getClass().getName()+"[realized "+getRealized()+
- ",\n\trequested "+getRequestedGLCapabilities()+
- ",\n\tchosen "+getChosenGLCapabilities()+
+ ",\n\tfactory "+getFactory()+
",\n\twindow "+getNativeWindow()+
- ",\n\tfactory "+getFactory()+"]";
+ ",\n\trequested "+getRequestedGLCapabilities()+
+ ",\n\tchosen "+getChosenGLCapabilities()+"]";
}
protected GLDrawableFactory factory;
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
index b9fc80156..31e65fc8c 100755
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
@@ -51,7 +51,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
private boolean created = true;
private GLContext lastContext;
- private WindowsExternalWGLContext(Drawable drawable, long hglrc) {
+ private WindowsExternalWGLContext(Drawable drawable, long hglrc, WindowsWGLGraphicsConfiguration cfg) {
super(drawable, null);
this.hglrc = hglrc;
if (DEBUG) {
@@ -59,6 +59,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
}
GLContextShareSet.contextCreated(this);
setGLFunctionAvailability(false);
+ cfg.updateCapabilitiesByWGL(this);
}
protected static WindowsExternalWGLContext create(GLDrawableFactory factory, GLProfile glp) {
@@ -76,12 +77,12 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
}
AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault();
- WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.create(glp, aScreen, hdc, pfdID, true, true);
+ WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.create(hdc, pfdID, glp, aScreen, true, true);
NullWindow nw = new NullWindow(cfg);
nw.setSurfaceHandle(hdc);
- return new WindowsExternalWGLContext(new Drawable(factory, nw), hglrc);
+ return new WindowsExternalWGLContext(new Drawable(factory, nw), hglrc, cfg);
}
public int makeCurrent() throws GLException {
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java
index 706675893..9b87afc38 100755
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java
@@ -61,12 +61,12 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable {
}
AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault();
- WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.create(glp, aScreen, hdc, pfdID, true, true);
+ WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.create(hdc, pfdID, glp, aScreen, true, true);
NullWindow nw = new NullWindow(cfg);
nw.setSurfaceHandle(hdc);
- // cfg.updateGraphicsConfiguration(factory, nw);
+ cfg.updateGraphicsConfiguration(factory, nw);
return new WindowsExternalWGLDrawable(factory, nw);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
index f54e8f1a0..79dda9049 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -295,7 +295,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
if(newCaps.isOnscreen()) {
throw new GLException("Error: Selected Onscreen Caps for PBuffer: "+newCaps);
}
- config.setCapsPFD(newCaps, pfd, pformats[whichFormat]);
+ config.setCapsPFD(newCaps, pfd, pformats[whichFormat], true);
} else {
PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor();
if (WGL.DescribePixelFormat(parentHdc, pformats[whichFormat], pfd.size(), pfd) == 0) {
@@ -305,7 +305,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
if(newCaps.isOnscreen()) {
throw new GLException("Error: Selected Onscreen Caps for PBuffer: "+newCaps);
}
- config.setCapsPFD(newCaps, pfd, pformats[whichFormat]);
+ config.setCapsPFD(newCaps, pfd, pformats[whichFormat], false);
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
index 92a563445..578279586 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -264,6 +264,11 @@ public class WindowsWGLContext extends GLContextImpl {
if (created) {
setGLFunctionAvailability(false);
+
+ WindowsWGLGraphicsConfiguration config =
+ (WindowsWGLGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ config.updateCapabilitiesByWGL(this);
+
return CONTEXT_CURRENT_NEW;
}
return CONTEXT_CURRENT;
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index 1a8d45465..844e72841 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -49,6 +49,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
private int pixelfmtID;
private boolean isChosen = false;
private GLCapabilitiesChooser chooser;
+ private boolean choosenByWGLPixelFormat=false;
public WindowsWGLGraphicsConfiguration(AbstractGraphicsScreen screen, GLCapabilities capsChosen, GLCapabilities capsRequested,
PIXELFORMATDESCRIPTOR pixelfmt, int pixelfmtID, GLCapabilitiesChooser chooser) {
@@ -58,17 +59,26 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
this.pixelfmtID = pixelfmtID;
}
- public static WindowsWGLGraphicsConfiguration create(GLProfile glp, AbstractGraphicsScreen screen, long hdc, int pfdID, boolean onscreen, boolean usePBuffer) {
- PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor();
- if (WGL.DescribePixelFormat(hdc, pfdID, pfd.size(), pfd) == 0) {
- throw new GLException("Unable to describe pixel format " + pfdID);
+ public static WindowsWGLGraphicsConfiguration create(long hdc, int pfdID,
+ GLProfile glp, AbstractGraphicsScreen screen, boolean onscreen, boolean usePBuffer)
+ {
+ if(pfdID<=0) {
+ throw new GLException("Invalid pixelformat id "+pfdID);
}
if(null==glp) {
glp = GLProfile.getDefault();
}
+ PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor();
+ if (WGL.DescribePixelFormat(hdc, pfdID, pfd.size(), pfd) == 0) {
+ throw new GLException("Unable to describe pixel format " + pfdID);
+ }
+
GLCapabilities caps = PFD2GLCapabilities(glp, pfd, onscreen, usePBuffer);
+ if(null==caps) {
+ throw new GLException("Couldn't choose Capabilities by: HDC 0x"+Long.toHexString(hdc)+", pfdID "+pfdID);
+ }
WindowsWGLGraphicsConfiguration cfg = new WindowsWGLGraphicsConfiguration(screen, caps, caps, pfd, pfdID, new DefaultGLCapabilitiesChooser());
- cfg.setCapsPFD(caps, pfd, pfdID);
+ cfg.setCapsPFD(caps, pfd, pfdID, false);
return cfg;
}
@@ -77,15 +87,40 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
return super.clone();
}
+ /** Update config - before having a valid context */
protected void updateGraphicsConfiguration(GLDrawableFactory factory, NativeWindow nativeWindow) {
WindowsWGLGraphicsConfigurationFactory.updateGraphicsConfiguration(chooser, factory, nativeWindow);
}
- protected void setCapsPFD(GLCapabilities caps, PIXELFORMATDESCRIPTOR pfd, int pfdID) {
- // FIXME: setScreen ( .. )
+
+ /** Update config - after having a valid and current context */
+ protected void updateCapabilitiesByWGL(GLContextImpl context) {
+ if(choosenByWGLPixelFormat) return; // already done ..
+
+ GLCapabilities capabilities = (GLCapabilities) getRequestedCapabilities();
+ boolean onscreen = capabilities.isOnscreen();
+ boolean usePBuffer = capabilities.isPBuffer();
+ GLProfile glp = capabilities.getGLProfile();
+
+ WGLExt wglExt = (WGLExt) context.getPlatformGLExtensions();
+ GLDrawable drawable = context.getGLDrawable();
+ NativeWindow nativeWindow = drawable.getNativeWindow();
+ long hdc = nativeWindow.getSurfaceHandle();
+
+ GLCapabilities[] 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) {
this.pixelfmt = pfd;
this.pixelfmtID = pfdID;
setChosenCapabilities(caps);
- isChosen=true;
+ this.isChosen=true;
+ this.choosenByWGLPixelFormat=choosenByWGLPixelFormat;
+ if (DEBUG) {
+ System.err.println("*** setCapsPFD: WGL-Choosen "+choosenByWGLPixelFormat+", pfdID "+pfdID+", "+caps);
+ }
}
public boolean getCapabilitiesChosen() {
@@ -94,6 +129,102 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
public PIXELFORMATDESCRIPTOR getPixelFormat() { return pixelfmt; }
public int getPixelFormatID() { return pixelfmtID; }
+ public boolean isChoosenByWGL() { return choosenByWGLPixelFormat; }
+
+ 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) {
+
+ if(haveWGLChoosePixelFormatARB<0) {
+ haveWGLChoosePixelFormatARB = wglExt.isExtensionAvailable("WGL_ARB_pixel_format")?1:0;
+ }
+ if(haveWGLARBMultisample<0) {
+ haveWGLARBMultisample = wglExt.isExtensionAvailable("WGL_ARB_multisample")?1:0;
+ }
+ if (0==haveWGLChoosePixelFormatARB) {
+ return null;
+ }
+
+ // Produce a list of GLCapabilities to give to the
+ // GLCapabilitiesChooser.
+ // Use wglGetPixelFormatAttribivARB instead of
+ // DescribePixelFormat to get higher-precision information
+ // about the pixel format (should make the GLCapabilities
+ // more precise as well...i.e., remove the
+ // "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;
+ int numFormats = 0;
+ int niattribs = 0;
+ int[] iattributes = new int [2*MAX_ATTRIBS];
+ int[] iresults = new int [2*MAX_ATTRIBS];
+
+ iattributes[0] = WGLExt.WGL_NUMBER_PIXEL_FORMATS_ARB;
+ if (wglExt.wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, iattributes, 0, iresults, 0)) {
+ numFormats = iresults[0];
+
+ if (DEBUG) {
+ System.err.println("wglGetPixelFormatAttribivARB reported WGL_NUMBER_PIXEL_FORMATS = " + numFormats);
+ }
+
+ if(pfdIDOnly>0 && pfdIDOnly>numFormats) {
+ throw new GLException("Invalid pixelformat ID " + pfdIDOnly + " (should be between 1 and " + numFormats + ")");
+ }
+
+ // Should we be filtering out the pixel formats which aren't
+ // applicable, as we are doing here?
+ // We don't have enough information in the GLCapabilities to
+ // represent those that aren't...
+ iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_WINDOW_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_ACCELERATION_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_SUPPORT_OPENGL_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_DEPTH_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_STENCIL_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_DOUBLE_BUFFER_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_STEREO_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_PIXEL_TYPE_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_RED_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_GREEN_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_BLUE_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_ALPHA_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_ACCUM_RED_BITS_ARB;
+ 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 (1==haveWGLARBMultisample) {
+ iattributes[niattribs++] = WGLExt.WGL_SAMPLE_BUFFERS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_SAMPLES_ARB;
+ }
+
+ if(pfdIDOnly>0) {
+ availableCaps = new GLCapabilities[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];
+ 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");
+ }
+ availableCaps[i] = AttribList2GLCapabilities(glp, iattributes, niattribs, iresults,
+ relaxed, onscreen, usePBuffer);
+ }
+ }
+ } else {
+ long lastErr = WGL.GetLastError();
+ // Intel Extreme graphics fails with a zero error code
+ if (lastErr != 0) {
+ throw new GLException("Unable to enumerate pixel formats of window using wglGetPixelFormatAttribivARB: error code " + WGL.GetLastError());
+ }
+ }
+ return availableCaps;
+ }
public static boolean GLCapabilities2AttribList(GLCapabilities caps,
int[] iattributes,
@@ -498,7 +629,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
}
public String toString() {
- return "WindowsWGLGraphicsConfiguration["+getScreen()+", pfdID " + pixelfmtID +
+ return "WindowsWGLGraphicsConfiguration["+getScreen()+", pfdID " + pixelfmtID + ", wglChoosen "+choosenByWGLPixelFormat+
",\n\trequested " + getRequestedCapabilities() +
",\n\tchosen " + getChosenCapabilities() +
"]";
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index f5974dc61..98ad83313 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -99,6 +99,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects");
}
+ boolean choosenBywGLPixelFormat = false;
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) nativeWindow.getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilities capabilities = (GLCapabilities) config.getRequestedCapabilities();
boolean onscreen = capabilities.isOnscreen();
@@ -113,7 +114,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
PIXELFORMATDESCRIPTOR pfd = null;
- int pixelFormat = -1;
+ int pixelFormat = -1; // 1-based pixel format
boolean pixelFormatSet = false;
GLCapabilities chosenCaps = null;
@@ -125,7 +126,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
// - or the Java2D/OpenGL pipeline's configuration
if (DEBUG) {
System.err.println("!!!! NOTE: pixel format already chosen for HDC: 0x" + Long.toHexString(hdc)+
- ", pixelformat "+WGL.GetPixelFormat(hdc));
+ ", pixelformat "+pixelFormat);
}
pixelFormatSet = true;
}
@@ -138,27 +139,25 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
WindowsWGLDrawable dummyDrawable = null;
GLContextImpl dummyContext = null;
WGLExt dummyWGLExt = null;
- dummyDrawable = new WindowsDummyWGLDrawable(factory);
- dummyContext = (GLContextImpl) dummyDrawable.createContext(null);
- if (dummyContext != null) {
- dummyContext.makeCurrent();
- dummyWGLExt = (WGLExt) dummyContext.getPlatformGLExtensions();
- }
- int recommendedPixelFormat = pixelFormat - 1;
+ if (capabilities.getSampleBuffers()) {
+ dummyDrawable = new WindowsDummyWGLDrawable(factory);
+ dummyContext = (GLContextImpl) dummyDrawable.createContext(null);
+ if (dummyContext != null) {
+ dummyContext.makeCurrent();
+ dummyWGLExt = (WGLExt) dummyContext.getPlatformGLExtensions();
+ }
+ }
+ int recommendedPixelFormat = pixelFormat; // 1-based pixel format
boolean haveWGLChoosePixelFormatARB = false;
- boolean haveWGLARBMultisample = false;
boolean gotAvailableCaps = false;
if (dummyWGLExt != null) {
try {
haveWGLChoosePixelFormatARB = dummyWGLExt.isExtensionAvailable("WGL_ARB_pixel_format");
if (haveWGLChoosePixelFormatARB) {
- haveWGLARBMultisample = dummyWGLExt.isExtensionAvailable("WGL_ARB_multisample");
-
- int[] iattributes = new int [2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS];
- int[] iresults = new int [2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS];
- float[] fattributes = new float[1];
-
if(pixelFormat<=0) {
+ int[] iattributes = new int [2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS];
+ float[] fattributes = new float[1];
+
if(WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList(capabilities,
iattributes,
dummyWGLExt,
@@ -174,8 +173,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
numFormatsTmp, 0)) {
numFormats = numFormatsTmp[0];
if (recommendedPixelFormat<=0 && numFormats > 0) {
- // Remove one-basing of pixel format (added on later)
- recommendedPixelFormat = pformats[0] - 1;
+ recommendedPixelFormat = pformats[0];
if (DEBUG) {
System.err.println(getThreadName() + ": Used wglChoosePixelFormatARB to recommend pixel format " + recommendedPixelFormat);
}
@@ -187,7 +185,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
}
if (DEBUG) {
- if (recommendedPixelFormat < 0) {
+ if (recommendedPixelFormat <= 0) {
System.err.print(getThreadName() + ": wglChoosePixelFormatARB didn't recommend a pixel format");
if (capabilities.getSampleBuffers()) {
System.err.print(" for multisampled GLCapabilities");
@@ -198,65 +196,9 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
}
- // Produce a list of GLCapabilities to give to the
- // GLCapabilitiesChooser.
- // Use wglGetPixelFormatAttribivARB instead of
- // DescribePixelFormat to get higher-precision information
- // about the pixel format (should make the GLCapabilities
- // more precise as well...i.e., remove the
- // "HardwareAccelerated" bit, which is basically
- // meaningless, and put in whether it can render to a
- // window, to a pbuffer, or to a pixmap)
- int niattribs = 0;
- iattributes[0] = WGLExt.WGL_NUMBER_PIXEL_FORMATS_ARB;
- if (dummyWGLExt.wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, iattributes, 0, iresults, 0)) {
- numFormats = iresults[0];
-
- if (DEBUG) {
- System.err.println("wglGetPixelFormatAttribivARB reported WGL_NUMBER_PIXEL_FORMATS = " + numFormats);
- }
-
- // Should we be filtering out the pixel formats which aren't
- // applicable, as we are doing here?
- // We don't have enough information in the GLCapabilities to
- // represent those that aren't...
- iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_WINDOW_ARB;
- iattributes[niattribs++] = WGLExt.WGL_ACCELERATION_ARB;
- iattributes[niattribs++] = WGLExt.WGL_SUPPORT_OPENGL_ARB;
- iattributes[niattribs++] = WGLExt.WGL_DEPTH_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_STENCIL_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_DOUBLE_BUFFER_ARB;
- iattributes[niattribs++] = WGLExt.WGL_STEREO_ARB;
- iattributes[niattribs++] = WGLExt.WGL_PIXEL_TYPE_ARB;
- iattributes[niattribs++] = WGLExt.WGL_RED_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_GREEN_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_BLUE_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_ALPHA_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_ACCUM_RED_BITS_ARB;
- 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) {
- iattributes[niattribs++] = WGLExt.WGL_SAMPLE_BUFFERS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_SAMPLES_ARB;
- }
-
- availableCaps = new GLCapabilities[numFormats];
- for (int i = 0; i < numFormats; i++) {
- if (!dummyWGLExt.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");
- }
- availableCaps[i] = WindowsWGLGraphicsConfiguration.AttribList2GLCapabilities(glProfile, iattributes, niattribs, iresults,
- pixelFormatSet, onscreen, usePBuffer);
- }
- gotAvailableCaps = true;
- } else {
- long lastErr = WGL.GetLastError();
- // Intel Extreme graphics fails with a zero error code
- if (lastErr != 0) {
- throw new GLException("Unable to enumerate pixel formats of window using wglGetPixelFormatAttribivARB: error code " + WGL.GetLastError());
- }
- }
+ availableCaps = WindowsWGLGraphicsConfiguration.HDC2GLCapabilities(dummyWGLExt, hdc, -1, glProfile, pixelFormatSet, onscreen, usePBuffer);
+ gotAvailableCaps = null!=availableCaps ;
+ choosenBywGLPixelFormat = gotAvailableCaps ;
}
} finally {
dummyContext.release();
@@ -265,7 +207,6 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
}
- // Fallback path for older cards, in particular Intel Extreme motherboard graphics
if (!gotAvailableCaps) {
if (DEBUG) {
if (!capabilities.getSampleBuffers()) {
@@ -279,8 +220,6 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
if (DEBUG) {
System.err.println(getThreadName() + ": Recommended pixel format = " + recommendedPixelFormat);
}
- // Remove one-basing of pixel format (added on later)
- recommendedPixelFormat -= 1;
numFormats = WGL.DescribePixelFormat(hdc, 1, 0, null);
if (numFormats == 0) {
@@ -305,19 +244,18 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
if(null!=chooser) {
// Supply information to chooser
try {
- pixelFormat = chooser.chooseCapabilities(capabilities, availableCaps, recommendedPixelFormat);
+ pixelFormat = chooser.chooseCapabilities(capabilities, availableCaps, recommendedPixelFormat) + 1;
} catch (NativeWindowException e) {
throw new GLException(e);
}
} else {
pixelFormat = recommendedPixelFormat;
}
- if ((pixelFormat < 0) || (pixelFormat >= numFormats)) {
+ if ((pixelFormat <= 0) || (pixelFormat > numFormats)) {
throw new GLException("Invalid result " + pixelFormat +
- " from GLCapabilitiesChooser (should be between 0 and " +
- (numFormats - 1) + ")");
+ " from GLCapabilitiesChooser (should be between 1 and " +
+ numFormats + ")");
}
- pixelFormat += 1; // one-base the index
}
chosenCaps = availableCaps[pixelFormat-1];
if (DEBUG) {
@@ -355,7 +293,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
} else {
capabilities = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, pfd, onscreen, usePBuffer);
}
- config.setCapsPFD(capabilities, pfd, pixelFormat);
+ config.setCapsPFD(capabilities, pfd, pixelFormat, choosenBywGLPixelFormat);
}
protected static String getThreadName() {
diff --git a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
index a173baff0..18dc7dae3 100755
--- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
@@ -59,7 +59,7 @@ public class WindowsWindow extends Window {
hmon = MonitorFromWindow(windowHandle);
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
Exception e = new Exception("!!! Window new surface handle "+Thread.currentThread().getName()+
- ",HDC 0x"+Long.toHexString(hdc)+", HMON 0x"+Long.toHexString(hmon));
+ ", HWND 0x"+Long.toHexString(windowHandle)+", HDC 0x"+Long.toHexString(hdc)+", HMON 0x"+Long.toHexString(hmon));
e.printStackTrace();
}
}
@@ -105,6 +105,11 @@ public class WindowsWindow extends Window {
throw new NativeWindowException("Error creating window");
}
windowHandleClose = windowHandle;
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ Exception e = new Exception("!!! Window new window handle "+Thread.currentThread().getName()+
+ ", HWND 0x"+Long.toHexString(windowHandle));
+ e.printStackTrace();
+ }
}
protected void closeNative() {