[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58697] branches/soc-2013-viewport_fx: A lot of misc.

Jason Wilkins Jason.A.Wilkins at gmail.com
Sun Jul 28 20:22:08 CEST 2013


Revision: 58697
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58697
Author:   jwilkins
Date:     2013-07-28 18:22:08 +0000 (Sun, 28 Jul 2013)
Log Message:
-----------
A lot of misc. stuff with the WGL contexts.

now the GLEW contexts get cleared and get created even if glew fails to initialize them
compatibility, core, and ES profile support
sRGB framebuffer creation
removed dead code from WindowWin32
I'm overthinking the robustness of context creation, need to simplify later

Modified Paths:
--------------
    branches/soc-2013-viewport_fx/CMakeLists.txt
    branches/soc-2013-viewport_fx/extern/glew-es/include/GL/wglew.h
    branches/soc-2013-viewport_fx/intern/ghost/CMakeLists.txt
    branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_Context.cpp
    branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_Context.h
    branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.cpp
    branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.h
    branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextWGL.cpp
    branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextWGL.h
    branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_WindowWin32.cpp

Modified: branches/soc-2013-viewport_fx/CMakeLists.txt
===================================================================
--- branches/soc-2013-viewport_fx/CMakeLists.txt	2013-07-28 17:06:31 UTC (rev 58696)
+++ branches/soc-2013-viewport_fx/CMakeLists.txt	2013-07-28 18:22:08 UTC (rev 58697)
@@ -302,9 +302,6 @@
 option(WITH_GLU "Provide the GL Utility Library (GLU). Only works with the 'compatibiity' profile. (deprecated)" ON)
 mark_as_advanced(WITH_GLU_ES)
 
-option(WITH_GL_SYSTEM_LEGACY "Support using AGL/WGL/XGL system library (without extensions) to initialize OpenGL. Can only access pre 3.1 'legacy' profile. (deprecated)" ON)
-mark_as_advanced(WITH_GL_SYSTEM_LEGACY)
-
 option(WITH_GL_SYSTEM_DESKTOP "Support using the AGL/WGL/XGL system library to initialize OpenGL. Can access 3.1+ core, compatibility, and 2.0 es profiles." OFF)
 mark_as_advanced(WITH_GL_SYSTEM_DESKTOP)
 
@@ -1944,11 +1941,6 @@
 #-----------------------------------------------------------------------------
 # Configure OpenGL.
 
-# sanity checking
-if(WITH_GL_SYSTEM_EMBEDDED AND (WITH_GL_SYSTEM_LEGACY OR WITH_GL_SYSTEM_DESKTOP))
-	message(FATAL_ERROR "WITH_GL_SYSTEM_EMBEDDED cannot be used at the same time as WITH_GL_SYSTEM_LEGACY or WITH_GL_SYSTEM_DESKTOP")
-endif()
-
 # ToDo: Automatically find system OpenGL ES?
 set(OES2_INCLUDE_PATH "" CACHE PATH     "Path to OpenGL ES 2 include files")
 set(OES2_LIBRARY      "" CACHE FILEPATH "OpenGL ES 2 library file")
@@ -1981,7 +1973,7 @@
 	)
 endif()
 
-if(WITH_GL_SYSTEM_LEGACY OR WITH_GL_SYSTEM_DESKTOP)
+if(WITH_GL_SYSTEM_DESKTOP)
 	find_package(OpenGL)
 
 	#set(SYSTEM_GL_INCLUDE_DIR "${OPENGL_INCLUDE_DIR}")
@@ -2017,10 +2009,6 @@
 	set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GL_PROFILE_ES20")
 endif()
 
-if(WITH_GL_SYSTEM_LEGACY)
-	set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GL_SYSTEM_LEGACY")
-endif()
-
 if(WITH_GL_SYSTEM_DESKTOP)
 	set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GL_SYSTEM_DESKTOP")
 endif()
@@ -2469,7 +2457,6 @@
 	info_cfg_text("OpenGL:")
 	info_cfg_option(WITH_GLEW_ES)
 	info_cfg_option(WITH_GLU)
-	info_cfg_option(WITH_GL_SYSTEM_LEGACY)
 	info_cfg_option(WITH_GL_SYSTEM_DESKTOP)
 	info_cfg_option(WITH_GL_SYSTEM_EMBEDDED)
 	info_cfg_option(WITH_GL_PROFILE_COMPAT)

Modified: branches/soc-2013-viewport_fx/extern/glew-es/include/GL/wglew.h
===================================================================
--- branches/soc-2013-viewport_fx/extern/glew-es/include/GL/wglew.h	2013-07-28 17:06:31 UTC (rev 58696)
+++ branches/soc-2013-viewport_fx/extern/glew-es/include/GL/wglew.h	2013-07-28 18:22:08 UTC (rev 58697)
@@ -954,8 +954,8 @@
 #if !defined(WGL_NV_gpu_affinity) 
 #define WGL_NV_gpu_affinity 1
 
-#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0
-#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1
+#define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 // XXX jwilkins: incorrect name
+#define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 // XXX jwilkins: incorrect name
 
 DECLARE_HANDLE(HGPUNV);
 typedef struct _GPU_DEVICE {

Modified: branches/soc-2013-viewport_fx/intern/ghost/CMakeLists.txt
===================================================================
--- branches/soc-2013-viewport_fx/intern/ghost/CMakeLists.txt	2013-07-28 17:06:31 UTC (rev 58696)
+++ branches/soc-2013-viewport_fx/intern/ghost/CMakeLists.txt	2013-07-28 18:22:08 UTC (rev 58697)
@@ -181,18 +181,8 @@
 			
 			intern/GHOST_ContextEGL.h
 		)
-
-		add_definitions(-DWITH_GL_SYSTEM_EMBEDDED)
 	endif()
 
-	if(WITH_GL_SYSTEM_LEGACY)
-		add_definitions(-DWITH_GL_SYSTEM_LEGACY)
-	endif()
-
-	if(WITH_GL_SYSTEM_DESKTOP)
-		add_definitions(-DWITH_GL_SYSTEM_DESKTOP)
-	endif()
-
 	if(APPLE)
 		if(WITH_COCOA)
 			list(APPEND SRC
@@ -207,7 +197,7 @@
 				intern/GHOST_WindowCocoa.h
 			)
 			
-			if (WITH_GL_SYSTEM_LEGACY OR WITH_GL_SYSTEM_DESKTOP)
+			if (WITH_GL_SYSTEM_DESKTOP)
 				list(APPEND SRC
 					intern/GHOST_ContextCGL.mm
 					
@@ -236,7 +226,7 @@
 				intern/GHOST_WindowCarbon.h
 			)
 
-			if (WITH_GL_SYSTEM_LEGACY OR WITH_GL_SYSTEM_DESKTOP)
+			if (WITH_GL_SYSTEM_DESKTOP)
 				list(APPEND SRC
 					intern/GHOST_ContextAGL.cpp
 					
@@ -268,7 +258,7 @@
 			intern/GHOST_WindowX11.h
 		)
 
-		if (WITH_GL_SYSTEM_LEGACY OR WITH_GL_SYSTEM_DESKTOP)
+		if (WITH_GL_SYSTEM_DESKTOP)
 			list(APPEND SRC
 				intern/GHOST_ContextXGL.cpp
 				
@@ -352,7 +342,7 @@
 			intern/GHOST_TaskbarWin32.h
 		)
 
-		if (WITH_GL_SYSTEM_LEGACY OR WITH_GL_SYSTEM_DESKTOP)
+		if (WITH_GL_SYSTEM_DESKTOP)
 			list(APPEND SRC
 				intern/GHOST_ContextWGL.cpp
 				

Modified: branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_Context.cpp
===================================================================
--- branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_Context.cpp	2013-07-28 17:06:31 UTC (rev 58696)
+++ branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_Context.cpp	2013-07-28 18:22:08 UTC (rev 58697)
@@ -32,24 +32,121 @@
 
 #include "GHOST_Context.h"
 
+#include <cstdio>
+#include <cstring>
 
 
+
 GLEWContext* glewContext = NULL;
 
 
 
-bool GHOST_Context::initGlew()
+const char* get_glew_error_message_string(GLenum error)
 {
-	if (m_glewContext == NULL) {
-		glewContext = new GLEWContext;
-		
-		if (glewInit() != GLEW_OK) {
-			delete glewContext;
-			glewContext = NULL;
-		}
+	switch (error) {
+		case GLEW_OK: /* also GLEW_NO_ERROR */
+			return "OK";
+
+		case GLEW_ERROR_NO_GL_VERSION:
+			return "Missing GL version";
+
+		case GLEW_ERROR_GL_VERSION_10_ONLY:
+			return "Need at least OpenGL 1.1";
+
+		case GLEW_ERROR_GLX_VERSION_11_ONLY:
+			return "Need at least GLX 1.2";
+
+		case GLEW_ERROR_NOT_GLES_VERSION:
+			return "Need to be OpenGL ES version";
+
+		case GLEW_ERROR_GLES_VERSION:
+			return "Need to be desktop OpenGL version";
+
+		case GLEW_ERROR_NO_EGL_VERSION:
+			return "Missing EGL version";
+
+		case GLEW_ERROR_EGL_VERSION_10_ONLY:
+			return "Need at least EGL 1.1";
+
+		default:
+			return NULL;
+	}
+}
 
-		m_glewContext = glewContext;
+
+
+const char* get_glew_error_enum_string(GLenum error)
+{
+	switch (error) {
+		case GLEW_OK: /* also GLEW_NO_ERROR */
+			return "GLEW_OK";
+
+		case GLEW_ERROR_NO_GL_VERSION:
+			return "GLEW_ERROR_NO_GL_VERSION";
+
+		case GLEW_ERROR_GL_VERSION_10_ONLY:
+			return "GLEW_ERROR_GL_VERSION_10_ONLY";
+
+		case GLEW_ERROR_GLX_VERSION_11_ONLY:
+			return "GLEW_ERROR_GLX_VERSION_11_ONLY";
+
+		case GLEW_ERROR_NOT_GLES_VERSION:
+			return "GLEW_ERROR_NOT_GLES_VERSION";
+
+		case GLEW_ERROR_GLES_VERSION:
+			return "GLEW_ERROR_GLES_VERSION";
+
+		case GLEW_ERROR_NO_EGL_VERSION:
+			return "GLEW_ERROR_NO_EGL_VERSION";
+
+		case GLEW_ERROR_EGL_VERSION_10_ONLY:
+			return "GLEW_ERROR_EGL_VERSION_10_ONLY";
+
+		default:
+			return NULL;
+	}
+}
+
+
+
+GLenum glew_chk(GLenum error, const char* file, int line, const char* text)
+{
+	if (error != GLEW_OK) {
+		const char* code = get_glew_error_enum_string(error);
+		const char* msg  = get_glew_error_message_string(error);
+
+#ifndef NDEBUG
+		fprintf(
+			stderr,
+			"%s(%d):[%s] -> GLEW Error (0x%04X): %s: %s\n",
+			file,
+			line,
+			text,
+			error,
+			code ? code : "<Unknown>",
+			msg  ? msg  : "<Unknown>");
+#else
+		fprintf(
+			stderr,
+			"GLEW Error (%04X): %s: %s\n",
+			error,
+			code ? code : "<Unknown>",
+			msg  ? msg  : "<Unknown>");
+#endif
 	}
-	
-	return  m_glewContext != NULL ? GHOST_kSuccess : GHOST_kFailure;
+
+	return error;
 }
+
+
+
+void GHOST_Context::initGlew()
+{
+	glewContext = new GLEWContext;
+	memset(glewContext, 0, sizeof(GLEWContext));
+
+	delete m_glewContext;
+	m_glewContext = glewContext;
+
+	GLEW_CHK(glewInit());
+}

Modified: branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_Context.h
===================================================================
--- branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_Context.h	2013-07-28 17:06:31 UTC (rev 58696)
+++ branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_Context.h	2013-07-28 18:22:08 UTC (rev 58697)
@@ -88,7 +88,7 @@
 	virtual GHOST_TSuccess releaseNativeHandles() = 0;
 
 protected:
-	bool GHOST_Context::initGlew();
+	void GHOST_Context::initGlew();
 
 	void GHOST_Context::activateGlew()
 	{
@@ -101,4 +101,14 @@
 
 
 
+GLenum glew_chk(GLenum error, const char* file, int line, const char* text);
+
+#ifndef NDEBUG
+#define GLEW_CHK(x) glew_chk((x), __FILE__, __LINE__, #x)
+#else
+#define GLEW_CHK(x) glew_chk(x)
+#endif
+
+
+
 #endif // __GHOST_CONTEXT_H__

Modified: branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.cpp
===================================================================
--- branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.cpp	2013-07-28 17:06:31 UTC (rev 58696)
+++ branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.cpp	2013-07-28 18:22:08 UTC (rev 58697)
@@ -161,7 +161,7 @@
 #ifndef NDEBUG
 		fprintf(
 			stderr,
-			"%s(%d):[%s] -> EGL Error (%04X): %s: %s\n",
+			"%s(%d):[%s] -> EGL Error (0x%04X): %s: %s\n",
 			file,
 			line,
 			text,
@@ -171,7 +171,7 @@
 #else
 		fprintf(
 			stderr,
-			"EGL Error (%04X): %s: %s\n",
+			"EGL Error (0x%04X): %s: %s\n",
 			error,
 			code ? code : "<Unknown>",
 			msg  ? msg  : "<Unknown>");
@@ -307,20 +307,15 @@
 
 
 
-bool GHOST_ContextEGL::initEGlew()
+void GHOST_ContextEGL::initEGlew()
 {
-	if (m_eglewContext == NULL) {
-		eglewContext = new EGLEWContext;
+	eglewContext = new EGLEWContext;
+	memset(eglewContext, 0, sizeof(EGLEWContext));
 
-		if (eglewInit() != GLEW_OK) {
-			delete eglewContext;
-			eglewContext = NULL;
-		}
+	delete m_eglewContext;
+	m_eglewContext = eglewContext;
 
-		m_eglewContext = eglewContext;
-	}
-
-	return m_eglewContext != NULL;
+	GLEW_CHK(eglewInit());
 }
 
 
@@ -332,10 +327,8 @@
 	assert(m_nativeWindow  != NULL);
 	assert(m_nativeDisplay != NULL);
 
-	if (stereoVisual) {
-		fprintf(stderr, "Stereo OpenGL ES contexts are not supported.\n");
-		return GHOST_kFailure;
-	}
+	if (stereoVisual)
+		fprintf(stderr, "Warning! Stereo OpenGL ES contexts are not supported.\n");
 
 #if defined(WITH_ANGLE)
 	// d3dcompiler_XX.dll needs to be loaded before ANGLE will work
@@ -364,16 +357,13 @@
 	if (!EGL_CHK(::eglInitialize(m_display, &major, &minor)))
 		goto error;
 
-	printf("Initialized EGL %d.%d\n", major, minor);
+	fprintf(stderr, "EGL Version %d.%d\n", major, minor);
 
 	if (!EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)))
 		goto error;
 
-	if (!initEGlew())
-		fprintf(stderr, "EGLEW failed to initialize.\n");
+	initEGlew();
 
-	eglewContext = m_eglewContext;
-
 	bindAPI(m_api);
 
 	attrib_list.reserve(20);


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list