diff options
Diffstat (limited to 'src/native/ogl/Canvas3D.c')
-rw-r--r-- | src/native/ogl/Canvas3D.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/native/ogl/Canvas3D.c b/src/native/ogl/Canvas3D.c index f653e84..f18d817 100644 --- a/src/native/ogl/Canvas3D.c +++ b/src/native/ogl/Canvas3D.c @@ -1309,7 +1309,7 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_useCtx( +jboolean JNICALL Java_javax_media_j3d_Canvas3D_useCtx( JNIEnv *env, jclass cl, jlong ctxInfo, @@ -1318,13 +1318,36 @@ void JNICALL Java_javax_media_j3d_Canvas3D_useCtx( { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; + int result; #if defined(UNIX) - glXMakeCurrent((Display *)display, (GLXDrawable)window, (GLXContext)ctx); + + result = glXMakeCurrent((Display *)display, (GLXDrawable)window, (GLXContext)ctx); + if (result != GL_TRUE) { + fprintf(stderr, "Java 3D ERROR : In Canvas3D.useCtx() glXMakeCurrent fails\n"); + return JNI_FALSE; + } + #endif #ifdef WIN32 - wglMakeCurrent((HDC) window, (HGLRC) ctx); + DWORD err; + LPTSTR errString; + + result = wglMakeCurrent((HDC) window, (HGLRC) ctx); + /* fprintf(stderr, "useCtx : wglMakeCurrent : window %d, ctx %d, result = %d\n", + window, (int) ctx, result); */ + + if (result != GL_TRUE) { + err = GetLastError(); + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, err, 0, (LPTSTR)&errString, 0, NULL); + fprintf(stderr, "wglMakeCurrent Failed: %s\n", errString); + return JNI_FALSE; + } + #endif + return JNI_TRUE; } JNIEXPORT @@ -2741,7 +2764,6 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( hpbuf = pFormatInfoPtr->wglCreatePbufferARB( hdc, pFormatInfoPtr->offScreenPFormat, width, height, piAttrs); - if(hpbuf == NULL) { printErrorMessage("In Canvas3D : wglCreatePbufferARB FAIL."); ReleaseDC(hwnd, hdc); |