diff options
Diffstat (limited to 'src/classes/com/sun/opengl/impl/x11')
-rw-r--r-- | src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java | 53 | ||||
-rw-r--r-- | src/classes/com/sun/opengl/impl/x11/X11PbufferGLDrawable.java | 72 |
2 files changed, 46 insertions, 79 deletions
diff --git a/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java b/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java index 48953739f..5bdc367e6 100644 --- a/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java @@ -105,7 +105,7 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl { // in pure Java, we're going to provide the underlying window // system's selection to the chooser as a hint - int[] attribs = glCapabilities2AttribList(capabilities, isMultisampleAvailable()); + int[] attribs = glCapabilities2AttribList(capabilities, isMultisampleAvailable(), false, 0, 0); XVisualInfo[] infos = null; GLCapabilities[] caps = null; int recommendedIndex = -1; @@ -309,7 +309,10 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl { } public static int[] glCapabilities2AttribList(GLCapabilities caps, - boolean isMultisampleAvailable) { + boolean isMultisampleAvailable, + boolean pbuffer, + long display, + int screen) { int colorDepth = (caps.getRedBits() + caps.getGreenBits() + caps.getBlueBits()); @@ -318,7 +321,15 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl { } int[] res = new int[MAX_ATTRIBS]; int idx = 0; - res[idx++] = GLX.GLX_RGBA; + if (pbuffer) { + res[idx++] = GLXExt.GLX_DRAWABLE_TYPE; + res[idx++] = GLXExt.GLX_PBUFFER_BIT; + + res[idx++] = GLXExt.GLX_RENDER_TYPE; + res[idx++] = GLXExt.GLX_RGBA_BIT; + } else { + res[idx++] = GLX.GLX_RGBA; + } if (caps.getDoubleBuffered()) { res[idx++] = GLX.GLX_DOUBLEBUFFER; } @@ -335,20 +346,40 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl { res[idx++] = caps.getAlphaBits(); res[idx++] = GLX.GLX_DEPTH_SIZE; res[idx++] = caps.getDepthBits(); - res[idx++] = GLX.GLX_STENCIL_SIZE; - res[idx++] = caps.getStencilBits(); - res[idx++] = GLX.GLX_ACCUM_RED_SIZE; - res[idx++] = caps.getAccumRedBits(); - res[idx++] = GLX.GLX_ACCUM_GREEN_SIZE; - res[idx++] = caps.getAccumGreenBits(); - res[idx++] = GLX.GLX_ACCUM_BLUE_SIZE; - res[idx++] = caps.getAccumBlueBits(); + if (caps.getStencilBits() > 0) { + res[idx++] = GLX.GLX_STENCIL_SIZE; + res[idx++] = caps.getStencilBits(); + } + if (caps.getAccumRedBits() > 0 || + caps.getAccumGreenBits() > 0 || + caps.getAccumBlueBits() > 0 || + caps.getAccumAlphaBits() > 0) { + res[idx++] = GLX.GLX_ACCUM_RED_SIZE; + res[idx++] = caps.getAccumRedBits(); + res[idx++] = GLX.GLX_ACCUM_GREEN_SIZE; + res[idx++] = caps.getAccumGreenBits(); + res[idx++] = GLX.GLX_ACCUM_BLUE_SIZE; + res[idx++] = caps.getAccumBlueBits(); + res[idx++] = GLX.GLX_ACCUM_ALPHA_SIZE; + res[idx++] = caps.getAccumAlphaBits(); + } if (isMultisampleAvailable && caps.getSampleBuffers()) { res[idx++] = GLXExt.GLX_SAMPLE_BUFFERS_ARB; res[idx++] = GL.GL_TRUE; res[idx++] = GLXExt.GLX_SAMPLES_ARB; res[idx++] = caps.getNumSamples(); } + if (pbuffer) { + if (caps.getOffscreenFloatingPointBuffers()) { + String glXExtensions = GLX.glXQueryExtensionsString(display, screen); + if (glXExtensions == null || + glXExtensions.indexOf("GLX_NV_float_buffer") < 0) { + throw new GLException("Floating-point pbuffers on X11 currently require NVidia hardware"); + } + res[idx++] = GLX.GLX_FLOAT_COMPONENTS_NV; + res[idx++] = GL.GL_TRUE; + } + } res[idx++] = 0; return res; } diff --git a/src/classes/com/sun/opengl/impl/x11/X11PbufferGLDrawable.java b/src/classes/com/sun/opengl/impl/x11/X11PbufferGLDrawable.java index eddc5c14d..7ea10055c 100644 --- a/src/classes/com/sun/opengl/impl/x11/X11PbufferGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/X11PbufferGLDrawable.java @@ -114,74 +114,10 @@ public class X11PbufferGLDrawable extends X11GLDrawable { throw new GLException("Render-to-texture-rectangle pbuffers not supported yet on X11"); } - int[] iattributes = new int [2*MAX_ATTRIBS]; - float[] fattributes = new float[2*MAX_ATTRIBS]; - int nfattribs = 0; - int niattribs = 0; - - // Since we are trying to create a pbuffer, the GLXFBConfig we - // request (and subsequently use) must be "p-buffer capable". - iattributes[niattribs++] = GLXExt.GLX_DRAWABLE_TYPE; - iattributes[niattribs++] = GLXExt.GLX_PBUFFER_BIT; - - iattributes[niattribs++] = GLXExt.GLX_RENDER_TYPE; - iattributes[niattribs++] = GLXExt.GLX_RGBA_BIT; - - iattributes[niattribs++] = GLX.GLX_DOUBLEBUFFER; - if (capabilities.getDoubleBuffered()) { - iattributes[niattribs++] = GL.GL_TRUE; - } else { - iattributes[niattribs++] = GL.GL_FALSE; - } - - iattributes[niattribs++] = GLX.GLX_DEPTH_SIZE; - iattributes[niattribs++] = capabilities.getDepthBits(); - - iattributes[niattribs++] = GLX.GLX_RED_SIZE; - iattributes[niattribs++] = capabilities.getRedBits(); - - iattributes[niattribs++] = GLX.GLX_GREEN_SIZE; - iattributes[niattribs++] = capabilities.getGreenBits(); - - iattributes[niattribs++] = GLX.GLX_BLUE_SIZE; - iattributes[niattribs++] = capabilities.getBlueBits(); - - iattributes[niattribs++] = GLX.GLX_ALPHA_SIZE; - iattributes[niattribs++] = capabilities.getAlphaBits(); - - if (capabilities.getStencilBits() > 0) { - iattributes[niattribs++] = GLX.GLX_STENCIL_SIZE; - iattributes[niattribs++] = capabilities.getStencilBits(); - } - - if (capabilities.getAccumRedBits() > 0 || - capabilities.getAccumGreenBits() > 0 || - capabilities.getAccumBlueBits() > 0) { - iattributes[niattribs++] = GLX.GLX_ACCUM_RED_SIZE; - iattributes[niattribs++] = capabilities.getAccumRedBits(); - iattributes[niattribs++] = GLX.GLX_ACCUM_GREEN_SIZE; - iattributes[niattribs++] = capabilities.getAccumGreenBits(); - iattributes[niattribs++] = GLX.GLX_ACCUM_BLUE_SIZE; - iattributes[niattribs++] = capabilities.getAccumBlueBits(); - } - int screen = 0; // FIXME: provide way to specify this? - - if (capabilities.getOffscreenFloatingPointBuffers()) { - String glXExtensions = GLX.glXQueryExtensionsString(display, screen); - if (glXExtensions == null || - glXExtensions.indexOf("GLX_NV_float_buffer") < 0) { - throw new GLException("Floating-point pbuffers on X11 currently require NVidia hardware"); - } - iattributes[niattribs++] = GLX.GLX_FLOAT_COMPONENTS_NV; - iattributes[niattribs++] = GL.GL_TRUE; - } - - // FIXME: add FSAA support? Don't want to get into a situation - // where we have to retry the glXChooseFBConfig call if it fails - // due to a lack of an antialiased visual... - - iattributes[niattribs++] = 0; // null-terminate + int[] iattributes = X11GLDrawableFactory.glCapabilities2AttribList(capabilities, + X11GLDrawableFactory.isMultisampleAvailable(), + true, display, screen); int[] nelementsTmp = new int[1]; GLXFBConfig[] fbConfigs = GLX.glXChooseFBConfig(display, screen, iattributes, 0, nelementsTmp, 0); @@ -210,7 +146,7 @@ public class X11PbufferGLDrawable extends X11GLDrawable { } // Create the p-buffer. - niattribs = 0; + int niattribs = 0; iattributes[niattribs++] = GLXExt.GLX_PBUFFER_WIDTH; iattributes[niattribs++] = initWidth; |