src/video/SDL_video.c
changeset 7390 e4b98404baa4
parent 7360 b86947ea2749
child 7399 f35ff854121a
equal deleted inserted replaced
7389:361d1a0c90f6 7390:e4b98404baa4
  2728     ctx = _this->GL_CreateContext(_this, window);
  2728     ctx = _this->GL_CreateContext(_this, window);
  2729 
  2729 
  2730     /* Creating a context is assumed to make it current in the SDL driver. */
  2730     /* Creating a context is assumed to make it current in the SDL driver. */
  2731     _this->current_glwin = window;
  2731     _this->current_glwin = window;
  2732     _this->current_glctx = ctx;
  2732     _this->current_glctx = ctx;
       
  2733     _this->current_glthread = SDL_ThreadID();
  2733 
  2734 
  2734     return ctx;
  2735     return ctx;
  2735 }
  2736 }
  2736 
  2737 
  2737 int
  2738 int
  2738 SDL_GL_MakeCurrent(SDL_Window * window, SDL_GLContext ctx)
  2739 SDL_GL_MakeCurrent(SDL_Window * window, SDL_GLContext ctx)
  2739 {
  2740 {
  2740     int retval;
  2741     int retval;
       
  2742     SDL_threadID thread = SDL_ThreadID();
  2741 
  2743 
  2742     if (!ctx) {
  2744     if (!ctx) {
  2743         window = NULL;
  2745         window = NULL;
  2744     } else {
  2746     } else {
  2745         CHECK_WINDOW_MAGIC(window, -1);
  2747         CHECK_WINDOW_MAGIC(window, -1);
  2747         if (!(window->flags & SDL_WINDOW_OPENGL)) {
  2749         if (!(window->flags & SDL_WINDOW_OPENGL)) {
  2748             return SDL_SetError("The specified window isn't an OpenGL window");
  2750             return SDL_SetError("The specified window isn't an OpenGL window");
  2749         }
  2751         }
  2750     }
  2752     }
  2751 
  2753 
  2752     if ((window == _this->current_glwin) && (ctx == _this->current_glctx)) {
  2754     if ((window == _this->current_glwin) && (ctx == _this->current_glctx) && (thread == _this->current_glthread)) {
  2753         retval = 0;  /* we're already current. */
  2755         retval = 0;  /* we're already current. */
  2754     } else {
  2756     } else {
  2755         retval = _this->GL_MakeCurrent(_this, window, ctx);
  2757         retval = _this->GL_MakeCurrent(_this, window, ctx);
  2756         if (retval == 0) {
  2758         if (retval == 0) {
  2757             _this->current_glwin = window;
  2759             _this->current_glwin = window;
  2758             _this->current_glctx = ctx;
  2760             _this->current_glctx = ctx;
       
  2761             _this->current_glthread = thread;
  2759         }
  2762         }
  2760     }
  2763     }
  2761 
  2764 
  2762     return retval;
  2765     return retval;
  2763 }
  2766 }