aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/impl/windows/WindowsPbufferGLDrawable.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-11-19 20:51:57 +0000
committerKenneth Russel <[email protected]>2006-11-19 20:51:57 +0000
commita303cd13ff62f94a0459978735620e37d72bbb77 (patch)
tree32b580af4e878d479890c12b8eae9c98e10a4874 /src/classes/com/sun/opengl/impl/windows/WindowsPbufferGLDrawable.java
parentbf82eceb6f78d5ee6e4c0f9f02590d2a58e647d3 (diff)
Fixed Issue 213: Expose GLCaps from GLDrawable
Added getChosenGLCapabilities() to the GLDrawable interface. Implemented on Windows, Unix and Mac OS X platforms with various techniques. Attempts to provide correct answers in all cases, even when the GLCapabilitiesChooser mechanism is not supported. Required addition of new platform-specific Java code in most cases to either re-convert existing PIXELFORMATDESCRIPTORS / XVisualInfos, or to query the pixel format or visual chosen for drawables like pbuffers for which the chooser mechanism is not (yet) implemented. Tested on Windows, Solaris/x86, and Mac OS X with on-screen, off-screen and pbuffer drawables. (Full support for the Java2D/JOGL bridge is not yet in place; the answer returned from the GLJPanel in this case is currently the default GLCapabilities, and it is likely that "external" GLDrawables will return null.) git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@989 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/impl/windows/WindowsPbufferGLDrawable.java')
-rw-r--r--src/classes/com/sun/opengl/impl/windows/WindowsPbufferGLDrawable.java43
1 files changed, 37 insertions, 6 deletions
diff --git a/src/classes/com/sun/opengl/impl/windows/WindowsPbufferGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/WindowsPbufferGLDrawable.java
index 0dddddddd..4f87eaecf 100644
--- a/src/classes/com/sun/opengl/impl/windows/WindowsPbufferGLDrawable.java
+++ b/src/classes/com/sun/opengl/impl/windows/WindowsPbufferGLDrawable.java
@@ -96,6 +96,7 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable {
throw new GLException("Error destroying pbuffer: error code " + WGL.GetLastError());
}
buffer = 0;
+ setChosenGLCapabilities(null);
}
}
@@ -198,8 +199,8 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable {
iattributes[3] = WGLExt.WGL_ALPHA_BITS_ARB;
iattributes[4] = WGLExt.WGL_DEPTH_BITS_ARB;
iattributes[5] = (useFloat ? (ati ? WGLExt.WGL_PIXEL_TYPE_ARB : WGLExt.WGL_FLOAT_COMPONENTS_NV) : WGLExt.WGL_RED_BITS_ARB);
- iattributes[6] = WGLExt.WGL_SAMPLE_BUFFERS_EXT;
- iattributes[7] = WGLExt.WGL_SAMPLES_EXT;
+ iattributes[6] = WGLExt.WGL_SAMPLE_BUFFERS_ARB;
+ iattributes[7] = WGLExt.WGL_SAMPLES_ARB;
iattributes[8] = WGLExt.WGL_DRAW_TO_PBUFFER_ARB;
int[] ivalues = new int[9];
for (int i = 0; i < nformats; i++) {
@@ -237,9 +238,9 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable {
}
long tmpBuffer = 0;
- int whichFormat = 0;
+ int whichFormat = -1;
// Loop is a workaround for bugs in NVidia's recent drivers
- do {
+ for (whichFormat = 0; whichFormat < nformats; whichFormat++) {
int format = pformats[whichFormat];
// Create the p-buffer.
@@ -266,8 +267,11 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable {
iattributes[niattribs++] = 0;
tmpBuffer = wglExt.wglCreatePbufferARB(parentHdc, format, initWidth, initHeight, iattributes, 0);
- ++whichFormat;
- } while ((tmpBuffer == 0) && (whichFormat < nformats));
+ if (tmpBuffer != 0) {
+ // Done
+ break;
+ }
+ }
if (tmpBuffer == 0) {
throw new GLException("pbuffer creation error: wglCreatePbufferARB() failed: tried " + nformats +
@@ -285,6 +289,33 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable {
hdc = tmpHdc;
cachedWGLExt = wglExt;
+ // Re-query chosen pixel format
+ {
+ niattribs = 0;
+ iattributes[niattribs++] = WGLExt.WGL_ACCELERATION_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_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_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;
+ iattributes[niattribs++] = (useFloat ? (ati ? WGLExt.WGL_PIXEL_TYPE_ARB : WGLExt.WGL_FLOAT_COMPONENTS_NV) : WGLExt.WGL_RED_BITS_ARB);
+ iattributes[niattribs++] = WGLExt.WGL_SAMPLE_BUFFERS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_SAMPLES_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_PBUFFER_ARB;
+ int[] ivalues = new int[niattribs];
+ // FIXME: usually prefer to throw exceptions, but failure here is not critical
+ if (wglExt.wglGetPixelFormatAttribivARB(parentHdc, pformats[whichFormat], 0, niattribs, iattributes, 0, ivalues, 0)) {
+ setChosenGLCapabilities(iattributes2GLCapabilities(iattributes, niattribs, ivalues, false));
+ }
+ }
+
// Determine the actual width and height we were able to create.
int[] tmp = new int[1];
wglExt.wglQueryPbufferARB( buffer, WGLExt.WGL_PBUFFER_WIDTH_ARB, tmp, 0 );