Use SDL_GL_DeleteContext instead of Cocoa_GL_DeleteContext for context cleanup

That will make the current context NULL before deleting the context.
main
Sam Lantinga 2023-03-08 01:33:28 -08:00
parent d08338ddc5
commit 04a03a3eec
1 changed files with 6 additions and 6 deletions

View File

@ -377,8 +377,8 @@ SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window *window)
interval = 0; interval = 0;
[context setValues:&interval forParameter:NSOpenGLCPSwapInterval]; [context setValues:&interval forParameter:NSOpenGLCPSwapInterval];
if (Cocoa_GL_MakeCurrent(_this, window, (__bridge SDL_GLContext)context) < 0) { if (Cocoa_GL_MakeCurrent(_this, window, sdlcontext) < 0) {
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); SDL_GL_DeleteContext(sdlcontext);
SDL_SetError("Failed making OpenGL context current"); SDL_SetError("Failed making OpenGL context current");
return NULL; return NULL;
} }
@ -392,27 +392,27 @@ SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window *window)
glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum))SDL_GL_GetProcAddress("glGetString"); glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum))SDL_GL_GetProcAddress("glGetString");
if (!glGetStringFunc) { if (!glGetStringFunc) {
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); SDL_GL_DeleteContext(sdlcontext);
SDL_SetError("Failed getting OpenGL glGetString entry point"); SDL_SetError("Failed getting OpenGL glGetString entry point");
return NULL; return NULL;
} }
glversion = (const char *)glGetStringFunc(GL_VERSION); glversion = (const char *)glGetStringFunc(GL_VERSION);
if (glversion == NULL) { if (glversion == NULL) {
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); SDL_GL_DeleteContext(sdlcontext);
SDL_SetError("Failed getting OpenGL context version"); SDL_SetError("Failed getting OpenGL context version");
return NULL; return NULL;
} }
if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) { if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) {
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); SDL_GL_DeleteContext(sdlcontext);
SDL_SetError("Failed parsing OpenGL context version"); SDL_SetError("Failed parsing OpenGL context version");
return NULL; return NULL;
} }
if ((glversion_major < _this->gl_config.major_version) || if ((glversion_major < _this->gl_config.major_version) ||
((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) { ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) {
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context); SDL_GL_DeleteContext(sdlcontext);
SDL_SetError("Failed creating OpenGL context at version requested"); SDL_SetError("Failed creating OpenGL context at version requested");
return NULL; return NULL;
} }