aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/cgl-macosx.cfg2
-rw-r--r--make/gl-common.cfg10
-rw-r--r--make/gl-impl-macosx.cfg4
-rw-r--r--make/gl-impl-win32.cfg6
-rw-r--r--make/gl-impl-x11.cfg6
-rw-r--r--make/stub_includes/macosx/window-system.c2
-rw-r--r--src/native/jogl/MacOSXWindowSystemInterface.m6
-rw-r--r--src/net/java/games/jogl/impl/GLContext.java7
-rw-r--r--src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java7
-rw-r--r--src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java7
10 files changed, 57 insertions, 0 deletions
diff --git a/make/cgl-macosx.cfg b/make/cgl-macosx.cfg
index c7a7f3841..dab1ec206 100644
--- a/make/cgl-macosx.cfg
+++ b/make/cgl-macosx.cfg
@@ -45,6 +45,8 @@ CustomCCode extern void setContextTextureImageToPBuffer(void* nsContext, void* p
CustomCCode extern void* getProcAddress(const char *procName);
+CustomCCode extern void setSwapInterval(void* nsContext, int interval);
+
# Implement the first argument to getProcAddress as String instead
# of byte[]
ArgumentIsString getProcAddress 0
diff --git a/make/gl-common.cfg b/make/gl-common.cfg
index 703715979..20bcaebe0 100644
--- a/make/gl-common.cfg
+++ b/make/gl-common.cfg
@@ -332,6 +332,16 @@ CustomJavaCode GL * {@link GLX#glXAllocateMemoryNV} extension.
CustomJavaCode GL */
CustomJavaCode GL public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3);
+CustomJavaCode GL /** Provides a platform-independent way to specify the minimum swap
+CustomJavaCode GL interval for buffer swaps. An argument of 0 disables
+CustomJavaCode GL sync-to-vertical-refresh completely, while an argument of 1
+CustomJavaCode GL causes the application to wait until the next vertical refresh
+CustomJavaCode GL until swapping buffers. The default, which is platform-specific,
+CustomJavaCode GL is usually either 0 or 1. This function is not guaranteed to
+CustomJavaCode GL have an effect, and in particular only affects heavyweight
+CustomJavaCode GL onscreen components. */
+CustomJavaCode GL public void setSwapInterval(int interval);
+
#
# Directives needed when processing wglext.h on Windows and other platforms
#
diff --git a/make/gl-impl-macosx.cfg b/make/gl-impl-macosx.cfg
index 8ce128851..5a09750dd 100644
--- a/make/gl-impl-macosx.cfg
+++ b/make/gl-impl-macosx.cfg
@@ -73,5 +73,9 @@ CustomJavaCode MacOSXGLImpl // FIXME
CustomJavaCode MacOSXGLImpl throw new GLException("Not yet implemented");
CustomJavaCode MacOSXGLImpl }
+CustomJavaCode MacOSXGLImpl public void setSwapInterval(int interval) { // FIXME: not implemented yet
+CustomJavaCode MacOSXGLImpl _context.setSwapInterval(interval);
+CustomJavaCode MacOSXGLImpl }
+
IncludeAs CustomJavaCode MacOSXGLImpl gl-impl-CustomJavaCode.java
IncludeAs CustomCCode gl-impl-CustomCCode.c
diff --git a/make/gl-impl-win32.cfg b/make/gl-impl-win32.cfg
index bf4f93998..252425659 100644
--- a/make/gl-impl-win32.cfg
+++ b/make/gl-impl-win32.cfg
@@ -60,5 +60,11 @@ CustomJavaCode WindowsGLImpl public java.nio.ByteBuffer glAllocateMemoryNV(int
CustomJavaCode WindowsGLImpl return wglAllocateMemoryNV(arg0, arg1, arg2, arg3);
CustomJavaCode WindowsGLImpl }
+CustomJavaCode WindowsGLImpl public void setSwapInterval(int interval) {
+CustomJavaCode WindowsGLImpl if (isExtensionAvailable("WGL_EXT_swap_control")) {
+CustomJavaCode WindowsGLImpl wglSwapIntervalEXT(interval);
+CustomJavaCode WindowsGLImpl }
+CustomJavaCode WindowsGLImpl }
+
IncludeAs CustomJavaCode WindowsGLImpl gl-impl-CustomJavaCode.java
IncludeAs CustomCCode gl-impl-CustomCCode.c
diff --git a/make/gl-impl-x11.cfg b/make/gl-impl-x11.cfg
index 33527d351..b60a28787 100644
--- a/make/gl-impl-x11.cfg
+++ b/make/gl-impl-x11.cfg
@@ -57,5 +57,11 @@ CustomJavaCode X11GLImpl public java.nio.ByteBuffer glAllocateMemoryNV(int arg
CustomJavaCode X11GLImpl return glXAllocateMemoryNV(arg0, arg1, arg2, arg3);
CustomJavaCode X11GLImpl }
+CustomJavaCode X11GLImpl public void setSwapInterval(int interval) {
+CustomJavaCode X11GLImpl if (isExtensionAvailable("GLX_SGI_swap_control")) {
+CustomJavaCode X11GLImpl glXSwapIntervalSGI(interval);
+CustomJavaCode X11GLImpl }
+CustomJavaCode X11GLImpl }
+
IncludeAs CustomJavaCode X11GLImpl gl-impl-CustomJavaCode.java
IncludeAs CustomCCode gl-impl-CustomCCode.c
diff --git a/make/stub_includes/macosx/window-system.c b/make/stub_includes/macosx/window-system.c
index e5ba4307f..b30c252f3 100644
--- a/make/stub_includes/macosx/window-system.c
+++ b/make/stub_includes/macosx/window-system.c
@@ -32,3 +32,5 @@ void setContextPBuffer(void* nsContext, void* pBuffer);
void setContextTextureImageToPBuffer(void* nsContext, void* pBuffer, int colorBuffer);
void* getProcAddress(const char *procName);
+
+void setSwapInterval(void* nsContext, int interval);
diff --git a/src/native/jogl/MacOSXWindowSystemInterface.m b/src/native/jogl/MacOSXWindowSystemInterface.m
index afa0fea69..6a5969fff 100644
--- a/src/native/jogl/MacOSXWindowSystemInterface.m
+++ b/src/native/jogl/MacOSXWindowSystemInterface.m
@@ -235,3 +235,9 @@ void* getProcAddress(const char *procname)
return NULL;
}
+
+void setSwapInterval(void* context, int interval) {
+ NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
+ long swapInterval = interval;
+ [nsContext setValues: &swapInterval forParameter: NSOpenGLCPSwapInterval];
+}
diff --git a/src/net/java/games/jogl/impl/GLContext.java b/src/net/java/games/jogl/impl/GLContext.java
index 17667fbce..318ff24a2 100644
--- a/src/net/java/games/jogl/impl/GLContext.java
+++ b/src/net/java/games/jogl/impl/GLContext.java
@@ -552,6 +552,13 @@ public abstract class GLContext {
*/
public abstract void releasePbufferFromTexture();
+ /*
+ * Sets the swap interval for onscreen OpenGL contexts. Has no
+ * effect for offscreen contexts.
+ */
+ public void setSwapInterval(final int interval) {
+ }
+
/** Maps the given "platform-independent" function name to a real function
name. Currently this is only used to map "glAllocateMemoryNV" and
associated routines to wglAllocateMemoryNV / glXAllocateMemoryNV. */
diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java
index 3c8027e7c..cfa5c3d99 100644
--- a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java
+++ b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java
@@ -227,6 +227,13 @@ public abstract class MacOSXGLContext extends GLContext
return "";
}
+ public void setSwapInterval(int interval) {
+ if (nsContext == 0) {
+ throw new GLException("OpenGL context not current");
+ }
+ CGL.setSwapInterval(nsContext, interval);
+ }
+
//----------------------------------------------------------------------
// Internals only below this point
//
diff --git a/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java b/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java
index 1b5f54979..241a45dc9 100644
--- a/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java
+++ b/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java
@@ -103,6 +103,13 @@ public class X11OnscreenGLContext extends X11GLContext {
throw new GLException("Should not call this");
}
+ public void setSwapInterval(int interval) {
+ GL gl = getGL();
+ if (gl.isExtensionAvailable("GLX_SGI_swap_control")) {
+ gl.glXSwapIntervalSGI(interval);
+ }
+ }
+
protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
try {
if (!lockSurface()) {