Merge branch 'blender2.7'
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 14 Jan 2019 11:43:34 +0000 (12:43 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 14 Jan 2019 11:43:34 +0000 (12:43 +0100)
1  2 
intern/ghost/intern/GHOST_WindowWin32.cpp

@@@ -190,7 -190,24 +190,24 @@@ GHOST_WindowWin32::GHOST_WindowWin32(GH
                    0);                         // pointer to window-creation data
                free(title_16);
        }
+       m_user32 = ::LoadLibrary("user32.dll");
        if (m_hWnd) {
+               if (m_user32) {
+                       // Touch enabled screens with pen support by default have gestures
+                       // enabled, which results in a delay between the pointer down event
+                       // and the first move when using the stylus. RegisterTouchWindow
+                       // disables the new gesture architecture enabling the events to be
+                       // sent immediately to the application rather than being absorbed by
+                       // the gesture API.
+                       GHOST_WIN32_RegisterTouchWindow pRegisterTouchWindow =
+                               (GHOST_WIN32_RegisterTouchWindow)GetProcAddress(m_user32, "RegisterTouchWindow");
+                       if (pRegisterTouchWindow) {
+                               pRegisterTouchWindow(m_hWnd, 0);
+                       }
+               }
                // Register this window as a droptarget. Requires m_hWnd to be valid.
                // Note that OleInitialize(0) has to be called prior to this. Done in GHOST_SystemWin32.
                m_dropTarget = new GHOST_DropTargetWin32(this, m_system);
@@@ -368,6 -385,11 +385,11 @@@ GHOST_WindowWin32::~GHOST_WindowWin32(
                ::DestroyWindow(m_hWnd);
                m_hWnd = 0;
        }
+       if (m_user32) {
+               FreeLibrary(m_user32);
+               m_user32 = NULL;
+       }
  }
  
  bool GHOST_WindowWin32::getValid() const
@@@ -629,79 -651,101 +651,79 @@@ GHOST_TSuccess GHOST_WindowWin32::inval
  GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType type)
  {
        if (type == GHOST_kDrawingContextTypeOpenGL) {
 -#if !defined(WITH_GL_EGL)
 +              GHOST_Context *context;
  
  #if defined(WITH_GL_PROFILE_CORE)
 -              GHOST_Context *context = new GHOST_ContextWGL(
 -                      m_wantStereoVisual,
 -                      m_wantAlphaBackground,
 -                      m_wantNumOfAASamples,
 -                      m_hWnd,
 -                      m_hDC,
 -                      WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
 -                      3, 2,
 -                      GHOST_OPENGL_WGL_CONTEXT_FLAGS,
 -                      GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
 -#elif defined(WITH_GL_PROFILE_ES20)
 -              GHOST_Context *context = new GHOST_ContextWGL(
 -                      m_wantStereoVisual,
 -                      m_wantAlphaBackground,
 -                      m_wantNumOfAASamples,
 -                      m_hWnd,
 -                      m_hDC,
 -                      WGL_CONTEXT_ES2_PROFILE_BIT_EXT,
 -                      2, 0,
 -                      GHOST_OPENGL_WGL_CONTEXT_FLAGS,
 -                      GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
 +              /* - AMD and Intel give us exactly this version
 +               * - NVIDIA gives at least this version <-- desired behavior
 +               * So we ask for 4.5, 4.4 ... 3.3 in descending order to get the best version on the user's system. */
 +              for (int minor = 5; minor >= 0; --minor) {
 +                      context = new GHOST_ContextWGL(
 +                          m_wantStereoVisual,
 +                          m_wantAlphaBackground,
 +                          m_wantNumOfAASamples,
 +                          m_hWnd,
 +                          m_hDC,
 +                          WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
 +                          4, minor,
 +                          (m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
 +                          GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
 +
 +                      if (context->initializeDrawingContext()) {
 +                              return context;
 +                      }
 +                      else {
 +                              delete context;
 +                      }
 +              }
 +              context = new GHOST_ContextWGL(
 +                  m_wantStereoVisual,
 +                  m_wantAlphaBackground,
 +                  m_wantNumOfAASamples,
 +                  m_hWnd,
 +                  m_hDC,
 +                  WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
 +                  3, 3,
 +                  (m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
 +                  GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
 +
 +              if (context->initializeDrawingContext()) {
 +                      return context;
 +              }
 +              else {
 +                      MessageBox(
 +                              m_hWnd,
 +                              "Blender requires a graphics driver with at least OpenGL 3.3 support.\n\n"
 +                              "The program will now close.",
 +                              "Blender - Unsupported Graphics Driver",
 +                              MB_OK | MB_ICONERROR);
 +                      delete context;
 +                      exit(0);
 +              }
 +
  #elif defined(WITH_GL_PROFILE_COMPAT)
 -              GHOST_Context *context = new GHOST_ContextWGL(
 +              // ask for 2.1 context, driver gives any GL version >= 2.1 (hopefully the latest compatibility profile)
 +              // 2.1 ignores the profile bit & is incompatible with core profile
 +              context = new GHOST_ContextWGL(
                        m_wantStereoVisual,
                        m_wantAlphaBackground,
                        m_wantNumOfAASamples,
                        m_hWnd,
                        m_hDC,
 -#if 1
 -                      0, // profile bit
 -                      2, 1, // GL version requested
 -#else
 -                      // switch to this for Blender 2.8 development
 -                      WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
 -                      3, 2,
 -#endif
 +                      0, // no profile bit
 +                      2, 1,
                        (m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
                        GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
 -#else
 -#  error
 -#endif
 -
 -#else
  
 -#if defined(WITH_GL_PROFILE_CORE)
 -              GHOST_Context *context = new GHOST_ContextEGL(
 -                      m_wantStereoVisual,
 -                      m_wantNumOfAASamples,
 -                      m_hWnd,
 -                      m_hDC,
 -                      EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
 -                      3, 2,
 -                      GHOST_OPENGL_EGL_CONTEXT_FLAGS,
 -                      GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
 -                      EGL_OPENGL_API);
 -#elif defined(WITH_GL_PROFILE_ES20)
 -              GHOST_Context *context = new GHOST_ContextEGL(
 -                      m_wantStereoVisual,
 -                      m_wantNumOfAASamples,
 -                      m_hWnd,
 -                      m_hDC,
 -                      0, // profile bit
 -                      2, 0,
 -                      GHOST_OPENGL_EGL_CONTEXT_FLAGS,
 -                      GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
 -                      EGL_OPENGL_ES_API);
 -#elif defined(WITH_GL_PROFILE_COMPAT)
 -              GHOST_Context *context = new GHOST_ContextEGL(
 -                      m_wantStereoVisual,
 -                      m_wantNumOfAASamples,
 -                      m_hWnd,
 -                      m_hDC,
 -#if 1
 -                      0, // profile bit
 -                      2, 1, // GL version requested
 -#else
 -                      // switch to this for Blender 2.8 development
 -                      EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT,
 -                      3, 2,
 -#endif
 -                      GHOST_OPENGL_EGL_CONTEXT_FLAGS,
 -                      GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
 -                      EGL_OPENGL_API);
 -#else
 -#  error
 -#endif
 -
 -#endif
 -              if (context->initializeDrawingContext())
 +              if (context->initializeDrawingContext()) {
                        return context;
 -              else
 +              }
 +              else {
                        delete context;
 +              }
 +#else
 +#  error // must specify either core or compat at build time
 +#endif
        }
  
        return NULL;
@@@ -976,10 -1020,6 +998,6 @@@ void GHOST_WindowWin32::bringTabletCont
  
  GHOST_TUns16 GHOST_WindowWin32::getDPIHint()
  {
-       if (!m_user32) {
-               m_user32 = ::LoadLibrary("user32.dll");
-       }
        if (m_user32) {
                GHOST_WIN32_GetDpiForWindow fpGetDpiForWindow = (GHOST_WIN32_GetDpiForWindow) ::GetProcAddress(m_user32, "GetDpiForWindow");