From d58c8b767bd834b0a2bbded0d967d8c1b2923c96 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 30 Mar 2003 19:40:35 +0000 Subject: [PATCH] I like those makeContextCurrent/releaseContext... --- src/java/org/lwjgl/opengl/BaseGL.java | 10 +++++++++ src/native/common/org_lwjgl_opengl_BaseGL.h | 16 ++++++++++++++ src/native/linux/org_lwjgl_opengl_BaseGL.cpp | 4 ++-- src/native/win32/org_lwjgl_opengl_BaseGL.cpp | 23 +++++++++++++++++++- 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/java/org/lwjgl/opengl/BaseGL.java b/src/java/org/lwjgl/opengl/BaseGL.java index 158002b9..46cc459c 100644 --- a/src/java/org/lwjgl/opengl/BaseGL.java +++ b/src/java/org/lwjgl/opengl/BaseGL.java @@ -170,4 +170,14 @@ public class BaseGL extends Window { */ private native void nDestroyGL(); + /** + * Make the GL context current to the current thread + */ + public native void makeContextCurrent(); + + /** + * Release the GL context + */ + public native void releaseContext(); + } diff --git a/src/native/common/org_lwjgl_opengl_BaseGL.h b/src/native/common/org_lwjgl_opengl_BaseGL.h index 3afbaa42..6febbeee 100644 --- a/src/native/common/org_lwjgl_opengl_BaseGL.h +++ b/src/native/common/org_lwjgl_opengl_BaseGL.h @@ -32,6 +32,22 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nCreate JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nDestroyGL (JNIEnv *, jobject); +/* + * Class: org_lwjgl_opengl_BaseGL + * Method: makeContextCurrent + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_makeContextCurrent + (JNIEnv *, jobject); + +/* + * Class: org_lwjgl_opengl_BaseGL + * Method: releaseContext + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_releaseContext + (JNIEnv *, jobject); + #ifdef __cplusplus } #endif diff --git a/src/native/linux/org_lwjgl_opengl_BaseGL.cpp b/src/native/linux/org_lwjgl_opengl_BaseGL.cpp index fe6693c9..3acad11d 100644 --- a/src/native/linux/org_lwjgl_opengl_BaseGL.cpp +++ b/src/native/linux/org_lwjgl_opengl_BaseGL.cpp @@ -190,7 +190,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_swapBuffers(JNIEnv * env, jo * Method: nMakeCurrent * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nMakeCurrent +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_makeContextCurrent (JNIEnv * env, jobject obj) { makeCurrent(); @@ -201,7 +201,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nMakeCurrent * Method: nFreeContext * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nReleaseContext +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_releaseContext (JNIEnv *, jobject) { releaseContext(); diff --git a/src/native/win32/org_lwjgl_opengl_BaseGL.cpp b/src/native/win32/org_lwjgl_opengl_BaseGL.cpp index 1e815e0e..d5dd0c98 100644 --- a/src/native/win32/org_lwjgl_opengl_BaseGL.cpp +++ b/src/native/win32/org_lwjgl_opengl_BaseGL.cpp @@ -218,4 +218,25 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_swapBuffers { SwapBuffers(wglGetCurrentDC()); } - + +/* + * Class: org_lwjgl_opengl_BaseGL + * Method: nMakeCurrent + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_makeContextCurrent + (JNIEnv * env, jobject obj) +{ + wglMakeCurrent(hdc, hglrc); +} + +/* + * * Class: org_lwjgl_opengl_BaseGL + * * Method: nFreeContext + * * Signature: ()V + * */ +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_releaseContext + (JNIEnv *, jobject) +{ + wglMakeCurrent(NULL, NULL); +}