The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
authorSam Lantinga <slouken@libsdl.org>
Sun, 30 Sep 2012 01:08:48 -0700
changeset 6522edacce9402fb
parent 6521 f36bbe0a10c9
child 6523 62d0193a7a02
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
src/video/SDL_video.c
src/video/windows/SDL_windowsopengl.c
src/video/x11/SDL_x11opengl.c
src/video/x11/SDL_x11opengles.c
     1.1 --- a/src/video/SDL_video.c	Sun Sep 30 01:01:48 2012 -0700
     1.2 +++ b/src/video/SDL_video.c	Sun Sep 30 01:08:48 2012 -0700
     1.3 @@ -2639,7 +2639,7 @@
     1.4  void
     1.5  SDL_GL_DeleteContext(SDL_GLContext context)
     1.6  {
     1.7 -    if (!_this || !_this->gl_data || !context) {
     1.8 +    if (!_this || !context) {
     1.9          return;
    1.10      }
    1.11      _this->GL_MakeCurrent(_this, NULL, NULL);
     2.1 --- a/src/video/windows/SDL_windowsopengl.c	Sun Sep 30 01:01:48 2012 -0700
     2.2 +++ b/src/video/windows/SDL_windowsopengl.c	Sun Sep 30 01:08:48 2012 -0700
     2.3 @@ -613,6 +613,11 @@
     2.4      HDC hdc;
     2.5      int status;
     2.6  
     2.7 +    if (!_this->gl_data) {
     2.8 +        SDL_SetError("OpenGL not initialized");
     2.9 +        return -1;
    2.10 +    }
    2.11 +
    2.12      if (window) {
    2.13          hdc = ((SDL_WindowData *) window->driverdata)->hdc;
    2.14      } else {
    2.15 @@ -666,6 +671,9 @@
    2.16  void
    2.17  WIN_GL_DeleteContext(_THIS, SDL_GLContext context)
    2.18  {
    2.19 +    if (!_this->gl_data) {
    2.20 +        return;
    2.21 +    }
    2.22      _this->gl_data->wglDeleteContext((HGLRC) context);
    2.23  }
    2.24  
     3.1 --- a/src/video/x11/SDL_x11opengl.c	Sun Sep 30 01:01:48 2012 -0700
     3.2 +++ b/src/video/x11/SDL_x11opengl.c	Sun Sep 30 01:08:48 2012 -0700
     3.3 @@ -610,6 +610,11 @@
     3.4      GLXContext glx_context = (GLXContext) context;
     3.5      int status;
     3.6  
     3.7 +    if (!_this->gl_data) {
     3.8 +        SDL_SetError("OpenGL not initialized");
     3.9 +        return -1;
    3.10 +    }
    3.11 +
    3.12      status = 0;
    3.13      if (!_this->gl_data->glXMakeCurrent(display, drawable, glx_context)) {
    3.14          SDL_SetError("Unable to make GL context current");
    3.15 @@ -714,6 +719,9 @@
    3.16      Display *display = ((SDL_VideoData *) _this->driverdata)->display;
    3.17      GLXContext glx_context = (GLXContext) context;
    3.18  
    3.19 +    if (!_this->gl_data) {
    3.20 +        return;
    3.21 +    }
    3.22      _this->gl_data->glXDestroyContext(display, glx_context);
    3.23      XSync(display, False);
    3.24  }
     4.1 --- a/src/video/x11/SDL_x11opengles.c	Sun Sep 30 01:01:48 2012 -0700
     4.2 +++ b/src/video/x11/SDL_x11opengles.c	Sun Sep 30 01:08:48 2012 -0700
     4.3 @@ -358,6 +358,11 @@
     4.4  //    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     4.5  //    Display *display = data->videodata->display;
     4.6  
     4.7 +    if (!_this->gles_data) {
     4.8 +        SDL_SetError("OpenGL not initialized");
     4.9 +        return -1;
    4.10 +    }
    4.11 +
    4.12      retval = 1;
    4.13      if (!_this->gles_data->eglMakeCurrent(_this->gles_data->egl_display,
    4.14                                            _this->gles_data->egl_surface,
    4.15 @@ -412,32 +417,33 @@
    4.16  X11_GLES_DeleteContext(_THIS, SDL_GLContext context)
    4.17  {
    4.18      /* Clean up GLES and EGL */
    4.19 -    if (_this->gles_data) {  
    4.20 -        if (_this->gles_data->egl_context != EGL_NO_CONTEXT ||
    4.21 -            _this->gles_data->egl_surface != EGL_NO_SURFACE) {
    4.22 -            _this->gles_data->eglMakeCurrent(_this->gles_data->egl_display,
    4.23 -                                             EGL_NO_SURFACE, EGL_NO_SURFACE,
    4.24 -                                             EGL_NO_CONTEXT);
    4.25 +    if (!_this->gles_data) {  
    4.26 +        return;
    4.27 +    }
    4.28  
    4.29 -            if (_this->gles_data->egl_context != EGL_NO_CONTEXT) {
    4.30 -                _this->gles_data->eglDestroyContext(_this->gles_data->egl_display,
    4.31 -                                                    _this->gles_data->
    4.32 -                                                    egl_context);
    4.33 -                _this->gles_data->egl_context = EGL_NO_CONTEXT;
    4.34 -            }
    4.35 +    if (_this->gles_data->egl_context != EGL_NO_CONTEXT ||
    4.36 +        _this->gles_data->egl_surface != EGL_NO_SURFACE) {
    4.37 +        _this->gles_data->eglMakeCurrent(_this->gles_data->egl_display,
    4.38 +                                         EGL_NO_SURFACE, EGL_NO_SURFACE,
    4.39 +                                         EGL_NO_CONTEXT);
    4.40  
    4.41 -            if (_this->gles_data->egl_surface != EGL_NO_SURFACE) {
    4.42 -                _this->gles_data->eglDestroySurface(_this->gles_data->egl_display,
    4.43 -                                                    _this->gles_data->
    4.44 -                                                    egl_surface);
    4.45 -                _this->gles_data->egl_surface = EGL_NO_SURFACE;
    4.46 -            }
    4.47 +        if (_this->gles_data->egl_context != EGL_NO_CONTEXT) {
    4.48 +            _this->gles_data->eglDestroyContext(_this->gles_data->egl_display,
    4.49 +                                                _this->gles_data->
    4.50 +                                                egl_context);
    4.51 +            _this->gles_data->egl_context = EGL_NO_CONTEXT;
    4.52          }
    4.53  
    4.54 -        /* crappy fix */
    4.55 -        X11_GLES_UnloadLibrary(_this);
    4.56 +        if (_this->gles_data->egl_surface != EGL_NO_SURFACE) {
    4.57 +            _this->gles_data->eglDestroySurface(_this->gles_data->egl_display,
    4.58 +                                                _this->gles_data->
    4.59 +                                                egl_surface);
    4.60 +            _this->gles_data->egl_surface = EGL_NO_SURFACE;
    4.61 +        }
    4.62      }
    4.63  
    4.64 +    /* crappy fix */
    4.65 +    X11_GLES_UnloadLibrary(_this);
    4.66  }
    4.67  
    4.68  #endif /* SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES */