Added releaseContext to BaseGL.java (and native for linux)

This commit is contained in:
Elias Naur 2002-11-25 17:04:56 +00:00
parent c13797bae2
commit 139e7b4cfb
3 changed files with 39 additions and 3 deletions

View File

@ -165,6 +165,16 @@ abstract class BaseGL {
destroy();
}
/**
* Free the context from the current thread.
*/
public final void releaseContext() {
assert created : "GL has not been created yet.";
renderThread = null;
currentContext = null;
nReleaseContext();
}
/**
* Make this the current context for the current thread.
*/
@ -180,6 +190,11 @@ abstract class BaseGL {
*/
public native void swapBuffers();
/**
* Native method to free the context
*/
private native void nReleaseContext();
/**
* Native method to make this the current thread
*/

View File

@ -9,7 +9,7 @@ extern "C" {
#endif
/* Inaccessible static: _00024assertionsDisabled */
/* Inaccessible static: currentContext */
/* Inaccessible static: class_000240 */
/* Inaccessible static: class_00024org_00024lwjgl_00024opengl_00024BaseGL */
/*
* Class: org_lwjgl_opengl_BaseGL
* Method: nCreate
@ -34,6 +34,14 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nDestroy
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_swapBuffers
(JNIEnv *, jobject);
/*
* Class: org_lwjgl_opengl_BaseGL
* Method: nReleaseContext
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nReleaseContext
(JNIEnv *, jobject);
/*
* Class: org_lwjgl_opengl_BaseGL
* Method: nMakeCurrent

View File

@ -51,6 +51,10 @@ void makeCurrent(void) {
glXMakeCurrent(disp, win, context);
}
void releaseContext(void) {
glXMakeCurrent(disp, None, NULL);
}
/*
* Class: org_lwjgl_opengl_BaseGL
* Method: nCreate
@ -92,8 +96,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_BaseGL_nCreate
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nDestroy
(JNIEnv * env, jobject obj)
{
glXMakeCurrent(disp, None, NULL);
releaseContext();
// Delete the rendering context
if (context != NULL)
glXDestroyContext(disp, context);
@ -120,3 +123,13 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nMakeCurrent
makeCurrent();
}
/*
* * Class: org_lwjgl_opengl_BaseGL
* * Method: nFreeContext
* * Signature: ()V
* */
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nReleaseContext
(JNIEnv *, jobject)
{
releaseContext();
}