src/video/SDL_egl.c
changeset 12376 cfc65d4d49ae
parent 12269 754cd2042e21
child 12493 82f9397db3e7
equal deleted inserted replaced
12375:d9a16c76d8d1 12376:cfc65d4d49ae
   445     } else {
   445     } else {
   446         *_this->gl_config.driver_path = '\0';
   446         *_this->gl_config.driver_path = '\0';
   447     }
   447     }
   448     
   448     
   449     return 0;
   449     return 0;
       
   450 }
       
   451 
       
   452 void
       
   453 SDL_EGL_SetRequiredVisualId(_THIS, int visual_id) 
       
   454 {
       
   455     _this->egl_data->egl_required_visual_id=visual_id;
   450 }
   456 }
   451 
   457 
   452 #ifdef DUMP_EGL_CONFIG
   458 #ifdef DUMP_EGL_CONFIG
   453 
   459 
   454 #define ATTRIBUTE(_attr) { _attr, #_attr }
   460 #define ATTRIBUTE(_attr) { _attr, #_attr }
   511 SDL_EGL_ChooseConfig(_THIS) 
   517 SDL_EGL_ChooseConfig(_THIS) 
   512 {
   518 {
   513 /* 64 seems nice. */
   519 /* 64 seems nice. */
   514     EGLint attribs[64];
   520     EGLint attribs[64];
   515     EGLint found_configs = 0, value;
   521     EGLint found_configs = 0, value;
   516 #ifdef SDL_VIDEO_DRIVER_KMSDRM
       
   517     /* Intel EGL on KMS/DRM (al least) returns invalid configs that confuse the bitdiff search used */
       
   518     /* later in this function, so we simply use the first one when using the KMSDRM driver for now. */
       
   519     EGLConfig configs[1];
       
   520 #else
       
   521     /* 128 seems even nicer here */
   522     /* 128 seems even nicer here */
   522     EGLConfig configs[128];
   523     EGLConfig configs[128];
   523 #endif
       
   524     int i, j, best_bitdiff = -1, bitdiff;
   524     int i, j, best_bitdiff = -1, bitdiff;
   525    
   525    
   526     if (!_this->egl_data) {
   526     if (!_this->egl_data) {
   527         /* The EGL library wasn't loaded, SDL_GetError() should have info */
   527         /* The EGL library wasn't loaded, SDL_GetError() should have info */
   528         return -1;
   528         return -1;
   601 
   601 
   602     /* eglChooseConfig returns a number of configurations that match or exceed the requested attribs. */
   602     /* eglChooseConfig returns a number of configurations that match or exceed the requested attribs. */
   603     /* From those, we select the one that matches our requirements more closely via a makeshift algorithm */
   603     /* From those, we select the one that matches our requirements more closely via a makeshift algorithm */
   604 
   604 
   605     for (i = 0; i < found_configs; i++ ) {
   605     for (i = 0; i < found_configs; i++ ) {
       
   606         if (_this->egl_data->egl_required_visual_id)
       
   607         {
       
   608             EGLint format;
       
   609             _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
       
   610                                             configs[i], 
       
   611                                             EGL_NATIVE_VISUAL_ID, &format);
       
   612             if (_this->egl_data->egl_required_visual_id != format)
       
   613                 continue;
       
   614         }
       
   615 
   606         bitdiff = 0;
   616         bitdiff = 0;
   607         for (j = 0; j < SDL_arraysize(attribs) - 1; j += 2) {
   617         for (j = 0; j < SDL_arraysize(attribs) - 1; j += 2) {
   608             if (attribs[j] == EGL_NONE) {
   618             if (attribs[j] == EGL_NONE) {
   609                break;
   619                break;
   610             }
   620             }