[Bf-blender-cvs] [991ff32d0b5] temp-drawcontext: GHOST: Style, add comments, and make sure that the system has at least one window

Germano noreply at git.blender.org
Sun Feb 11 21:01:13 CET 2018


Commit: 991ff32d0b56739762e91931399e30f81f1a5571
Author: Germano
Date:   Sun Feb 11 18:00:58 2018 -0200
Branches: temp-drawcontext
https://developer.blender.org/rB991ff32d0b56739762e91931399e30f81f1a5571

GHOST: Style, add comments, and make sure that the system has at least one window

===================================================================

M	intern/ghost/intern/GHOST_ContextWGL.cpp
M	intern/ghost/intern/GHOST_SystemWin32.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp
index e6498f1ffa8..8ca639363f4 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextWGL.cpp
@@ -85,7 +85,6 @@ GHOST_ContextWGL::GHOST_ContextWGL(
       m_dummyVersion(NULL)
 #endif
 {
-	assert(m_hWnd);
 	assert(m_hDC);
 }
 
@@ -109,9 +108,11 @@ GHOST_ContextWGL::~GHOST_ContextWGL()
 	}
 
 #ifndef NDEBUG
-	free((void*)m_dummyRenderer);
-	free((void*)m_dummyVendor);
-	free((void*)m_dummyVersion);
+	if (m_dummyRenderer) {
+		free((void*)m_dummyRenderer);
+		free((void*)m_dummyVendor);
+		free((void*)m_dummyVersion);
+	}
 #endif
 }
 
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 1f1d1461949..0ec1f04b0be 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -312,23 +312,31 @@ GHOST_IWindow *GHOST_SystemWin32::createWindow(
  */
 GHOST_IContext *GHOST_SystemWin32::createOffscreenContext()
 {
-	GHOST_WindowWin32 *ghost_window = (GHOST_WindowWin32 *)(m_windowManager->getWindows()[0]);
-	HWND hWnd = ghost_window->getHWND();
-	HDC hDC = GetDC(hWnd);
+	HDC hDC;
+
+	bool debug_context = false; /* TODO: inform as a parameter */
+
+	/* Get any hDC (it will only be used to keep the context current) */
+	std::vector<GHOST_IWindow *> ghost_windows = m_windowManager->getWindows();
+	if (!ghost_windows.empty()) {
+		GHOST_WindowWin32 * window = (GHOST_WindowWin32 *)ghost_windows[0];
+		hDC = GetDC(window->getHWND());
+//		debug_context = window->m_debug_context;
+	}
+	else {
+		hDC = GetDC(NULL); /* DC for the entire screen! */
+	}
 
 	GHOST_Context *context;
 
 #if defined(WITH_GL_PROFILE_CORE)
 	for (int minor = 5; minor >= 0; --minor) {
 			context = new GHOST_ContextWGL(
-			    false,
-			    true,
-			    0,
-			    hWnd,
-			    hDC,
+			    false, true, 0,
+			    NULL, hDC,
 			    WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
 			    4, minor,
-			    (false ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
+			    (debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
 			    GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
 
 			if (context->initializeDrawingContext()) {
@@ -340,27 +348,21 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext()
 		}
 
 		context = new GHOST_ContextWGL(
-		    false,
-		    true,
-		    0,
-		    hWnd,
-		    hDC,
+		    false, true, 0,
+		    NULL, hDC,
 		    WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
 		    3, 3,
-		    (false ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
+		    (debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
 		    GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
 
 		if (context->initializeDrawingContext()) {
 			return context;
 		}
 		else {
-			MessageBox(
-			        hWnd,
+			GHOST_PRINT(
 			        "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);
-			exit();
+			        "Blender - Unsupported Graphics Driver!");
 			delete context;
 		}
 
@@ -368,14 +370,11 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext()
 		// 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(
-		        false,
-		        true,
-		        0,
-		        hWnd,
-		        NULL,
+		        false, true, 0,
+		        NULL, hDC,
 		        0, // no profile bit
 		        2, 1,
-		        (false ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
+		        (debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
 		        GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
 
 		if (context->initializeDrawingContext()) {



More information about the Bf-blender-cvs mailing list