src/video/x11/SDL_x11opengles.c
changeset 6522 edacce9402fb
parent 6373 494e0436525f
child 6791 c19c5232439d
equal deleted inserted replaced
6521:f36bbe0a10c9 6522:edacce9402fb
   356     int retval;
   356     int retval;
   357 
   357 
   358 //    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   358 //    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   359 //    Display *display = data->videodata->display;
   359 //    Display *display = data->videodata->display;
   360 
   360 
       
   361     if (!_this->gles_data) {
       
   362         SDL_SetError("OpenGL not initialized");
       
   363         return -1;
       
   364     }
       
   365 
   361     retval = 1;
   366     retval = 1;
   362     if (!_this->gles_data->eglMakeCurrent(_this->gles_data->egl_display,
   367     if (!_this->gles_data->eglMakeCurrent(_this->gles_data->egl_display,
   363                                           _this->gles_data->egl_surface,
   368                                           _this->gles_data->egl_surface,
   364                                           _this->gles_data->egl_surface,
   369                                           _this->gles_data->egl_surface,
   365                                           _this->gles_data->egl_context)) {
   370                                           _this->gles_data->egl_context)) {
   410 
   415 
   411 void
   416 void
   412 X11_GLES_DeleteContext(_THIS, SDL_GLContext context)
   417 X11_GLES_DeleteContext(_THIS, SDL_GLContext context)
   413 {
   418 {
   414     /* Clean up GLES and EGL */
   419     /* Clean up GLES and EGL */
   415     if (_this->gles_data) {  
   420     if (!_this->gles_data) {  
   416         if (_this->gles_data->egl_context != EGL_NO_CONTEXT ||
   421         return;
   417             _this->gles_data->egl_surface != EGL_NO_SURFACE) {
   422     }
   418             _this->gles_data->eglMakeCurrent(_this->gles_data->egl_display,
   423 
   419                                              EGL_NO_SURFACE, EGL_NO_SURFACE,
   424     if (_this->gles_data->egl_context != EGL_NO_CONTEXT ||
   420                                              EGL_NO_CONTEXT);
   425         _this->gles_data->egl_surface != EGL_NO_SURFACE) {
   421 
   426         _this->gles_data->eglMakeCurrent(_this->gles_data->egl_display,
   422             if (_this->gles_data->egl_context != EGL_NO_CONTEXT) {
   427                                          EGL_NO_SURFACE, EGL_NO_SURFACE,
   423                 _this->gles_data->eglDestroyContext(_this->gles_data->egl_display,
   428                                          EGL_NO_CONTEXT);
   424                                                     _this->gles_data->
   429 
   425                                                     egl_context);
   430         if (_this->gles_data->egl_context != EGL_NO_CONTEXT) {
   426                 _this->gles_data->egl_context = EGL_NO_CONTEXT;
   431             _this->gles_data->eglDestroyContext(_this->gles_data->egl_display,
   427             }
   432                                                 _this->gles_data->
   428 
   433                                                 egl_context);
   429             if (_this->gles_data->egl_surface != EGL_NO_SURFACE) {
   434             _this->gles_data->egl_context = EGL_NO_CONTEXT;
   430                 _this->gles_data->eglDestroySurface(_this->gles_data->egl_display,
       
   431                                                     _this->gles_data->
       
   432                                                     egl_surface);
       
   433                 _this->gles_data->egl_surface = EGL_NO_SURFACE;
       
   434             }
       
   435         }
   435         }
   436 
   436 
   437         /* crappy fix */
   437         if (_this->gles_data->egl_surface != EGL_NO_SURFACE) {
   438         X11_GLES_UnloadLibrary(_this);
   438             _this->gles_data->eglDestroySurface(_this->gles_data->egl_display,
   439     }
   439                                                 _this->gles_data->
   440 
   440                                                 egl_surface);
       
   441             _this->gles_data->egl_surface = EGL_NO_SURFACE;
       
   442         }
       
   443     }
       
   444 
       
   445     /* crappy fix */
       
   446     X11_GLES_UnloadLibrary(_this);
   441 }
   447 }
   442 
   448 
   443 #endif /* SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES */
   449 #endif /* SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES */
   444 
   450 
   445 /* vi: set ts=4 sw=4 expandtab: */
   451 /* vi: set ts=4 sw=4 expandtab: */