src/video/SDL_egl.c
changeset 11830 a01af1a724b3
parent 11829 fcbafc9e443c
child 11839 971881e55d61
equal deleted inserted replaced
11829:fcbafc9e443c 11830:a01af1a724b3
   517     if (_this->gl_config.multisamplesamples) {
   517     if (_this->gl_config.multisamplesamples) {
   518         attribs[i++] = EGL_SAMPLES;
   518         attribs[i++] = EGL_SAMPLES;
   519         attribs[i++] = _this->gl_config.multisamplesamples;
   519         attribs[i++] = _this->gl_config.multisamplesamples;
   520     }
   520     }
   521 
   521 
   522     if (_this->gl_config.framebuffer_srgb_capable) {
       
   523 #ifdef EGL_KHR_gl_colorspace
       
   524         if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) {
       
   525             attribs[i++] = EGL_GL_COLORSPACE_KHR;
       
   526             attribs[i++] = EGL_GL_COLORSPACE_SRGB_KHR;
       
   527         } else
       
   528 #endif
       
   529         {
       
   530             return SDL_SetError("EGL implementation does not support sRGB system framebuffers");
       
   531         }
       
   532     }
       
   533 
       
   534     attribs[i++] = EGL_RENDERABLE_TYPE;
   522     attribs[i++] = EGL_RENDERABLE_TYPE;
   535     if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
   523     if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
   536 #ifdef EGL_KHR_create_context
   524 #ifdef EGL_KHR_create_context
   537         if (_this->gl_config.major_version >= 3 &&
   525         if (_this->gl_config.major_version >= 3 &&
   538             SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_create_context")) {
   526             SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_create_context")) {
   797 }
   785 }
   798 
   786 
   799 EGLSurface *
   787 EGLSurface *
   800 SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) 
   788 SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) 
   801 {
   789 {
       
   790     /* max 2 values plus terminator. */
       
   791     EGLint attribs[3];
       
   792     int attr = 0;
       
   793 	
   802     EGLSurface * surface;
   794     EGLSurface * surface;
   803 
   795 
   804     if (SDL_EGL_ChooseConfig(_this) != 0) {
   796     if (SDL_EGL_ChooseConfig(_this) != 0) {
   805         return EGL_NO_SURFACE;
   797         return EGL_NO_SURFACE;
   806     }
   798     }
   816                                             EGL_NATIVE_VISUAL_ID, &format);
   808                                             EGL_NATIVE_VISUAL_ID, &format);
   817 
   809 
   818         ANativeWindow_setBuffersGeometry(nw, 0, 0, format);
   810         ANativeWindow_setBuffersGeometry(nw, 0, 0, format);
   819     }
   811     }
   820 #endif    
   812 #endif    
       
   813     if (_this->gl_config.framebuffer_srgb_capable) {
       
   814 #ifdef EGL_KHR_gl_colorspace
       
   815         if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) {
       
   816             attribs[attr++] = EGL_GL_COLORSPACE_KHR;
       
   817             attribs[attr++] = EGL_GL_COLORSPACE_SRGB_KHR;
       
   818         } else
       
   819 #endif
       
   820         {
       
   821             SDL_SetError("EGL implementation does not support sRGB system framebuffers");
       
   822             return EGL_NO_SURFACE;
       
   823         }
       
   824     }
       
   825 	
       
   826     attribs[attr++] = EGL_NONE;
   821     
   827     
   822     surface = _this->egl_data->eglCreateWindowSurface(
   828     surface = _this->egl_data->eglCreateWindowSurface(
   823             _this->egl_data->egl_display,
   829             _this->egl_data->egl_display,
   824             _this->egl_data->egl_config,
   830             _this->egl_data->egl_config,
   825             nw, NULL);
   831             nw, &attribs[0]);
   826     if (surface == EGL_NO_SURFACE) {
   832     if (surface == EGL_NO_SURFACE) {
   827         SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface");
   833         SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface");
   828     }
   834     }
   829     return surface;
   835     return surface;
   830 }
   836 }