summaryrefslogtreecommitdiffstats
path: root/src/jogl/native/JoglCommon.h
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-04-12 20:21:06 +0200
committerSven Gothel <[email protected]>2012-04-12 20:21:06 +0200
commitace2daf725dfc1aa700338fae71fe93a9d0fd865 (patch)
tree71846e4937f932608e73053c5eab387776cbcf2e /src/jogl/native/JoglCommon.h
parent711b283a350e2ad27be38e4baede26ad744c1450 (diff)
JOGL/Native: Add JNIEnv functions
Diffstat (limited to 'src/jogl/native/JoglCommon.h')
-rw-r--r--src/jogl/native/JoglCommon.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/jogl/native/JoglCommon.h b/src/jogl/native/JoglCommon.h
index d82b445ce..b988336fa 100644
--- a/src/jogl/native/JoglCommon.h
+++ b/src/jogl/native/JoglCommon.h
@@ -7,9 +7,42 @@
void JoglCommon_init(JNIEnv *env);
+/** Set by JoglCommon_init */
+JavaVM *JoglCommon_GetJVMHandle();
+
+/** Set by JoglCommon_init */
+int JoglCommon_GetJVMVersion();
+
jchar* JoglCommon_GetNullTerminatedStringChars(JNIEnv* env, jstring str);
void JoglCommon_FatalError(JNIEnv *env, const char* msg, ...);
void JoglCommon_throwNewRuntimeException(JNIEnv *env, const char* msg, ...);
+/**
+ *
+ * 1) Store jvmHandle and jvmVersion is done by 'JoglCommon_init(JNIEnv*)'
+ * and internally used by 'JoglCommon_GetJNIEnv(..)' and 'JoglCommon_ReleaseJNIEnv(..)'.
+ *
+ * 2) Use current thread JNIEnv or attach current thread to JVM, generating new JNIEnv
+ *
+ int shallBeDetached = 0;
+ JNIEnv* env = NewtCommon_GetJNIEnv(&shallBeDetached);
+ if(NULL==env) {
+ DBG_PRINT("drawRect: null JNIEnv\n");
+ return;
+ }
+
+ *
+ * 3) Use JNIEnv ..
+ *
+ .. your JNIEnv code here ..
+
+ *
+ * 4) Detach thread from JVM, if required
+ *
+ JoglCommon_ReleaseJNIEnv (shallBeDetached);
+ */
+JNIEnv* JoglCommon_GetJNIEnv (int * shallBeDetached);
+void JoglCommon_ReleaseJNIEnv (int shallBeDetached);
+
#endif