diff options
Diffstat (limited to 'src/net/java/games/jogl/impl/x11')
4 files changed, 46 insertions, 25 deletions
diff --git a/src/net/java/games/jogl/impl/x11/X11GLContext.java b/src/net/java/games/jogl/impl/x11/X11GLContext.java index 451997a73..112f8a709 100644 --- a/src/net/java/games/jogl/impl/x11/X11GLContext.java +++ b/src/net/java/games/jogl/impl/x11/X11GLContext.java @@ -39,7 +39,7 @@ package net.java.games.jogl.impl.x11; -import java.awt.Component; +import java.nio.*; import java.util.*; import net.java.games.jogl.*; import net.java.games.jogl.impl.*; @@ -50,9 +50,10 @@ public abstract class X11GLContext extends GLContextImpl { private boolean glXQueryExtensionsStringInitialized; private boolean glXQueryExtensionsStringAvailable; private static final Map/*<String, String>*/ functionNameMap; + private GLXExt glXExt; // Table that holds the addresses of the native C-language entry points for - // OpenGL functions. - private GLProcAddressTable glProcAddressTable; + // GLX extension functions. + private GLXExtProcAddressTable glXExtProcAddressTable; // Cache the most recent value of the "display" variable (which we // only guarantee to be valid in between makeCurrent / free pairs) // so that we can implement displayImpl() (which must be done when @@ -71,11 +72,17 @@ public abstract class X11GLContext extends GLContextImpl { this.drawable = drawable; } - protected GL createGL() - { - return new X11GLImpl(this); + public Object getPlatformGLExtensions() { + return getGLXExt(); } - + + public GLXExt getGLXExt() { + if (glXExt == null) { + glXExt = new GLXExtImpl(this); + } + return glXExt; + } + public GLDrawable getGLDrawable() { return drawable; } @@ -175,20 +182,20 @@ public abstract class X11GLContext extends GLContextImpl { protected void resetGLFunctionAvailability() { super.resetGLFunctionAvailability(); if (DEBUG) { - System.err.println("!!! Initializing OpenGL extension address table"); + System.err.println(getThreadName() + ": !!! Initializing GLX extension address table"); } - resetProcAddressTable(getGLProcAddressTable()); + resetProcAddressTable(getGLXExtProcAddressTable()); } - public GLProcAddressTable getGLProcAddressTable() { - if (glProcAddressTable == null) { + public GLXExtProcAddressTable getGLXExtProcAddressTable() { + if (glXExtProcAddressTable == null) { // FIXME: cache ProcAddressTables by capability bits so we can // share them among contexts with the same capabilities - glProcAddressTable = new GLProcAddressTable(); + glXExtProcAddressTable = new GLXExtProcAddressTable(); } - return glProcAddressTable; + return glXExtProcAddressTable; } - + public synchronized String getPlatformExtensionsString() { if (drawable.getDisplay() == 0) { throw new GLException("Context not current"); @@ -238,6 +245,20 @@ public abstract class X11GLContext extends GLContextImpl { return super.isExtensionAvailable(glExtensionName); } + + public void setSwapInterval(int interval) { + // FIXME: make the context current first? Currently assumes that + // will not be necessary. Make the caller do this? + GLXExt glXExt = getGLXExt(); + if (glXExt.isExtensionAvailable("GLX_SGI_swap_control")) { + glXExt.glXSwapIntervalSGI(interval); + } + } + + public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { + return getGLXExt().glXAllocateMemoryNV(arg0, arg1, arg2, arg3); + } + public int getOffscreenContextPixelDataType() { throw new GLException("Should not call this"); } diff --git a/src/net/java/games/jogl/impl/x11/X11GLDrawableFactory.java b/src/net/java/games/jogl/impl/x11/X11GLDrawableFactory.java index 49db6230c..e2dcff91c 100755 --- a/src/net/java/games/jogl/impl/x11/X11GLDrawableFactory.java +++ b/src/net/java/games/jogl/impl/x11/X11GLDrawableFactory.java @@ -315,9 +315,9 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl { res[idx++] = GLX.GLX_ACCUM_BLUE_SIZE; res[idx++] = caps.getAccumBlueBits(); if (isMultisampleAvailable && caps.getSampleBuffers()) { - res[idx++] = GL.GLX_SAMPLE_BUFFERS_ARB; + res[idx++] = GLXExt.GLX_SAMPLE_BUFFERS_ARB; res[idx++] = GL.GL_TRUE; - res[idx++] = GL.GLX_SAMPLES_ARB; + res[idx++] = GLXExt.GLX_SAMPLES_ARB; res[idx++] = caps.getNumSamples(); } res[idx++] = 0; diff --git a/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java b/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java index 0d89c96df..1e651e3ec 100644 --- a/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java +++ b/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java @@ -137,7 +137,7 @@ public class X11PbufferGLContext extends X11GLContext { throw new GLException("GLContextShareSet returned an invalid OpenGL context"); } } - context = GLX.glXCreateNewContext(drawable.getDisplay(), drawable.getFBConfig(), GL.GLX_RGBA_TYPE, share, true); + context = GLX.glXCreateNewContext(drawable.getDisplay(), drawable.getFBConfig(), GLXExt.GLX_RGBA_TYPE, share, true); if (context == 0) { throw new GLException("pbuffer creation error: glXCreateNewContext() failed"); } diff --git a/src/net/java/games/jogl/impl/x11/X11PbufferGLDrawable.java b/src/net/java/games/jogl/impl/x11/X11PbufferGLDrawable.java index 8bbde41da..9294d3954 100644 --- a/src/net/java/games/jogl/impl/x11/X11PbufferGLDrawable.java +++ b/src/net/java/games/jogl/impl/x11/X11PbufferGLDrawable.java @@ -121,11 +121,11 @@ public class X11PbufferGLDrawable extends X11GLDrawable { // Since we are trying to create a pbuffer, the GLXFBConfig we // request (and subsequently use) must be "p-buffer capable". - iattributes[niattribs++] = GL.GLX_DRAWABLE_TYPE; - iattributes[niattribs++] = GL.GLX_PBUFFER_BIT; + iattributes[niattribs++] = GLXExt.GLX_DRAWABLE_TYPE; + iattributes[niattribs++] = GLXExt.GLX_PBUFFER_BIT; - iattributes[niattribs++] = GL.GLX_RENDER_TYPE; - iattributes[niattribs++] = GL.GLX_RGBA_BIT; + iattributes[niattribs++] = GLXExt.GLX_RENDER_TYPE; + iattributes[niattribs++] = GLXExt.GLX_RGBA_BIT; iattributes[niattribs++] = GLX.GLX_DOUBLEBUFFER; if (capabilities.getDoubleBuffered()) { @@ -212,9 +212,9 @@ public class X11PbufferGLDrawable extends X11GLDrawable { // Create the p-buffer. niattribs = 0; - iattributes[niattribs++] = GL.GLX_PBUFFER_WIDTH; + iattributes[niattribs++] = GLXExt.GLX_PBUFFER_WIDTH; iattributes[niattribs++] = initWidth; - iattributes[niattribs++] = GL.GLX_PBUFFER_HEIGHT; + iattributes[niattribs++] = GLXExt.GLX_PBUFFER_HEIGHT; iattributes[niattribs++] = initHeight; iattributes[niattribs++] = 0; @@ -232,9 +232,9 @@ public class X11PbufferGLDrawable extends X11GLDrawable { // Determine the actual width and height we were able to create. int[] tmp = new int[1]; - GLX.glXQueryDrawable(display, drawable, GL.GLX_WIDTH, tmp, 0); + GLX.glXQueryDrawable(display, drawable, GLXExt.GLX_WIDTH, tmp, 0); width = tmp[0]; - GLX.glXQueryDrawable(display, drawable, GL.GLX_HEIGHT, tmp, 0); + GLX.glXQueryDrawable(display, drawable, GLXExt.GLX_HEIGHT, tmp, 0); height = tmp[0]; if (DEBUG) { |