[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58640] branches/soc-2013-viewport_fx: started implementation of GHOST_ContextWGL.cpp.

Jason Wilkins Jason.A.Wilkins at gmail.com
Sat Jul 27 02:55:20 CEST 2013


Revision: 58640
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58640
Author:   jwilkins
Date:     2013-07-27 00:55:20 +0000 (Sat, 27 Jul 2013)
Log Message:
-----------
started implementation of GHOST_ContextWGL.cpp.  (Incomplete)

Modified Paths:
--------------
    branches/soc-2013-viewport_fx/extern/glew-es/include/GL/eglew.h
    branches/soc-2013-viewport_fx/extern/glew-es/src/glew.c
    branches/soc-2013-viewport_fx/intern/ghost/CMakeLists.txt
    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/extern/glew-es/include/GL/eglew.h
===================================================================
--- branches/soc-2013-viewport_fx/extern/glew-es/include/GL/eglew.h	2013-07-27 00:47:41 UTC (rev 58639)
+++ branches/soc-2013-viewport_fx/extern/glew-es/include/GL/eglew.h	2013-07-27 00:55:20 UTC (rev 58640)
@@ -1366,7 +1366,7 @@
 #define EGLEW_GET_VAR(x) (*(const GLboolean*)&x)
 #define EGLEW_GET_FUN(x) x
 
-extern GLenum eglewContextInit (EGLDisplay display); // XXX jwilkins: context handling not really written yet?
+extern GLenum eglewContextInit(); // XXX jwilkins: context handling not really written yet?
 #define eglewInit eglewContextInit // XXX jwilkins:  context handling not really written yet?
 
 extern GLboolean eglewIsSupported (const char* name);

Modified: branches/soc-2013-viewport_fx/extern/glew-es/src/glew.c
===================================================================
--- branches/soc-2013-viewport_fx/extern/glew-es/src/glew.c	2013-07-27 00:47:41 UTC (rev 58639)
+++ branches/soc-2013-viewport_fx/extern/glew-es/src/glew.c	2013-07-27 00:55:20 UTC (rev 58640)
@@ -93,7 +93,7 @@
 #      define GLXEW_CONTEXT_ARG_DEF_LIST GLXEWContext* ctx
 #    endif
 #  endif /* _WIN32 */
-#  define GLEW_CONTEXT_ARG_DEF_LIST EGLDisplay display, GLEWContext* ctx
+#  define GLEW_CONTEXT_ARG_DEF_LIST GLEWContext* ctx
 #else /* GLEW_MX */
 #  define GLEW_CONTEXT_ARG_DEF_INIT void
 #  define GLEW_CONTEXT_ARG_VAR_INIT
@@ -103,7 +103,7 @@
 #  define GLXEW_CONTEXT_ARG_DEF_INIT void
 #  define GLXEW_CONTEXT_ARG_DEF_LIST void
 #  define EGLEW_CONTEXT_ARG_DEF_INIT void
-#  define EGLEW_CONTEXT_ARG_DEF_LIST EGLDisplay display
+#  define EGLEW_CONTEXT_ARG_DEF_LIST void
 #endif /* GLEW_MX */
 
 #if defined(GLEW_USE_LIB_ES)
@@ -14353,6 +14353,7 @@
   GLint major, minor;
   const GLubyte* extStart;
   const GLubyte* extEnd;
+  EGLDisplay display = eglGetCurrentDisplay();
   s = (GLubyte*)eglQueryString(display , EGL_VERSION);
   dot = _glewStrCLen(s, '.');
   if (dot == 0)

Modified: branches/soc-2013-viewport_fx/intern/ghost/CMakeLists.txt
===================================================================
--- branches/soc-2013-viewport_fx/intern/ghost/CMakeLists.txt	2013-07-27 00:47:41 UTC (rev 58639)
+++ branches/soc-2013-viewport_fx/intern/ghost/CMakeLists.txt	2013-07-27 00:55:20 UTC (rev 58640)
@@ -38,7 +38,7 @@
 	intern/GHOST_Buttons.cpp
 	intern/GHOST_C-api.cpp
 	intern/GHOST_CallbackEventConsumer.cpp
-    intern/GHOST_Context.cpp
+	intern/GHOST_Context.cpp
 	intern/GHOST_ContextNone.cpp
 	intern/GHOST_DisplayManager.cpp
 	intern/GHOST_EventManager.cpp
@@ -66,8 +66,8 @@
 
 	intern/GHOST_Buttons.h
 	intern/GHOST_CallbackEventConsumer.h
-    intern/GHOST_Context.h
-    intern/GHOST_ContextNone.h
+	intern/GHOST_Context.h
+	intern/GHOST_ContextNone.h
 	intern/GHOST_Debug.h
 	intern/GHOST_DisplayManager.h
 	intern/GHOST_Event.h

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-27 00:47:41 UTC (rev 58639)
+++ branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_Context.h	2013-07-27 00:55:20 UTC (rev 58640)
@@ -71,6 +71,12 @@
 	 * \return Indication as to whether removal has succeeded.
 	 */
 	virtual GHOST_TSuccess removeDrawingContext() = 0;
+
+	/**
+	 * Checks if it is OK for a remove the native display
+	 * \return Indication as to whether removal has succeeded.
+	 */
+	virtual GHOST_TSuccess releaseNativeHandles();
 };
 
 

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-27 00:47:41 UTC (rev 58639)
+++ branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.cpp	2013-07-27 00:55:20 UTC (rev 58640)
@@ -42,49 +42,49 @@
 {
 	switch(error) {
 		case EGL_SUCCESS:
-			return "The last function succeeded without error.";
+			return "EGL_SUCCESS: The last function succeeded without error.";
 
 		case EGL_NOT_INITIALIZED:
-			return "EGL is not initialized, or could not be initialized, for the specified EGL display connection.";
+			return "EGL_NOT_INITIALIZED: EGL is not initialized, or could not be initialized, for the specified EGL display connection.";
 
 		case EGL_BAD_ACCESS:
-			return "EGL cannot access a requested resource (for example a context is bound in another thread).";
+			return "EGL_BAD_ALLOC: EGL cannot access a requested resource (for example a context is bound in another thread).";
 
 		case EGL_BAD_ALLOC:
-			return "EGL failed to allocate resources for the requested operation.";
+			return "EGL_BAD_ALLOC: EGL failed to allocate resources for the requested operation.";
 
 		case EGL_BAD_ATTRIBUTE:
-			return "An unrecognized attribute or attribute value was passed in the attribute list.";
+			return "EGL_BAD_ATTRIBUTE: An unrecognized attribute or attribute value was passed in the attribute list.";
 
 		case EGL_BAD_CONTEXT:
-			return "An EGLContext argument does not name a valid EGL rendering context.";
+			return "EGL_BAD_CONTEXT: An EGLContext argument does not name a valid EGL rendering context.";
 
 		case EGL_BAD_CONFIG:
-			return "An EGLConfig argument does not name a valid EGL frame buffer configuration.";
+			return "EGL_BAD_CONFIG: An EGLConfig argument does not name a valid EGL frame buffer configuration.";
 
 		case EGL_BAD_CURRENT_SURFACE:
-			return "The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid.";
+			return "EGL_BAD_CURRENT_SURFACE: The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid.";
 
 		case EGL_BAD_DISPLAY:
-			return "An EGLDisplay argument does not name a valid EGL display connection.";
+			return "EGL_BAD_DISPLAY: An EGLDisplay argument does not name a valid EGL display connection.";
 
 		case EGL_BAD_SURFACE:
-			return "An EGLSurface argument does not name a valid surface (window, pixel buffer or pixmap) configured for GL rendering.";
+			return "EGL_BAD_SURFACE: An EGLSurface argument does not name a valid surface (window, pixel buffer or pixmap) configured for GL rendering.";
 
 		case EGL_BAD_MATCH:
-			return "Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).";
+			return "EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).";
 
 		case EGL_BAD_PARAMETER:
-			return "One or more argument values are invalid.";
+			return "EGL_BAD_PARAMETER: One or more argument values are invalid.";
 
 		case EGL_BAD_NATIVE_PIXMAP:
-			return "A NativePixmapType argument does not refer to a valid native pixmap.";
+			return "EGL_BAD_NATIVE_PIXMAP: A NativePixmapType argument does not refer to a valid native pixmap.";
 
 		case EGL_BAD_NATIVE_WINDOW:
-			return "A NativeWindowType argument does not refer to a valid native window.";
+			return "EGL_BAD_NATIVE_WINDOW: A NativeWindowType argument does not refer to a valid native window.";
 
 		case EGL_CONTEXT_LOST:
-			return "A power management event has occurred. The application must destroy all contexts and reinitialise OpenGL ES state and objects to continue rendering.";
+			return "EGL_CONTEXT_LOST: A power management event has occurred. The application must destroy all contexts and reinitialise OpenGL ES state and objects to continue rendering.";
 
 		default:
 			abort();
@@ -95,15 +95,8 @@
 
 static inline bool egl_chk(bool result, const char* file, int line, const char* text)
 {
-	GLenum error;
-
-	for (;;) {
-		error = eglGetError();
-
-		if (error == EGL_SUCCESS)
-			break;
-
-		fprintf(stderr, "EGL Error: %s\n", get_egl_error_string(error));
+	if (!result) {
+		fprintf(stderr, "EGL Error: %s\n", get_egl_error_string(eglGetError()));
 		fprintf(stderr, "%s(%d): %s\n", file, line, text);
 	}
 
@@ -162,17 +155,28 @@
 
 
 
-GHOST_ContextEGL::GHOST_ContextEGL(EGLenum api, EGLint egl_ContextClientVersion)
-	: m_display(EGL_NO_DISPLAY)
+GHOST_ContextEGL::GHOST_ContextEGL(
+	EGLNativeWindowType  nativeWindow,
+	EGLNativeDisplayType nativeDisplay,
+	EGLenum              api,
+	EGLint               contextClientVersion
+)
+	: m_nativeWindow(nativeWindow)
+	, m_nativeDisplay(nativeDisplay)
+	, m_api(api)
+	, m_contextClientVersion(contextClientVersion)
+	, m_display(EGL_NO_DISPLAY)
 	, m_surface(EGL_NO_SURFACE)
 	, m_context(EGL_NO_CONTEXT)
-	, m_api(api)
-	, m_egl_ContextClientVersion(egl_ContextClientVersion)
 	, m_sharedContext(choose_api(api, s_gl_sharedContext, s_gles_sharedContext, s_vg_sharedContext))
 	, m_sharedCount  (choose_api(api, s_gl_sharedCount,   s_gles_sharedCount,   s_vg_sharedCount))
-{ }
+{
+	assert(m_nativeWindow  != NULL);
+	assert(m_nativeDisplay != NULL);
+}
 
 
+
 GHOST_ContextEGL::~GHOST_ContextEGL()
 {
 	removeDrawingContext();
@@ -201,10 +205,35 @@
 
 
 
+GHOST_TSuccess GHOST_ContextEGL::init_eglew()
+{
+	if (!s_eglewInitialized) {
+		if (eglewInit() == GLEW_OK) {
+			s_eglewInitialized = true;
+			return GHOST_kSuccess;
+		}
+		else {
+			return GHOST_kFailure;
+		}
+	}
+	else {
+		return GHOST_kSuccess;
+	}
+}
+
+
+
 GHOST_TSuccess GHOST_ContextEGL::installDrawingContext(bool stereoVisual, GHOST_TUns16 numOfAASamples)
 {
-	if (stereoVisual)
+	std::vector<EGLint> attrib_list;
+
+	assert(m_nativeWindow  != NULL);
+	assert(m_nativeDisplay != NULL);
+
+	if (stereoVisual) {
+		fprintf(stderr, "Stereo OpenGL ES contexts are not supported.\n");
 		return GHOST_kFailure;
+	}
 
 #if defined(WITH_ANGLE)
 	// d3dcompiler_XX.dll needs to be loaded before ANGLE will work
@@ -218,30 +247,31 @@
 	}
 #endif
 
+	EGLDisplay prev_display = eglGetCurrentDisplay();
+	EGLSurface prev_draw    = eglGetCurrentSurface(EGL_DRAW);
+	EGLSurface prev_read    = eglGetCurrentSurface(EGL_READ);
+	EGLContext prev_context = eglGetCurrentContext();
+
 	m_display = ::eglGetDisplay(m_nativeDisplay);
 
-	if (EGL_CHK(m_display == EGL_NO_DISPLAY))
+	if (!EGL_CHK(m_display != EGL_NO_DISPLAY))
 		return GHOST_kFailure;
 
 	EGLint major, minor;
 
 	if (!EGL_CHK(::eglInitialize(m_display, &major, &minor)))
-		return GHOST_kFailure;
+		goto error;
 
-	printf("EGL %d.%d\n", major, minor);
+	printf("Initialized EGL %d.%d\n", major, minor);
 
-	if (!s_eglewInitialized) {
-		if (eglewInit(m_display) == GLEW_OK) {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list