From bafff33544dae0f28a0a7141d2a4ee05295ea2ec Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Sun, 24 Apr 2005 00:10:41 +0000 Subject: Fixed Issue 92: Platform Independent VSync functionality Added GL.setSwapInterval() which delegates to appropriate platform-dependent routines. Must be called only from within GLEventListener callbacks. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@260 232f8b59-042b-4e1e-8c03-345bb8c30851 --- src/net/java/games/jogl/impl/GLContext.java | 7 +++++++ src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java | 7 +++++++ src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java | 7 +++++++ 3 files changed, 21 insertions(+) (limited to 'src/net/java/games/jogl/impl') 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()) { -- cgit v1.2.3