< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 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,


   1 /*
   2  * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 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 >