diff options
author | Kenneth Russel <[email protected]> | 2005-07-27 00:30:06 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-07-27 00:30:06 +0000 |
commit | 7c1f2cde56438a979ddaab5fecc09f663427be91 (patch) | |
tree | 65098e75762b3e0f6a7b1a484792f9a48ca3b247 /src/net/java/games | |
parent | ebd2c94e33c643ad6102e76f22d1624e9b986737 (diff) |
Refactored platform extensions out of the GL interface and
implementation and into their own objects according to the JSR-231
expert group's resolutions. Moved the interfaces declaring these
extensions into the platform-specific implementation directories and
added a loosely-specified GL.getPlatformGLExtensions(). This will
shrink the size of the platform-independent jar file considerably as
the implementing class for the public GL interface is now no longer
replicated for each platform. The build process is also simplified a
fair bit; more simplifications are possible.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@337 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games')
14 files changed, 274 insertions, 203 deletions
diff --git a/src/net/java/games/gluegen/opengl/GLEmitter.java b/src/net/java/games/gluegen/opengl/GLEmitter.java index b0c88e954..b3581bd73 100644 --- a/src/net/java/games/gluegen/opengl/GLEmitter.java +++ b/src/net/java/games/gluegen/opengl/GLEmitter.java @@ -365,7 +365,6 @@ public class GLEmitter extends JavaEmitter private Set/*<String>*/ skipProcAddressGen = new HashSet(); private List/*<String>*/ forceProcAddressGen = new ArrayList(); private String contextVariableName = "context"; - private String defaultGetProcAddressTableExpr = ".getGLProcAddressTable()"; private String getProcAddressTableExpr; // The following data members support ignoring an entire extension at a time private List/*<String>*/ glHeaders = new ArrayList(); @@ -438,7 +437,7 @@ public class GLEmitter extends JavaEmitter public String contextVariableName() { return contextVariableName; } public String getProcAddressTableExpr() { if (getProcAddressTableExpr == null) { - getProcAddressTableExpr = contextVariableName + defaultGetProcAddressTableExpr; + getProcAddressTableExpr = contextVariableName + ".get" + tableClassName + "()"; } return getProcAddressTableExpr; } diff --git a/src/net/java/games/jogl/impl/GLContextImpl.java b/src/net/java/games/jogl/impl/GLContextImpl.java index 8e29633c7..1729cbbd2 100755 --- a/src/net/java/games/jogl/impl/GLContextImpl.java +++ b/src/net/java/games/jogl/impl/GLContextImpl.java @@ -40,6 +40,7 @@ package net.java.games.jogl.impl; import java.awt.Component; +import java.nio.*; import net.java.games.jogl.*; import net.java.games.gluegen.runtime.*; @@ -53,6 +54,9 @@ public abstract class GLContextImpl extends GLContext { // Cache of the functions that are available to be called at the current // moment in time protected FunctionAvailabilityCache functionAvailability; + // Table that holds the addresses of the native C-language entry points for + // OpenGL functions. + private GLProcAddressTable glProcAddressTable; protected GL gl; protected GLU glu = new GLUImpl(gluProcAddressTable); @@ -137,12 +141,25 @@ public abstract class GLContextImpl extends GLContext { this.glu = glu; } + public abstract Object getPlatformGLExtensions(); + //---------------------------------------------------------------------- // Helpers for various context implementations // /** Create the GL for this context. */ - protected abstract GL createGL(); + protected GL createGL() { + return new GLImpl(this); + } + + public GLProcAddressTable getGLProcAddressTable() { + if (glProcAddressTable == null) { + // FIXME: cache ProcAddressTables by capability bits so we can + // share them among contexts with the same capabilities + glProcAddressTable = new GLProcAddressTable(); + } + return glProcAddressTable; + } /** * Pbuffer support; given that this is a GLContext associated with a @@ -156,6 +173,8 @@ public abstract class GLContextImpl extends GLContext { */ public abstract void releasePbufferFromTexture(); + public abstract ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3); + /* * Sets the swap interval for onscreen OpenGL contexts. Has no * effect for offscreen contexts. @@ -204,6 +223,10 @@ public abstract class GLContextImpl extends GLContext { setGL(createGL()); functionAvailability.flush(); + if (DEBUG) { + System.err.println(getThreadName() + ": !!! Initializing OpenGL extension address table"); + } + resetProcAddressTable(getGLProcAddressTable()); if (!haveResetGLUProcAddressTable) { if (DEBUG) { System.err.println(getThreadName() + ": !!! Initializing GLU extension address table"); diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXDummyGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXDummyGLContext.java index 1c48e1171..f8934c06a 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXDummyGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXDummyGLContext.java @@ -49,17 +49,10 @@ import net.java.games.jogl.impl.*; function lookup is supported in this configuration by having this object provide the FunctionAvailabilityTable. */ -class MacOSXDummyGLContext extends MacOSXGLContext +public class MacOSXDummyGLContext extends MacOSXGLContext { - private MacOSXGLImpl gl; - - MacOSXDummyGLContext(MacOSXGLImpl gl) { + public MacOSXDummyGLContext() { super(null, null); - this.gl = gl; - } - - protected GL createGL() { - return gl; } public int getOffscreenContextReadBuffer() { diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java index bd1253cc4..3028304d5 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java @@ -39,7 +39,7 @@ package net.java.games.jogl.impl.macosx; -import java.awt.Component; +import java.nio.*; import java.util.*; import net.java.games.jogl.*; import net.java.games.jogl.impl.*; @@ -48,9 +48,10 @@ public abstract class MacOSXGLContext extends GLContextImpl { protected MacOSXGLDrawable drawable; protected long nsContext; // NSOpenGLContext + private CGLExt cglExt; // Table that holds the addresses of the native C-language entry points for - // OpenGL functions. - private GLProcAddressTable glProcAddressTable; + // CGL extension functions. + private CGLExtProcAddressTable cglExtProcAddressTable; public MacOSXGLContext(MacOSXGLDrawable drawable, GLContext shareWith) @@ -59,11 +60,17 @@ public abstract class MacOSXGLContext extends GLContextImpl this.drawable = drawable; } - protected GL createGL() - { - return new MacOSXGLImpl(this); + public Object getPlatformGLExtensions() { + return getCGLExt(); } - + + public CGLExt getCGLExt() { + if (cglExt == null) { + cglExt = new CGLExtImpl(this); + } + return cglExt; + } + public GLDrawable getGLDrawable() { return drawable; } @@ -180,21 +187,20 @@ public abstract class MacOSXGLContext extends GLContextImpl { super.resetGLFunctionAvailability(); if (DEBUG) { - System.err.println("!!! Initializing OpenGL extension address table"); + System.err.println("!!! Initializing CGL extension address table"); } - resetProcAddressTable(getGLProcAddressTable()); + resetProcAddressTable(getCGLProcAddressTable()); } - public GLProcAddressTable getGLProcAddressTable() - { - if (glProcAddressTable == null) { + public CGLExtProcAddressTable getCGLExtProcAddressTable() { + if (cglExtProcAddressTable == null) { // FIXME: cache ProcAddressTables by capability bits so we can // share them among contexts with the same capabilities - glProcAddressTable = new GLProcAddressTable(); + cglExtProcAddressTable = new CGLExtProcAddressTable(); } - return glProcAddressTable; + return cglExtProcAddressTable; } - + public String getPlatformExtensionsString() { return ""; @@ -207,6 +213,11 @@ public abstract class MacOSXGLContext extends GLContextImpl CGL.setSwapInterval(nsContext, interval); } + public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { + // FIXME: apparently the Apple extension doesn't require a custom memory allocator + throw new GLException("Not yet implemented"); + } + protected boolean isFunctionAvailable(String glFunctionName) { return super.isFunctionAvailable(glFunctionName); diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java index cfad7f3ac..ada57b500 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java @@ -39,6 +39,7 @@ package net.java.games.jogl.impl.windows; +import java.nio.*; import java.util.*; import net.java.games.jogl.*; import net.java.games.jogl.impl.*; @@ -50,9 +51,10 @@ public class WindowsGLContext extends GLContextImpl { private boolean wglGetExtensionsStringEXTAvailable; private static final Map/*<String, String>*/ functionNameMap; private static final Map/*<String, String>*/ extensionNameMap; + private WGLExt wglExt; // Table that holds the addresses of the native C-language entry points for - // OpenGL functions. - private GLProcAddressTable glProcAddressTable; + // WGL extension functions. + private WGLExtProcAddressTable wglExtProcAddressTable; static { functionNameMap = new HashMap(); @@ -70,11 +72,17 @@ public class WindowsGLContext extends GLContextImpl { this.drawable = drawable; } - protected GL createGL() - { - return new WindowsGLImpl(this); + public Object getPlatformGLExtensions() { + return getWGLExt(); } - + + public WGLExt getWGLExt() { + if (wglExt == null) { + wglExt = new WGLExtImpl(this); + } + return wglExt; + } + public GLDrawable getGLDrawable() { return drawable; } @@ -192,18 +200,18 @@ public class WindowsGLContext extends GLContextImpl { protected void resetGLFunctionAvailability() { super.resetGLFunctionAvailability(); if (DEBUG) { - System.err.println(getThreadName() + ": !!! Initializing OpenGL extension address table"); + System.err.println(getThreadName() + ": !!! Initializing WGL extension address table"); } - resetProcAddressTable(getGLProcAddressTable()); + resetProcAddressTable(getWGLExtProcAddressTable()); } - public GLProcAddressTable getGLProcAddressTable() { - if (glProcAddressTable == null) { + public WGLExtProcAddressTable getWGLExtProcAddressTable() { + if (wglExtProcAddressTable == null) { // FIXME: cache ProcAddressTables by capability bits so we can // share them among contexts with the same capabilities - glProcAddressTable = new GLProcAddressTable(); + wglExtProcAddressTable = new WGLExtProcAddressTable(); } - return glProcAddressTable; + return wglExtProcAddressTable; } public String getPlatformExtensionsString() { @@ -212,7 +220,7 @@ public class WindowsGLContext extends GLContextImpl { wglGetExtensionsStringEXTInitialized = true; } if (wglGetExtensionsStringEXTAvailable) { - return gl.wglGetExtensionsStringEXT(); + return getWGLExt().wglGetExtensionsStringEXT(); } else { return ""; } @@ -234,6 +242,19 @@ public class WindowsGLContext extends GLContextImpl { return available; } + public void setSwapInterval(int interval) { + // FIXME: make the context current first? Currently assumes that + // will not be necessary. Make the caller do this? + WGLExt wglExt = getWGLExt(); + if (wglExt.isExtensionAvailable("WGL_EXT_swap_control")) { + wglExt.wglSwapIntervalEXT(interval); + } + } + + public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { + return getWGLExt().wglAllocateMemoryNV(arg0, arg1, arg2, arg3); + } + public int getOffscreenContextPixelDataType() { throw new GLException("Should not call this"); } diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLDrawable.java b/src/net/java/games/jogl/impl/windows/WindowsGLDrawable.java index 840dd2183..5bbba75c1 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsGLDrawable.java +++ b/src/net/java/games/jogl/impl/windows/WindowsGLDrawable.java @@ -93,23 +93,23 @@ public abstract class WindowsGLDrawable extends GLDrawableImpl { // Produce a recommended pixel format selection for the GLCapabilitiesChooser. // Use wglChoosePixelFormatARB if user requested multisampling and if we have it available WindowsGLDrawable dummyDrawable = null; - GLContext dummyContext = null; - GL dummyGL = null; + GLContextImpl dummyContext = null; + WGLExt dummyWGLExt = null; if (capabilities.getSampleBuffers()) { dummyDrawable = new WindowsDummyGLDrawable(); - dummyContext = dummyDrawable.createContext(null); + dummyContext = (GLContextImpl) dummyDrawable.createContext(null); if (dummyContext != null) { dummyContext.makeCurrent(); - dummyGL = dummyContext.getGL(); + dummyWGLExt = (WGLExt) dummyContext.getPlatformGLExtensions(); } } int recommendedPixelFormat = -1; boolean haveWGLChoosePixelFormatARB = false; boolean haveWGLARBMultisample = false; boolean gotAvailableCaps = false; - if (dummyGL != null) { - haveWGLChoosePixelFormatARB = dummyGL.isExtensionAvailable("WGL_ARB_pixel_format"); - haveWGLARBMultisample = dummyGL.isExtensionAvailable("WGL_ARB_multisample"); + if (dummyWGLExt != null) { + haveWGLChoosePixelFormatARB = dummyWGLExt.isExtensionAvailable("WGL_ARB_pixel_format"); + haveWGLARBMultisample = dummyWGLExt.isExtensionAvailable("WGL_ARB_multisample"); try { if (haveWGLChoosePixelFormatARB) { @@ -118,71 +118,71 @@ public abstract class WindowsGLDrawable extends GLDrawableImpl { float[] fattributes = new float[2 * MAX_ATTRIBS]; int niattribs = 0; int nfattribs = 0; - iattributes[niattribs++] = GL.WGL_SUPPORT_OPENGL_ARB; + iattributes[niattribs++] = WGLExt.WGL_SUPPORT_OPENGL_ARB; iattributes[niattribs++] = GL.GL_TRUE; - iattributes[niattribs++] = GL.WGL_DRAW_TO_WINDOW_ARB; + iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_WINDOW_ARB; iattributes[niattribs++] = GL.GL_TRUE; - iattributes[niattribs++] = GL.WGL_PIXEL_TYPE_ARB; - iattributes[niattribs++] = GL.WGL_TYPE_RGBA_ARB; - iattributes[niattribs++] = GL.WGL_DOUBLE_BUFFER_ARB; + iattributes[niattribs++] = WGLExt.WGL_PIXEL_TYPE_ARB; + iattributes[niattribs++] = WGLExt.WGL_TYPE_RGBA_ARB; + iattributes[niattribs++] = WGLExt.WGL_DOUBLE_BUFFER_ARB; if (capabilities.getDoubleBuffered()) { iattributes[niattribs++] = GL.GL_TRUE; } else { iattributes[niattribs++] = GL.GL_FALSE; } - iattributes[niattribs++] = GL.WGL_STEREO_ARB; + iattributes[niattribs++] = WGLExt.WGL_STEREO_ARB; if (capabilities.getStereo()) { iattributes[niattribs++] = GL.GL_TRUE; } else { iattributes[niattribs++] = GL.GL_FALSE; } - iattributes[niattribs++] = GL.WGL_DEPTH_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_DEPTH_BITS_ARB; iattributes[niattribs++] = capabilities.getDepthBits(); - iattributes[niattribs++] = GL.WGL_RED_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_RED_BITS_ARB; iattributes[niattribs++] = capabilities.getRedBits(); - iattributes[niattribs++] = GL.WGL_GREEN_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_GREEN_BITS_ARB; iattributes[niattribs++] = capabilities.getGreenBits(); - iattributes[niattribs++] = GL.WGL_BLUE_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_BLUE_BITS_ARB; iattributes[niattribs++] = capabilities.getBlueBits(); - iattributes[niattribs++] = GL.WGL_ALPHA_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_ALPHA_BITS_ARB; iattributes[niattribs++] = capabilities.getAlphaBits(); - iattributes[niattribs++] = GL.WGL_STENCIL_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_STENCIL_BITS_ARB; iattributes[niattribs++] = capabilities.getStencilBits(); if (capabilities.getAccumRedBits() > 0 || capabilities.getAccumGreenBits() > 0 || capabilities.getAccumBlueBits() > 0 || capabilities.getAccumAlphaBits() > 0) { - iattributes[niattribs++] = GL.WGL_ACCUM_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_ACCUM_BITS_ARB; iattributes[niattribs++] = (capabilities.getAccumRedBits() + capabilities.getAccumGreenBits() + capabilities.getAccumBlueBits() + capabilities.getAccumAlphaBits()); - iattributes[niattribs++] = GL.WGL_ACCUM_RED_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_ACCUM_RED_BITS_ARB; iattributes[niattribs++] = capabilities.getAccumRedBits(); - iattributes[niattribs++] = GL.WGL_ACCUM_GREEN_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_ACCUM_GREEN_BITS_ARB; iattributes[niattribs++] = capabilities.getAccumGreenBits(); - iattributes[niattribs++] = GL.WGL_ACCUM_BLUE_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_ACCUM_BLUE_BITS_ARB; iattributes[niattribs++] = capabilities.getAccumBlueBits(); - iattributes[niattribs++] = GL.WGL_ACCUM_ALPHA_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_ACCUM_ALPHA_BITS_ARB; iattributes[niattribs++] = capabilities.getAccumAlphaBits(); } if (haveWGLARBMultisample) { if (capabilities.getSampleBuffers()) { - iattributes[niattribs++] = GL.WGL_SAMPLE_BUFFERS_ARB; + iattributes[niattribs++] = WGLExt.WGL_SAMPLE_BUFFERS_ARB; iattributes[niattribs++] = GL.GL_TRUE; - iattributes[niattribs++] = GL.WGL_SAMPLES_ARB; + iattributes[niattribs++] = WGLExt.WGL_SAMPLES_ARB; iattributes[niattribs++] = capabilities.getNumSamples(); } } int[] pformats = new int[MAX_PFORMATS]; int[] numFormatsTmp = new int[1]; - if (dummyGL.wglChoosePixelFormatARB(hdc, - iattributes, 0, - fattributes, 0, - MAX_PFORMATS, - pformats, 0, - numFormatsTmp, 0)) { + if (dummyWGLExt.wglChoosePixelFormatARB(hdc, + iattributes, 0, + fattributes, 0, + MAX_PFORMATS, + pformats, 0, + numFormatsTmp, 0)) { numFormats = numFormatsTmp[0]; if (numFormats > 0) { // Remove one-basing of pixel format (added on later) @@ -217,37 +217,37 @@ public abstract class WindowsGLDrawable extends GLDrawableImpl { // meaningless, and put in whether it can render to a // window, to a pbuffer, or to a pixmap) niattribs = 0; - iattributes[0] = GL.WGL_NUMBER_PIXEL_FORMATS_ARB; - if (dummyGL.wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, iattributes, 0, iresults, 0)) { + iattributes[0] = WGLExt.WGL_NUMBER_PIXEL_FORMATS_ARB; + if (dummyWGLExt.wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, iattributes, 0, iresults, 0)) { numFormats = iresults[0]; // 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++] = GL.WGL_DRAW_TO_WINDOW_ARB; - iattributes[niattribs++] = GL.WGL_ACCELERATION_ARB; - iattributes[niattribs++] = GL.WGL_SUPPORT_OPENGL_ARB; - iattributes[niattribs++] = GL.WGL_DEPTH_BITS_ARB; - iattributes[niattribs++] = GL.WGL_STENCIL_BITS_ARB; - iattributes[niattribs++] = GL.WGL_DOUBLE_BUFFER_ARB; - iattributes[niattribs++] = GL.WGL_STEREO_ARB; - iattributes[niattribs++] = GL.WGL_PIXEL_TYPE_ARB; - iattributes[niattribs++] = GL.WGL_RED_BITS_ARB; - iattributes[niattribs++] = GL.WGL_GREEN_BITS_ARB; - iattributes[niattribs++] = GL.WGL_BLUE_BITS_ARB; - iattributes[niattribs++] = GL.WGL_ALPHA_BITS_ARB; - iattributes[niattribs++] = GL.WGL_ACCUM_RED_BITS_ARB; - iattributes[niattribs++] = GL.WGL_ACCUM_GREEN_BITS_ARB; - iattributes[niattribs++] = GL.WGL_ACCUM_BLUE_BITS_ARB; - iattributes[niattribs++] = GL.WGL_ACCUM_ALPHA_BITS_ARB; + 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++] = GL.WGL_SAMPLE_BUFFERS_ARB; - iattributes[niattribs++] = GL.WGL_SAMPLES_ARB; + 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 (!dummyGL.wglGetPixelFormatAttribivARB(hdc, i+1, 0, niattribs, iattributes, 0, iresults, 0)) { + 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] = iattributes2GLCapabilities(iattributes, iresults, niattribs, true); @@ -403,78 +403,78 @@ public abstract class WindowsGLDrawable extends GLDrawableImpl { GLCapabilities res = new GLCapabilities(); for (int i = 0; i < niattribs; i++) { switch (iattribs[i]) { - case GL.WGL_DRAW_TO_WINDOW_ARB: + case WGLExt.WGL_DRAW_TO_WINDOW_ARB: if (iresults[i] != GL.GL_TRUE) return null; break; - case GL.WGL_ACCELERATION_ARB: - res.setHardwareAccelerated(iresults[i] == GL.WGL_FULL_ACCELERATION_ARB); + case WGLExt.WGL_ACCELERATION_ARB: + res.setHardwareAccelerated(iresults[i] == WGLExt.WGL_FULL_ACCELERATION_ARB); break; - case GL.WGL_SUPPORT_OPENGL_ARB: + case WGLExt.WGL_SUPPORT_OPENGL_ARB: if (iresults[i] != GL.GL_TRUE) return null; break; - case GL.WGL_DEPTH_BITS_ARB: + case WGLExt.WGL_DEPTH_BITS_ARB: res.setDepthBits(iresults[i]); break; - case GL.WGL_STENCIL_BITS_ARB: + case WGLExt.WGL_STENCIL_BITS_ARB: res.setStencilBits(iresults[i]); break; - case GL.WGL_DOUBLE_BUFFER_ARB: + case WGLExt.WGL_DOUBLE_BUFFER_ARB: res.setDoubleBuffered(iresults[i] == GL.GL_TRUE); break; - case GL.WGL_STEREO_ARB: + case WGLExt.WGL_STEREO_ARB: res.setStereo(iresults[i] == GL.GL_TRUE); break; - case GL.WGL_PIXEL_TYPE_ARB: - if (iresults[i] != GL.WGL_TYPE_RGBA_ARB) + case WGLExt.WGL_PIXEL_TYPE_ARB: + if (iresults[i] != WGLExt.WGL_TYPE_RGBA_ARB) return null; break; - case GL.WGL_RED_BITS_ARB: + case WGLExt.WGL_RED_BITS_ARB: res.setRedBits(iresults[i]); break; - case GL.WGL_GREEN_BITS_ARB: + case WGLExt.WGL_GREEN_BITS_ARB: res.setGreenBits(iresults[i]); break; - case GL.WGL_BLUE_BITS_ARB: + case WGLExt.WGL_BLUE_BITS_ARB: res.setBlueBits(iresults[i]); break; - case GL.WGL_ALPHA_BITS_ARB: + case WGLExt.WGL_ALPHA_BITS_ARB: res.setAlphaBits(iresults[i]); break; - case GL.WGL_ACCUM_RED_BITS_ARB: + case WGLExt.WGL_ACCUM_RED_BITS_ARB: res.setAccumRedBits(iresults[i]); break; - case GL.WGL_ACCUM_GREEN_BITS_ARB: + case WGLExt.WGL_ACCUM_GREEN_BITS_ARB: res.setAccumGreenBits(iresults[i]); break; - case GL.WGL_ACCUM_BLUE_BITS_ARB: + case WGLExt.WGL_ACCUM_BLUE_BITS_ARB: res.setAccumBlueBits(iresults[i]); break; - case GL.WGL_ACCUM_ALPHA_BITS_ARB: + case WGLExt.WGL_ACCUM_ALPHA_BITS_ARB: res.setAccumAlphaBits(iresults[i]); break; - case GL.WGL_SAMPLE_BUFFERS_ARB: + case WGLExt.WGL_SAMPLE_BUFFERS_ARB: res.setSampleBuffers(iresults[i] == GL.GL_TRUE); break; - case GL.WGL_SAMPLES_ARB: + case WGLExt.WGL_SAMPLES_ARB: res.setNumSamples(iresults[i]); break; diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLDrawableFactory.java b/src/net/java/games/jogl/impl/windows/WindowsGLDrawableFactory.java index b29bcf157..d3c176fa8 100755 --- a/src/net/java/games/jogl/impl/windows/WindowsGLDrawableFactory.java +++ b/src/net/java/games/jogl/impl/windows/WindowsGLDrawableFactory.java @@ -188,19 +188,19 @@ public class WindowsGLDrawableFactory extends GLDrawableFactoryImpl { Runnable r = new Runnable() { public void run() { WindowsDummyGLDrawable dummyDrawable = new WindowsDummyGLDrawable(); - GLContext dummyContext = dummyDrawable.createContext(null); + WindowsGLContext dummyContext = (WindowsGLContext) dummyDrawable.createContext(null); GLContext lastContext = GLContext.getCurrent(); if (lastContext != null) { lastContext.release(); } dummyContext.makeCurrent(); - GL dummyGL = dummyContext.getGL(); + WGLExt dummyWGLExt = dummyContext.getWGLExt(); try { WindowsPbufferGLDrawable pbufferDrawable = new WindowsPbufferGLDrawable(capabilities, initialWidth, initialHeight, dummyDrawable, - dummyGL); + dummyWGLExt); GLPbufferImpl pbuffer = new GLPbufferImpl(pbufferDrawable, shareWith); returnList.add(pbuffer); dummyContext.release(); diff --git a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLDrawable.java b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLDrawable.java index 50cf5c9f4..479e8586d 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLDrawable.java +++ b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLDrawable.java @@ -94,6 +94,8 @@ public class WindowsOnscreenGLDrawable extends WindowsGLDrawable { } public void swapBuffers() throws GLException { + // FIXME: currently must do this while the surface is locked + // (i.e., a context is current); fix and/or specify this? if (!WGL.SwapBuffers(hdc) && (WGL.GetLastError() != 0)) { throw new GLException("Error swapping buffers"); } diff --git a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java index c602cab99..d6c329d7a 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java @@ -65,9 +65,10 @@ public class WindowsPbufferGLContext extends WindowsGLContext { "specified in its GLCapabilities"); } GL gl = getGL(); + WGLExt wglExt = getWGLExt(); gl.glBindTexture(textureTarget, texture); if (rtt && hasRTT) { - if (!gl.wglBindTexImageARB(drawable.getPbuffer(), GL.WGL_FRONT_LEFT_ARB)) { + if (!wglExt.wglBindTexImageARB(drawable.getPbuffer(), WGLExt.WGL_FRONT_LEFT_ARB)) { throw new GLException("Binding of pbuffer to texture failed: " + wglGetLastError()); } } @@ -82,8 +83,8 @@ public class WindowsPbufferGLContext extends WindowsGLContext { "specified in its GLCapabilities"); } if (rtt && hasRTT) { - GL gl = getGL(); - if (!gl.wglReleaseTexImageARB(drawable.getPbuffer(), GL.WGL_FRONT_LEFT_ARB)) { + WGLExt wglExt = getWGLExt(); + if (!wglExt.wglReleaseTexImageARB(drawable.getPbuffer(), WGLExt.WGL_FRONT_LEFT_ARB)) { throw new GLException("Releasing of pbuffer from texture failed: " + wglGetLastError()); } } diff --git a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLDrawable.java b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLDrawable.java index b6099286a..3b98491a0 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLDrawable.java +++ b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLDrawable.java @@ -46,8 +46,8 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { private int initWidth; private int initHeight; - private GL cachedGL; // cached GL instance from parent GLCanvas, - // needed to destroy pbuffer + private WGLExt cachedWGLExt; // cached WGLExt instance from parent GLCanvas, + // needed to destroy pbuffer private long buffer; // pbuffer handle private int width; private int height; @@ -58,7 +58,7 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { int initialWidth, int initialHeight, WindowsGLDrawable dummyDrawable, - GL gl) { + WGLExt wglExt) { super(null, capabilities, null); this.initWidth = initialWidth; this.initHeight = initialHeight; @@ -74,7 +74,7 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { (capabilities.getOffscreenFloatingPointBuffers() ? " [float]" : "")); } - createPbuffer(dummyDrawable.getHDC(), gl); + createPbuffer(dummyDrawable.getHDC(), wglExt); } public GLContext createContext(GLContext shareWith) { @@ -87,12 +87,12 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { // NOTE that since the context is not current, glGetError() can // not be called here, so we skip the use of any composable // pipelines (see WindowsOnscreenGLContext.makeCurrentImpl) - GL gl = cachedGL; - if (gl.wglReleasePbufferDCARB(buffer, hdc) == 0) { + WGLExt wglExt = cachedWGLExt; + if (wglExt.wglReleasePbufferDCARB(buffer, hdc) == 0) { throw new GLException("Error releasing pbuffer device context: error code " + WGL.GetLastError()); } hdc = 0; - if (!gl.wglDestroyPbufferARB(buffer)) { + if (!wglExt.wglDestroyPbufferARB(buffer)) { throw new GLException("Error destroying pbuffer: error code " + WGL.GetLastError()); } buffer = 0; @@ -141,7 +141,7 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { */ } - private void createPbuffer(long parentHdc, GL gl) { + private void createPbuffer(long parentHdc, WGLExt wglExt) { int[] iattributes = new int [2*MAX_ATTRIBS]; float[] fattributes = new float[2*MAX_ATTRIBS]; int nfattribs = 0; @@ -162,7 +162,7 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { // Since we are trying to create a pbuffer, the pixel format we // request (and subsequently use) must be "p-buffer capable". - iattributes[niattribs++] = GL.WGL_DRAW_TO_PBUFFER_ARB; + iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_PBUFFER_ARB; iattributes[niattribs++] = GL.GL_TRUE; if (rtt && !rect) { @@ -170,19 +170,19 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { } if (rect) { - if (!gl.isExtensionAvailable("GL_NV_texture_rectangle")) { + if (!wglExt.isExtensionAvailable("GL_NV_texture_rectangle")) { throw new GLException("Render-to-texture-rectangle requires GL_NV_texture_rectangle extension"); } } if (useFloat) { - if (!gl.isExtensionAvailable("WGL_ATI_pixel_format_float") && - !gl.isExtensionAvailable("WGL_NV_float_buffer")) { + if (!wglExt.isExtensionAvailable("WGL_ATI_pixel_format_float") && + !wglExt.isExtensionAvailable("WGL_NV_float_buffer")) { throw new GLException("Floating-point pbuffers not supported by this hardware"); } // Prefer NVidia extension over ATI - if (gl.isExtensionAvailable("WGL_NV_float_buffer")) { + if (wglExt.isExtensionAvailable("WGL_NV_float_buffer")) { ati = false; floatMode = GLPbuffer.NV_FLOAT; } else { @@ -198,42 +198,42 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { if (rtt) { throw new GLException("Render-to-floating-point-texture not supported on ATI hardware"); } else { - iattributes[niattribs++] = GL.WGL_PIXEL_TYPE_ARB; - iattributes[niattribs++] = GL.WGL_TYPE_RGBA_FLOAT_ATI; + iattributes[niattribs++] = WGLExt.WGL_PIXEL_TYPE_ARB; + iattributes[niattribs++] = WGLExt.WGL_TYPE_RGBA_FLOAT_ATI; } } else { if (!rtt) { // Currently we don't support non-truecolor visuals in the // GLCapabilities, so we don't offer the option of making // color-index pbuffers. - iattributes[niattribs++] = GL.WGL_PIXEL_TYPE_ARB; - iattributes[niattribs++] = GL.WGL_TYPE_RGBA_ARB; + iattributes[niattribs++] = WGLExt.WGL_PIXEL_TYPE_ARB; + iattributes[niattribs++] = WGLExt.WGL_TYPE_RGBA_ARB; } } - iattributes[niattribs++] = GL.WGL_DOUBLE_BUFFER_ARB; + iattributes[niattribs++] = WGLExt.WGL_DOUBLE_BUFFER_ARB; if (capabilities.getDoubleBuffered()) { iattributes[niattribs++] = GL.GL_TRUE; } else { iattributes[niattribs++] = GL.GL_FALSE; } - iattributes[niattribs++] = GL.WGL_DEPTH_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_DEPTH_BITS_ARB; iattributes[niattribs++] = capabilities.getDepthBits(); - iattributes[niattribs++] = GL.WGL_RED_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_RED_BITS_ARB; iattributes[niattribs++] = capabilities.getRedBits(); - iattributes[niattribs++] = GL.WGL_GREEN_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_GREEN_BITS_ARB; iattributes[niattribs++] = capabilities.getGreenBits(); - iattributes[niattribs++] = GL.WGL_BLUE_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_BLUE_BITS_ARB; iattributes[niattribs++] = capabilities.getBlueBits(); - iattributes[niattribs++] = GL.WGL_ALPHA_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_ALPHA_BITS_ARB; iattributes[niattribs++] = capabilities.getAlphaBits(); - iattributes[niattribs++] = GL.WGL_STENCIL_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_STENCIL_BITS_ARB; if (capabilities.getStencilBits() > 0) { iattributes[niattribs++] = GL.GL_TRUE; } else { @@ -243,12 +243,12 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { if (capabilities.getAccumRedBits() > 0 || capabilities.getAccumGreenBits() > 0 || capabilities.getAccumBlueBits() > 0) { - iattributes[niattribs++] = GL.WGL_ACCUM_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_ACCUM_BITS_ARB; iattributes[niattribs++] = GL.GL_TRUE; } if (useFloat && !ati) { - iattributes[niattribs++] = GL.WGL_FLOAT_COMPONENTS_NV; + iattributes[niattribs++] = WGLExt.WGL_FLOAT_COMPONENTS_NV; iattributes[niattribs++] = GL.GL_TRUE; } @@ -258,26 +258,26 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { if (!rect) { throw new GLException("Render-to-floating-point-texture only supported on NVidia hardware with render-to-texture-rectangle"); } - iattributes[niattribs++] = GL.WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV; + iattributes[niattribs++] = WGLExt.WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV; iattributes[niattribs++] = GL.GL_TRUE; } else { - iattributes[niattribs++] = rect ? GL.WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV : GL.WGL_BIND_TO_TEXTURE_RGB_ARB; + iattributes[niattribs++] = rect ? WGLExt.WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV : WGLExt.WGL_BIND_TO_TEXTURE_RGB_ARB; iattributes[niattribs++] = GL.GL_TRUE; } } - iattributes[niattribs++] = GL.WGL_SUPPORT_OPENGL_ARB; + iattributes[niattribs++] = WGLExt.WGL_SUPPORT_OPENGL_ARB; iattributes[niattribs++] = GL.GL_TRUE; int[] pformats = new int[MAX_PFORMATS]; int nformats; int[] nformatsTmp = new int[1]; - if (!gl.wglChoosePixelFormatARB(parentHdc, - iattributes, 0, - fattributes, 0, - MAX_PFORMATS, - pformats, 0, - nformatsTmp, 0)) { + if (!wglExt.wglChoosePixelFormatARB(parentHdc, + iattributes, 0, + fattributes, 0, + MAX_PFORMATS, + pformats, 0, + nformatsTmp, 0)) { throw new GLException("pbuffer creation error: wglChoosePixelFormatARB() failed"); } nformats = nformatsTmp[0]; @@ -288,18 +288,18 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { if (DEBUG) { System.err.println("" + nformats + " suitable pixel formats found"); // query pixel format - iattributes[0] = GL.WGL_RED_BITS_ARB; - iattributes[1] = GL.WGL_GREEN_BITS_ARB; - iattributes[2] = GL.WGL_BLUE_BITS_ARB; - iattributes[3] = GL.WGL_ALPHA_BITS_ARB; - iattributes[4] = GL.WGL_DEPTH_BITS_ARB; - iattributes[5] = (useFloat ? (ati ? GL.WGL_PIXEL_TYPE_ARB : GL.WGL_FLOAT_COMPONENTS_NV) : GL.WGL_RED_BITS_ARB); - iattributes[6] = GL.WGL_SAMPLE_BUFFERS_EXT; - iattributes[7] = GL.WGL_SAMPLES_EXT; - iattributes[8] = GL.WGL_DRAW_TO_PBUFFER_ARB; + iattributes[0] = WGLExt.WGL_RED_BITS_ARB; + iattributes[1] = WGLExt.WGL_GREEN_BITS_ARB; + iattributes[2] = WGLExt.WGL_BLUE_BITS_ARB; + 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[8] = WGLExt.WGL_DRAW_TO_PBUFFER_ARB; int[] ivalues = new int[9]; for (int i = 0; i < nformats; i++) { - if (!gl.wglGetPixelFormatAttribivARB(parentHdc, pformats[i], 0, 9, iattributes, 0, ivalues, 0)) { + if (!wglExt.wglGetPixelFormatAttribivARB(parentHdc, pformats[i], 0, 9, iattributes, 0, ivalues, 0)) { throw new GLException("Error while querying pixel format " + pformats[i] + "'s (index " + i + "'s) capabilities for debugging"); } @@ -313,9 +313,9 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { System.err.print(" samples: " + ivalues[7]); if (useFloat) { if (ati) { - if (ivalues[5] == GL.WGL_TYPE_RGBA_FLOAT_ATI) { + if (ivalues[5] == WGLExt.WGL_TYPE_RGBA_FLOAT_ATI) { System.err.print(" [ati float]"); - } else if (ivalues[5] != GL.WGL_TYPE_RGBA_ARB) { + } else if (ivalues[5] != WGLExt.WGL_TYPE_RGBA_ARB) { System.err.print(" [unknown pixel type " + ivalues[5] + "]"); } } else { @@ -342,26 +342,26 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { niattribs = 0; if (rtt) { - iattributes[niattribs++] = GL.WGL_TEXTURE_FORMAT_ARB; + iattributes[niattribs++] = WGLExt.WGL_TEXTURE_FORMAT_ARB; if (useFloat) { - iattributes[niattribs++] = GL.WGL_TEXTURE_FLOAT_RGB_NV; + iattributes[niattribs++] = WGLExt.WGL_TEXTURE_FLOAT_RGB_NV; } else { - iattributes[niattribs++] = GL.WGL_TEXTURE_RGBA_ARB; + iattributes[niattribs++] = WGLExt.WGL_TEXTURE_RGBA_ARB; } - iattributes[niattribs++] = GL.WGL_TEXTURE_TARGET_ARB; - iattributes[niattribs++] = rect ? GL.WGL_TEXTURE_RECTANGLE_NV : GL.WGL_TEXTURE_2D_ARB; + iattributes[niattribs++] = WGLExt.WGL_TEXTURE_TARGET_ARB; + iattributes[niattribs++] = rect ? WGLExt.WGL_TEXTURE_RECTANGLE_NV : WGLExt.WGL_TEXTURE_2D_ARB; - iattributes[niattribs++] = GL.WGL_MIPMAP_TEXTURE_ARB; + iattributes[niattribs++] = WGLExt.WGL_MIPMAP_TEXTURE_ARB; iattributes[niattribs++] = GL.GL_FALSE; - iattributes[niattribs++] = GL.WGL_PBUFFER_LARGEST_ARB; + iattributes[niattribs++] = WGLExt.WGL_PBUFFER_LARGEST_ARB; iattributes[niattribs++] = GL.GL_FALSE; } iattributes[niattribs++] = 0; - tmpBuffer = gl.wglCreatePbufferARB(parentHdc, format, initWidth, initHeight, iattributes, 0); + tmpBuffer = wglExt.wglCreatePbufferARB(parentHdc, format, initWidth, initHeight, iattributes, 0); ++whichFormat; } while ((tmpBuffer == 0) && (whichFormat < nformats)); @@ -371,7 +371,7 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { } // Get the device context. - long tmpHdc = gl.wglGetPbufferDCARB(tmpBuffer); + long tmpHdc = wglExt.wglGetPbufferDCARB(tmpBuffer); if (tmpHdc == 0) { throw new GLException("pbuffer creation error: wglGetPbufferDCARB() failed"); } @@ -379,13 +379,13 @@ public class WindowsPbufferGLDrawable extends WindowsGLDrawable { // Set up instance variables buffer = tmpBuffer; hdc = tmpHdc; - cachedGL = gl; + cachedWGLExt = wglExt; // Determine the actual width and height we were able to create. int[] tmp = new int[1]; - gl.wglQueryPbufferARB( buffer, GL.WGL_PBUFFER_WIDTH_ARB, tmp, 0 ); + wglExt.wglQueryPbufferARB( buffer, WGLExt.WGL_PBUFFER_WIDTH_ARB, tmp, 0 ); width = tmp[0]; - gl.wglQueryPbufferARB( buffer, GL.WGL_PBUFFER_HEIGHT_ARB, tmp, 0 ); + wglExt.wglQueryPbufferARB( buffer, WGLExt.WGL_PBUFFER_HEIGHT_ARB, tmp, 0 ); height = tmp[0]; if (DEBUG) { 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) { |