< prev index next >

src/java.desktop/windows/native/libawt/java2d/opengl/WGLGraphicsConfig.c

Print this page




 485  * cannot be used for this GraphicsConfig (we should fallback on the existing
 486  * DX pipeline).
 487  */
 488 JNIEXPORT jlong JNICALL
 489 Java_sun_java2d_opengl_WGLGraphicsConfig_getWGLConfigInfo(JNIEnv *env,
 490                                                           jclass wglgc,
 491                                                           jint screennum,
 492                                                           jint pixfmt)
 493 {
 494     OGLContext *oglc;
 495     PIXELFORMATDESCRIPTOR pfd;
 496     HWND hwnd;
 497     HDC hdc;
 498     HGLRC context;
 499     HPBUFFERARB scratch;
 500     HDC scratchDC;
 501     WGLGraphicsConfigInfo *wglinfo;
 502     const unsigned char *versionstr;
 503     const char *extstr;
 504     jint caps = CAPS_EMPTY;
 505     int attrKeys[] = { WGL_DOUBLE_BUFFER_ARB, WGL_ALPHA_BITS_ARB };
 506     int attrVals[2];
 507 
 508     J2dRlsTraceLn(J2D_TRACE_INFO, "WGLGraphicsConfig_getWGLConfigInfo");
 509 
 510     // initialize GL/WGL extension functions
 511     if (!WGLGC_InitExtFuncs(screennum)) {
 512         J2dRlsTraceLn(J2D_TRACE_ERROR,
 513             "WGLGraphicsConfig_getWGLConfigInfo: could not init ext funcs");
 514         return 0L;
 515     }
 516 
 517     // create a scratch window
 518     hwnd = WGLGC_CreateScratchWindow(screennum);
 519     if (hwnd == 0) {
 520         return 0L;
 521     }
 522 
 523     // get the HDC for the scratch window
 524     hdc = GetDC(hwnd);
 525     if (hdc == 0) {
 526         J2dRlsTraceLn(J2D_TRACE_ERROR,


 607         ReleaseDC(hwnd, hdc);
 608         DestroyWindow(hwnd);
 609         return 0L;
 610     }
 611 
 612     // check for required WGL extensions
 613     if (!OGLContext_IsExtensionAvailable(extstr, "WGL_ARB_pbuffer") ||
 614         !OGLContext_IsExtensionAvailable(extstr, "WGL_ARB_make_current_read")||
 615         !OGLContext_IsExtensionAvailable(extstr, "WGL_ARB_pixel_format"))
 616     {
 617         J2dRlsTraceLn(J2D_TRACE_ERROR,
 618             "WGLGraphicsConfig_getWGLConfigInfo: required ext(s) unavailable");
 619         j2d_wglMakeCurrent(NULL, NULL);
 620         j2d_wglDeleteContext(context);
 621         ReleaseDC(hwnd, hdc);
 622         DestroyWindow(hwnd);
 623         return 0L;
 624     }
 625 
 626     // get config-specific capabilities
 627     j2d_wglGetPixelFormatAttribivARB(hdc, pixfmt, 0, 2, attrKeys, attrVals);
 628     if (attrVals[0]) {
 629         caps |= CAPS_DOUBLEBUFFERED;
 630     }
 631     if (attrVals[1] > 0) {
 632         caps |= CAPS_STORED_ALPHA;
 633     }
 634 
 635     // create the scratch pbuffer
 636     scratch = j2d_wglCreatePbufferARB(hdc, pixfmt, 1, 1, NULL);
 637 
 638     // destroy the temporary resources
 639     j2d_wglMakeCurrent(NULL, NULL);
 640     ReleaseDC(hwnd, hdc);
 641     DestroyWindow(hwnd);
 642 
 643     if (scratch == 0) {
 644         J2dRlsTraceLn(J2D_TRACE_ERROR,
 645             "WGLGraphicsConfig_getWGLConfigInfo: could not create scratch surface");
 646         j2d_wglDeleteContext(context);
 647         return 0L;
 648     }
 649 
 650     // get the HDC for the scratch pbuffer
 651     scratchDC = j2d_wglGetPbufferDCARB(scratch);
 652     if (scratchDC == 0) {
 653         J2dRlsTraceLn(J2D_TRACE_ERROR,




 485  * cannot be used for this GraphicsConfig (we should fallback on the existing
 486  * DX pipeline).
 487  */
 488 JNIEXPORT jlong JNICALL
 489 Java_sun_java2d_opengl_WGLGraphicsConfig_getWGLConfigInfo(JNIEnv *env,
 490                                                           jclass wglgc,
 491                                                           jint screennum,
 492                                                           jint pixfmt)
 493 {
 494     OGLContext *oglc;
 495     PIXELFORMATDESCRIPTOR pfd;
 496     HWND hwnd;
 497     HDC hdc;
 498     HGLRC context;
 499     HPBUFFERARB scratch;
 500     HDC scratchDC;
 501     WGLGraphicsConfigInfo *wglinfo;
 502     const unsigned char *versionstr;
 503     const char *extstr;
 504     jint caps = CAPS_EMPTY;
 505     int attrKeys[] = { WGL_DOUBLE_BUFFER_ARB};
 506     int attrVals[1];
 507 
 508     J2dRlsTraceLn(J2D_TRACE_INFO, "WGLGraphicsConfig_getWGLConfigInfo");
 509 
 510     // initialize GL/WGL extension functions
 511     if (!WGLGC_InitExtFuncs(screennum)) {
 512         J2dRlsTraceLn(J2D_TRACE_ERROR,
 513             "WGLGraphicsConfig_getWGLConfigInfo: could not init ext funcs");
 514         return 0L;
 515     }
 516 
 517     // create a scratch window
 518     hwnd = WGLGC_CreateScratchWindow(screennum);
 519     if (hwnd == 0) {
 520         return 0L;
 521     }
 522 
 523     // get the HDC for the scratch window
 524     hdc = GetDC(hwnd);
 525     if (hdc == 0) {
 526         J2dRlsTraceLn(J2D_TRACE_ERROR,


 607         ReleaseDC(hwnd, hdc);
 608         DestroyWindow(hwnd);
 609         return 0L;
 610     }
 611 
 612     // check for required WGL extensions
 613     if (!OGLContext_IsExtensionAvailable(extstr, "WGL_ARB_pbuffer") ||
 614         !OGLContext_IsExtensionAvailable(extstr, "WGL_ARB_make_current_read")||
 615         !OGLContext_IsExtensionAvailable(extstr, "WGL_ARB_pixel_format"))
 616     {
 617         J2dRlsTraceLn(J2D_TRACE_ERROR,
 618             "WGLGraphicsConfig_getWGLConfigInfo: required ext(s) unavailable");
 619         j2d_wglMakeCurrent(NULL, NULL);
 620         j2d_wglDeleteContext(context);
 621         ReleaseDC(hwnd, hdc);
 622         DestroyWindow(hwnd);
 623         return 0L;
 624     }
 625 
 626     // get config-specific capabilities
 627     j2d_wglGetPixelFormatAttribivARB(hdc, pixfmt, 0, 1, attrKeys, attrVals);
 628     if (attrVals[0]) {
 629         caps |= CAPS_DOUBLEBUFFERED;
 630     }



 631 
 632     // create the scratch pbuffer
 633     scratch = j2d_wglCreatePbufferARB(hdc, pixfmt, 1, 1, NULL);
 634 
 635     // destroy the temporary resources
 636     j2d_wglMakeCurrent(NULL, NULL);
 637     ReleaseDC(hwnd, hdc);
 638     DestroyWindow(hwnd);
 639 
 640     if (scratch == 0) {
 641         J2dRlsTraceLn(J2D_TRACE_ERROR,
 642             "WGLGraphicsConfig_getWGLConfigInfo: could not create scratch surface");
 643         j2d_wglDeleteContext(context);
 644         return 0L;
 645     }
 646 
 647     // get the HDC for the scratch pbuffer
 648     scratchDC = j2d_wglGetPbufferDCARB(scratch);
 649     if (scratchDC == 0) {
 650         J2dRlsTraceLn(J2D_TRACE_ERROR,


< prev index next >