aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/sun
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/sun')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java20
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java6
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java3
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java13
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java25
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java8
7 files changed, 44 insertions, 35 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
index c60cccec6..fa7e1ade7 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
@@ -284,11 +284,23 @@ public abstract class GLContextImpl extends GLContext {
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.
- */
public void setSwapInterval(final int interval) {
+ GLContext current = getCurrent();
+ if (current != this) {
+ throw new GLException("This context is not current. Current context: "+current+
+ ", this context "+this);
+ }
+ setSwapIntervalImpl(interval);
+ }
+
+ protected int currentSwapInterval = -1; // default: not set yet ..
+
+ public int getSwapInterval() {
+ return currentSwapInterval;
+ }
+
+ protected void setSwapIntervalImpl(final int interval) {
+ // nop per default ..
}
/** Maps the given "platform-independent" function name to a real function
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
index 45fe0fcd3..1a75f03a9 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
@@ -261,6 +261,12 @@ public abstract class EGLContext extends GLContextImpl {
}
}
+ protected void setSwapIntervalImpl(int interval) {
+ if (EGL.eglSwapInterval(drawable.getDisplay(), interval)) {
+ currentSwapInterval = interval ;
+ }
+ }
+
public abstract void bindPbufferToTexture();
public abstract void releasePbufferFromTexture();
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java
index b424e9516..f60dd1645 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java
@@ -337,11 +337,12 @@ public abstract class MacOSXCGLContext extends GLContextImpl
return "";
}
- public void setSwapInterval(int interval) {
+ protected void setSwapIntervalImpl(int interval) {
if (nsContext == 0) {
throw new GLException("OpenGL context not current");
}
CGL.setSwapInterval(nsContext, interval);
+ currentSwapInterval = interval ;
}
public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
index d702150d3..4ea3519bf 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
@@ -121,11 +121,12 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
}
}
- public void setSwapInterval(int interval) {
+ protected void setSwapIntervalImpl(int interval) {
if (nsContext == 0) {
throw new GLException("OpenGL context not current");
}
impl.setSwapInterval(nsContext, interval);
+ currentSwapInterval = impl.getSwapInterval() ;
}
public int getFloatingPointMode() {
@@ -210,6 +211,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
public boolean makeCurrent(long ctx);
public boolean release(long ctx);
public void setSwapInterval(long ctx, int interval);
+ public int getSwapInterval();
}
// NSOpenGLContext-based implementation
@@ -241,8 +243,14 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
return CGL.clearCurrentContext(ctx);
}
+ private int currentSwapInterval = 0 ;
+
public void setSwapInterval(long ctx, int interval) {
CGL.setSwapInterval(ctx, interval);
+ currentSwapInterval = interval ;
+ }
+ public int getSwapInterval() {
+ return currentSwapInterval;
}
}
@@ -344,5 +352,8 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
public void setSwapInterval(long ctx, int interval) {
// For now not supported (not really relevant for off-screen contexts anyway)
}
+ public int getSwapInterval() {
+ return 0;
+ }
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
index 4423f8da5..22b0ffe55 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
@@ -144,10 +144,6 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
}
}
- public void setSwapInterval(int interval) {
- // Not supported in this context implementation
- }
-
public void setOpenGLMode(int mode) {
if (mode != MacOSXCGLDrawable.CGL_MODE)
throw new GLException("OpenGL mode switching not supported for Java2D GLContexts");
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
index 1bc3acada..92a563445 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -332,29 +332,12 @@ public class WindowsWGLContext extends GLContextImpl {
}
}
- public boolean isFunctionAvailable(String glFunctionName)
- {
- boolean available = super.isFunctionAvailable(glFunctionName);
-
- // Sanity check for implementations that use proc addresses for run-time
- // linking: if the function IS available, then make sure there's a proc
- // address for it if it's an extension or not part of the OpenGL 1.1 core
- // (post GL 1.1 functions are run-time linked on windows).
- /* FIXME:
- assert(!available ||
- (getGLProcAddressTable().getAddressFor(mapToRealGLFunctionName(glFunctionName)) != 0 ||
- FunctionAvailabilityCache.isPartOfGLCore("1.1", mapToRealGLFunctionName(glFunctionName)))
- ); */
-
- 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?
+ protected void setSwapIntervalImpl(int interval) {
WGLExt wglExt = getWGLExt();
if (wglExt.isExtensionAvailable("WGL_EXT_swap_control")) {
- wglExt.wglSwapIntervalEXT(interval);
+ if ( wglExt.wglSwapIntervalEXT(interval) ) {
+ currentSwapInterval = interval ;
+ }
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
index 57abcf588..718d55aa0 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
@@ -396,11 +396,9 @@ public abstract class X11GLXContext extends GLContextImpl {
private int hasSwapIntervalSGI = 0;
- public void setSwapInterval(int interval) {
+ protected void setSwapIntervalImpl(int interval) {
getDrawableImpl().getFactoryImpl().lockToolkit();
try {
- // FIXME: make the context current first? Currently assumes that
- // will not be necessary. Make the caller do this?
GLXExt glXExt = getGLXExt();
if(0==hasSwapIntervalSGI) {
try {
@@ -409,7 +407,9 @@ public abstract class X11GLXContext extends GLContextImpl {
}
if (hasSwapIntervalSGI>0) {
try {
- glXExt.glXSwapIntervalSGI(interval);
+ if( 0 == glXExt.glXSwapIntervalSGI(interval) ) {
+ currentSwapInterval = interval;
+ }
} catch (Throwable t) { hasSwapIntervalSGI=-1; }
}
} finally {