From e9f192a454935bf53eeb342d224098bcfe4702dd Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 15 Aug 2007 03:52:31 +0000 Subject: [PATCH] Optimization suggested by Ryan: Don't set the same OpenGL context multiple times --- src/video/SDL_sysvideo.h | 1 + src/video/SDL_video.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 32896d44a..f4306fa48 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -126,6 +126,7 @@ struct SDL_Window int display; SDL_Renderer *renderer; + SDL_GLContext context; void *userdata; void *driverdata; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 9801572a1..e535539ec 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -2566,6 +2566,12 @@ SDL_GL_MakeCurrent(SDL_WindowID windowID, SDL_GLContext context) if (!context) { window = NULL; } + if (window) { + if (window->context == context) { + return 0; + } + window->context = context; + } return _this->GL_MakeCurrent(_this, window, context); }