Windows: Check for gl errors after setting swap interval

This commit is contained in:
Elias Naur 2007-05-27 05:19:19 +00:00
parent 59a3176ace
commit 42e75bb619
3 changed files with 9 additions and 10 deletions

View File

@ -57,7 +57,7 @@ public final class Sys {
private static final String VERSION = "1.1"; private static final String VERSION = "1.1";
/** Current version of the JNI library */ /** Current version of the JNI library */
static final int JNI_VERSION = 9; static final int JNI_VERSION = 10;
/** The implementation instance to delegate platform specific behavior to */ /** The implementation instance to delegate platform specific behavior to */
private final static SysImplementation implementation; private final static SysImplementation implementation;

View File

@ -34,6 +34,7 @@ package org.lwjgl.opengl;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
/** /**
* *
@ -96,14 +97,12 @@ final class WindowsContextImplementation implements ContextImplementation {
private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException; private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException;
public void setSwapInterval(int value) { public void setSwapInterval(int value) {
Context current_context = Context.getCurrentContext(); boolean success = nSetSwapInterval(value) == GL11.GL_TRUE ? true : false;
if (current_context == null) if (!success)
throw new IllegalStateException("No context is current"); LWJGLUtil.log("Failed to set swap interval");
synchronized (current_context) { Util.checkGLError();
nSetSwapInterval(current_context.getHandle(), value);
} }
} private static native int nSetSwapInterval(int value);
private static native void nSetSwapInterval(ByteBuffer context_handle, int value);
public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
nDestroy(handle); nDestroy(handle);

View File

@ -105,8 +105,8 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nI
return wglGetCurrentContext() == context_info->context; return wglGetCurrentContext() == context_info->context;
} }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSetSwapInterval JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSetSwapInterval
(JNIEnv *env, jclass clazz, jobject context_handle, jint value) { (JNIEnv *env, jclass clazz, jint value) {
WGLExtensions extensions; WGLExtensions extensions;
extgl_InitWGL(&extensions); extgl_InitWGL(&extensions);
if (extensions.WGL_EXT_swap_control) { if (extensions.WGL_EXT_swap_control) {