< prev index next >

src/java.desktop/unix/native/common/java2d/opengl/GLXGraphicsConfig.c

Print this page




 455  * met, the native GLXGraphicsConfigInfo structure is initialized for this
 456  * GraphicsConfig with the necessary information (GLXFBConfig, etc.)
 457  * and a pointer to this structure is returned as a jlong.  If
 458  * initialization fails at any point, zero is returned, indicating that GLX
 459  * cannot be used for this GraphicsConfig (we should fallback on the existing
 460  * X11 pipeline).
 461  */
 462 JNIEXPORT jlong JNICALL
 463 Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo(JNIEnv *env,
 464                                                           jclass glxgc,
 465                                                           jint screennum,
 466                                                           jint visnum)
 467 {
 468 #ifndef HEADLESS
 469     OGLContext *oglc;
 470     GLXFBConfig fbconfig;
 471     GLXContext context;
 472     GLXPbuffer scratch;
 473     GLXGraphicsConfigInfo *glxinfo;
 474     jint caps = CAPS_EMPTY;
 475     int db, alpha;
 476     const unsigned char *versionstr;
 477 
 478     J2dRlsTraceLn(J2D_TRACE_INFO, "GLXGraphicsConfig_getGLXConfigInfo");
 479 
 480     if (usingXinerama) {
 481         // when Xinerama is enabled, the screen ID needs to be 0
 482         screennum = 0;
 483     }
 484 
 485     fbconfig = GLXGC_InitFBConfig(env, screennum, (VisualID)visnum);
 486     if (fbconfig == 0) {
 487         J2dRlsTraceLn(J2D_TRACE_ERROR,
 488             "GLXGraphicsConfig_getGLXConfigInfo: could not create fbconfig");
 489         return 0L;
 490     }
 491 
 492     if (sharedContext == 0) {
 493         // create the one shared context
 494         sharedContext = j2d_glXCreateNewContext(awt_display, fbconfig,
 495                                                 GLX_RGBA_TYPE, 0, GL_TRUE);


 566     // destroy the temporary resources
 567     j2d_glXMakeContextCurrent(awt_display, None, None, NULL);
 568 
 569     J2dRlsTraceLn1(J2D_TRACE_INFO,
 570         "GLXGraphicsConfig_getGLXConfigInfo: OpenGL version=%s",
 571                    (versionstr == NULL) ? "null" : (char *)versionstr);
 572 
 573     if (!OGLContext_IsVersionSupported(versionstr)) {
 574         J2dRlsTraceLn(J2D_TRACE_ERROR,
 575             "GLXGraphicsConfig_getGLXConfigInfo: OpenGL 1.2 is required");
 576         j2d_glXDestroyPbuffer(awt_display, scratch);
 577         j2d_glXDestroyContext(awt_display, context);
 578         return 0L;
 579     }
 580 
 581     // get config-specific capabilities
 582     j2d_glXGetFBConfigAttrib(awt_display, fbconfig, GLX_DOUBLEBUFFER, &db);
 583     if (db) {
 584         caps |= CAPS_DOUBLEBUFFERED;
 585     }
 586     j2d_glXGetFBConfigAttrib(awt_display, fbconfig, GLX_ALPHA_SIZE, &alpha);
 587     if (alpha > 0) {
 588         caps |= CAPS_STORED_ALPHA;
 589     }
 590 
 591     // initialize the OGLContext, which wraps the GLXFBConfig and GLXContext
 592     oglc = GLXGC_InitOGLContext(fbconfig, context, scratch, caps);
 593     if (oglc == NULL) {
 594         J2dRlsTraceLn(J2D_TRACE_ERROR,
 595             "GLXGraphicsConfig_getGLXConfigInfo: could not create oglc");
 596         j2d_glXDestroyPbuffer(awt_display, scratch);
 597         j2d_glXDestroyContext(awt_display, context);
 598         return 0L;
 599     }
 600 
 601     J2dTraceLn(J2D_TRACE_VERBOSE,
 602         "GLXGraphicsConfig_getGLXConfigInfo: finished checking dependencies");
 603 
 604     // create the GLXGraphicsConfigInfo record for this config
 605     glxinfo = (GLXGraphicsConfigInfo *)malloc(sizeof(GLXGraphicsConfigInfo));
 606     if (glxinfo == NULL) {
 607         J2dRlsTraceLn(J2D_TRACE_ERROR,
 608             "GLXGraphicsConfig_getGLXConfigInfo: could not allocate memory for glxinfo");
 609         GLXGC_DestroyOGLContext(oglc);




 455  * met, the native GLXGraphicsConfigInfo structure is initialized for this
 456  * GraphicsConfig with the necessary information (GLXFBConfig, etc.)
 457  * and a pointer to this structure is returned as a jlong.  If
 458  * initialization fails at any point, zero is returned, indicating that GLX
 459  * cannot be used for this GraphicsConfig (we should fallback on the existing
 460  * X11 pipeline).
 461  */
 462 JNIEXPORT jlong JNICALL
 463 Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo(JNIEnv *env,
 464                                                           jclass glxgc,
 465                                                           jint screennum,
 466                                                           jint visnum)
 467 {
 468 #ifndef HEADLESS
 469     OGLContext *oglc;
 470     GLXFBConfig fbconfig;
 471     GLXContext context;
 472     GLXPbuffer scratch;
 473     GLXGraphicsConfigInfo *glxinfo;
 474     jint caps = CAPS_EMPTY;
 475     int db;
 476     const unsigned char *versionstr;
 477 
 478     J2dRlsTraceLn(J2D_TRACE_INFO, "GLXGraphicsConfig_getGLXConfigInfo");
 479 
 480     if (usingXinerama) {
 481         // when Xinerama is enabled, the screen ID needs to be 0
 482         screennum = 0;
 483     }
 484 
 485     fbconfig = GLXGC_InitFBConfig(env, screennum, (VisualID)visnum);
 486     if (fbconfig == 0) {
 487         J2dRlsTraceLn(J2D_TRACE_ERROR,
 488             "GLXGraphicsConfig_getGLXConfigInfo: could not create fbconfig");
 489         return 0L;
 490     }
 491 
 492     if (sharedContext == 0) {
 493         // create the one shared context
 494         sharedContext = j2d_glXCreateNewContext(awt_display, fbconfig,
 495                                                 GLX_RGBA_TYPE, 0, GL_TRUE);


 566     // destroy the temporary resources
 567     j2d_glXMakeContextCurrent(awt_display, None, None, NULL);
 568 
 569     J2dRlsTraceLn1(J2D_TRACE_INFO,
 570         "GLXGraphicsConfig_getGLXConfigInfo: OpenGL version=%s",
 571                    (versionstr == NULL) ? "null" : (char *)versionstr);
 572 
 573     if (!OGLContext_IsVersionSupported(versionstr)) {
 574         J2dRlsTraceLn(J2D_TRACE_ERROR,
 575             "GLXGraphicsConfig_getGLXConfigInfo: OpenGL 1.2 is required");
 576         j2d_glXDestroyPbuffer(awt_display, scratch);
 577         j2d_glXDestroyContext(awt_display, context);
 578         return 0L;
 579     }
 580 
 581     // get config-specific capabilities
 582     j2d_glXGetFBConfigAttrib(awt_display, fbconfig, GLX_DOUBLEBUFFER, &db);
 583     if (db) {
 584         caps |= CAPS_DOUBLEBUFFERED;
 585     }




 586 
 587     // initialize the OGLContext, which wraps the GLXFBConfig and GLXContext
 588     oglc = GLXGC_InitOGLContext(fbconfig, context, scratch, caps);
 589     if (oglc == NULL) {
 590         J2dRlsTraceLn(J2D_TRACE_ERROR,
 591             "GLXGraphicsConfig_getGLXConfigInfo: could not create oglc");
 592         j2d_glXDestroyPbuffer(awt_display, scratch);
 593         j2d_glXDestroyContext(awt_display, context);
 594         return 0L;
 595     }
 596 
 597     J2dTraceLn(J2D_TRACE_VERBOSE,
 598         "GLXGraphicsConfig_getGLXConfigInfo: finished checking dependencies");
 599 
 600     // create the GLXGraphicsConfigInfo record for this config
 601     glxinfo = (GLXGraphicsConfigInfo *)malloc(sizeof(GLXGraphicsConfigInfo));
 602     if (glxinfo == NULL) {
 603         J2dRlsTraceLn(J2D_TRACE_ERROR,
 604             "GLXGraphicsConfig_getGLXConfigInfo: could not allocate memory for glxinfo");
 605         GLXGC_DestroyOGLContext(oglc);


< prev index next >