diff options
Diffstat (limited to 'CNativeCode/OpenGL_X11.c')
-rw-r--r-- | CNativeCode/OpenGL_X11.c | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/CNativeCode/OpenGL_X11.c b/CNativeCode/OpenGL_X11.c index ac88c70..14510ec 100644 --- a/CNativeCode/OpenGL_X11.c +++ b/CNativeCode/OpenGL_X11.c @@ -83,6 +83,7 @@ */ static jboolean verbose = JNI_FALSE; + JNIEXPORT jboolean JNICALL Java_gl4java_GLContext_useJAWT( JNIEnv *env, jobject obj ) { @@ -136,7 +137,8 @@ Java_gl4java_GLContext_openOpenGLNative( JNIEnv *env, jobject obj, jobject jglCaps=0; GLCapabilities glCaps; - jboolean jownwind = JNI_FALSE ; + jboolean jb_value; + int ownwind = 0 ; jint jcreatewinw = 0, jcreatewinh = 0; GLXContext jshareWith = 0; @@ -240,7 +242,10 @@ Java_gl4java_GLContext_openOpenGLNative( JNIEnv *env, jobject obj, if(ret==JNI_TRUE) { fownwind = (*env)->GetFieldID(env, cls, "createOwnWindow", "Z"); if (fownwind == 0) ret= JNI_FALSE; - else jownwind =(*env)->GetBooleanField(env, obj, fownwind); + else { + jb_value =(*env)->GetBooleanField(env, obj, fownwind); + ownwind = (jb_value==JNI_TRUE)?1:0; + } } if(ret==JNI_TRUE) { @@ -266,7 +271,7 @@ Java_gl4java_GLContext_openOpenGLNative( JNIEnv *env, jobject obj, if(joffScreenRenderer==JNI_TRUE) { - jownwind = JNI_FALSE; + ownwind = 0; thisWin=0; } @@ -320,15 +325,15 @@ Java_gl4java_GLContext_openOpenGLNative( JNIEnv *env, jobject obj, /* Check to see if the Xserver supports OpenGL */ if(ret==JNI_TRUE) { - if( !glXQueryExtension(display, (int *) 0, (int *) 0) ) { + if( !disp__glXQueryExtension(display, (int *) 0, (int *) 0) ) { fprintf(stderr, "GL4Java ERROR: Can not query glx extension -> Server does not support OpenGL\n"); fflush(stderr); ret = JNI_FALSE; } else if (JNI_TRUE==verbose) { fprintf(stdout, "GLX by %s Version %s\n", - glXGetClientString(display, GLX_VENDOR), - glXGetClientString(display, GLX_VERSION)); + disp__glXGetClientString(display, GLX_VENDOR), + disp__glXGetClientString(display, GLX_VERSION)); } } @@ -338,12 +343,14 @@ Java_gl4java_GLContext_openOpenGLNative( JNIEnv *env, jobject obj, screen = DefaultScreen( display ); rootwini = RootWindow(display,screen) ; - glXMakeCurrent(display, None, NULL); + disp__glXMakeCurrent(display, None, NULL); vgc = findVisualGlX( display, rootwini, &thisWin, (int)jcreatewinw, (int)jcreatewinh, - &glCaps, - &jownwind, jshareWith, + &glCaps, &ownwind, + NULL /* pOwnWinAttr */, + 0 /* ownWinmask */, + jshareWith, joffScreenRenderer, &pix, verbose); if(vgc.success == 0 && glCaps.color==COLOR_RGBA) @@ -356,8 +363,10 @@ Java_gl4java_GLContext_openOpenGLNative( JNIEnv *env, jobject obj, vgc = findVisualGlX( display, rootwini, &thisWin, (int)jcreatewinw, (int)jcreatewinh, - &glCaps, - &jownwind, jshareWith, + &glCaps, &ownwind, + NULL /* pOwnWinAttr */, + 0 /* ownWinmask */, + jshareWith, joffScreenRenderer, &pix, verbose); } @@ -366,7 +375,7 @@ Java_gl4java_GLContext_openOpenGLNative( JNIEnv *env, jobject obj, fprintf(stderr,"GL4Java ERROR: GETTING GC FAILED\n"); fflush(stderr); - if(jownwind==JNI_TRUE && thisWin!=0) + if(ownwind && thisWin!=0) XDestroyWindow( display, thisWin ); if(joffScreenRenderer==JNI_TRUE && pix!=0) XFreePixmap(display, pix); @@ -416,7 +425,8 @@ Java_gl4java_GLContext_openOpenGLNative( JNIEnv *env, jobject obj, } if(ret==JNI_TRUE && fownwind) { - (*env)->SetBooleanField(env, obj, fownwind, jownwind); + jb_value = ownwind?JNI_TRUE:JNI_FALSE; + (*env)->SetBooleanField(env, obj, fownwind, jb_value); } return ret; @@ -432,7 +442,7 @@ Java_gl4java_GLContext_gljResizeNative( JNIEnv *env, jobject obj, * by a native Thread .... So we have to try avoid gl* reentrance * on the same GL-Context */ - glXWaitGL(); + disp__glXWaitGL(); if(isOwnWindow) { @@ -469,14 +479,14 @@ Java_gl4java_GLContext_gljMakeCurrentNative( JNIEnv *env, jobject obj, return JNI_FALSE; } - ctx = glXGetCurrentContext(); + ctx = disp__glXGetCurrentContext(); if(ctx==(GLXContext)((PointerHolder)glContext)) return JNI_TRUE; if(ret==JNI_TRUE) { - if( !glXMakeCurrent( (Display *)((PointerHolder)disp), + if( !disp__glXMakeCurrent( (Display *)((PointerHolder)disp), (Window)((PointerHolder)thisWin), (GLXContext)((PointerHolder)glContext) ) ) { @@ -506,7 +516,7 @@ Java_gl4java_GLContext_gljFreeNative( JNIEnv *env, jobject obj, if(ret==JNI_TRUE) { - if( !glXMakeCurrent( (Display *)((PointerHolder)disp), None, NULL)) + if( !disp__glXMakeCurrent( (Display *)((PointerHolder)disp), None, NULL)) { fprintf(stderr, "GL4Java: gljFree failed\n"); fflush(stderr); @@ -521,7 +531,7 @@ Java_gl4java_GLContext_gljIsContextCurrentNative( JNIEnv *env, jobject obj, jlong glContext ) { - GLXContext ctx = glXGetCurrentContext(); + GLXContext ctx = disp__glXGetCurrentContext(); if(ctx==(GLXContext)((PointerHolder)glContext)) return JNI_TRUE; @@ -594,7 +604,7 @@ Java_gl4java_GLContext_gljDestroyNative( JNIEnv *env, jobject obj, else jownwind =(*env)->GetBooleanField(env, obj, fownwind); } - glXWaitGL(); + disp__glXWaitGL(); if(ret==JNI_TRUE) { @@ -606,16 +616,16 @@ Java_gl4java_GLContext_gljDestroyNative( JNIEnv *env, jobject obj, fflush(stderr); } } - glXMakeCurrent( disp, None, NULL ); + disp__glXMakeCurrent( disp, None, NULL ); if(ret==JNI_TRUE) { if(gc!=0) - glXDestroyContext(disp, gc); + disp__glXDestroyContext(disp, gc); if(pix!=0) { if(win!=0) - glXDestroyGLXPixmap(disp, win); + disp__glXDestroyGLXPixmap(disp, win); win=0; XFreePixmap(disp, pix); } @@ -675,9 +685,9 @@ Java_gl4java_GLContext_gljSwapNative( JNIEnv *env, jobject obj, if( doubleBuffer == JNI_FALSE ) { /* don't double buffer */ - glXWaitGL(); + disp__glXWaitGL(); } else { - glXSwapBuffers( (Display *)((PointerHolder)disp), + disp__glXSwapBuffers( (Display *)((PointerHolder)disp), (Window)((PointerHolder)thisWin) ); } @@ -685,3 +695,4 @@ Java_gl4java_GLContext_gljSwapNative( JNIEnv *env, jobject obj, } + |