From: Subu <ma...@ce...> - 2002-07-20 00:06:53
|
When the parent of a GLCanvas is changed, the code in the if block (gljMakeCurrentNative() in OpenGL_Win32_jawt.c) is executed. if(jawt_lock(env, pData, JNI_FALSE, verbose)==JNI_FALSE || pData->result==JNI_FALSE ) { /* this can happen: if ( (pJData->lock & JAWT_LOCK_SURFACE_CHANGED) != 0 ) In this case, we need a new GLXContext ... This has to be queried by the java class, while using the native method hasJAWTSurfaceChanged ! */ if(verbose) { fprintf(stderr,"\nGL4Java ERROR: MakeCurrent could not lock JAWT reference!\n"); fflush(stderr); } ret=JNI_FALSE; jawt_close_unlock(env, pData, JNI_FALSE); return ret; } Before the call to jawt_close_unlock(), pData->lock has the bit JAWT_LOCK_SURFACE_CHANGED set. After this call, this bit is cleared. Now gljMakeCurrent() (in GLContext.java) calls hasJAWTSurfaceChanged() to check if the GLContext needs to be recreated, and hasJAWTSurfaceChanged() always returns false. I've made a local fix to set this bit after the call to jawt_close_unlock() only if it was set before the call. This seems to work nicely for me. Could someone who knows more about this please tell me if this is the right thing to do? If it is correct, could one of the developers please fix it for the next release. JNIEXPORT jboolean JNICALL Java_gl4java_GLContext_gljMakeCurrentNative( JNIEnv *env, jobject obj, jobject canvas, jlong disp, jlong thisWin, jlong glContext) { ... int lockSurfaceChanged = 0; ... ... if(jawt_lock(env, pData, JNI_FALSE, verbose)==JNI_FALSE || pData->result==JNI_FALSE ) { ... ... lockSurfaceChanged = pData->lock & JAWT_LOCK_SURFACE_CHANGED; jawt_close_unlock(env, pData, JNI_FALSE); if (lockSurfaceChanged) pData->lock |= JAWT_LOCK_SURFACE_CHANGED; return ret; } ... ... } -s |