[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58666] branches/soc-2013-viewport_fx: GHOST_ContextWGL in working condition
Jason Wilkins
Jason.A.Wilkins at gmail.com
Sat Jul 27 17:50:24 CEST 2013
Revision: 58666
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58666
Author: jwilkins
Date: 2013-07-27 15:50:23 +0000 (Sat, 27 Jul 2013)
Log Message:
-----------
GHOST_ContextWGL in working condition
Modified Paths:
--------------
branches/soc-2013-viewport_fx/extern/glew-es/include/GL/wglew.h
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_ContextNone.cpp
branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextNone.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_SystemWin32.cpp
branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_Window.cpp
branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_Window.h
branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_WindowWin32.cpp
branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_WindowWin32.h
branches/soc-2013-viewport_fx/source/blender/gpu/CMakeLists.txt
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate.c
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_lighting.c
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_matrix.c
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_safety.h
Added Paths:
-----------
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_safety.c
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-27 14:44:52 UTC (rev 58665)
+++ branches/soc-2013-viewport_fx/extern/glew-es/include/GL/wglew.h 2013-07-27 15:50:23 UTC (rev 58666)
@@ -1406,6 +1406,9 @@
#define WGLEW_GET_VAR(x) (*(const GLboolean*)&x)
#define WGLEW_GET_FUN(x) x
+GLEWAPI GLenum wglewContextInit (void); // XXX jwilkins: Why does this require GLEW_MX? Should I enable GLEW_MX? instead?
+#define wglewInit() wglewContextInit() // XXX jwilkins: Why does this require GLEW_MX? Should I enable GLEW_MX? instead?
+
GLEWAPI GLboolean wglewIsSupported (const char* name);
#endif /* GLEW_MX */
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 14:44:52 UTC (rev 58665)
+++ branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_Context.h 2013-07-27 15:50:23 UTC (rev 58666)
@@ -59,24 +59,18 @@
virtual GHOST_TSuccess activateDrawingContext() = 0;
/**
- * Tries to install a rendering context in this window.
+ * Call immediately after new to initialize. If this fails then immediately delete the object.
* \param stereoVisual Stereo visual for quad buffered stereo.
* \param numOfAASamples Number of samples used for AA (zero if no AA)
- * \return Indication as to whether installation has succeeded.
+ * \return Indication as to whether initialization has succeeded.
*/
- virtual GHOST_TSuccess installDrawingContext(bool stereoVisual = false, GHOST_TUns16 numOfAASamples = 0) = 0;
+ virtual GHOST_TSuccess initializeDrawingContext(bool stereoVisual = false, GHOST_TUns16 numOfAASamples = 0) = 0;
/**
- * Removes the current drawing context.
- * \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();
+ virtual GHOST_TSuccess releaseNativeHandles() = 0;
};
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 14:44:52 UTC (rev 58665)
+++ branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.cpp 2013-07-27 15:50:23 UTC (rev 58666)
@@ -38,74 +38,150 @@
-static const char* get_egl_error_string(EGLenum error)
+static const char* get_egl_error_enum_string(EGLenum error)
{
switch(error) {
case EGL_SUCCESS:
- return "EGL_SUCCESS: The last function succeeded without error.";
+ return "EGL_SUCCESS";
case EGL_NOT_INITIALIZED:
- return "EGL_NOT_INITIALIZED: EGL is not initialized, or could not be initialized, for the specified EGL display connection.";
+ return "EGL_NOT_INITIALIZED";
case EGL_BAD_ACCESS:
- return "EGL_BAD_ALLOC: EGL cannot access a requested resource (for example a context is bound in another thread).";
+ return "EGL_BAD_ALLOC";
case EGL_BAD_ALLOC:
- return "EGL_BAD_ALLOC: EGL failed to allocate resources for the requested operation.";
+ return "EGL_BAD_ALLOC";
case EGL_BAD_ATTRIBUTE:
- return "EGL_BAD_ATTRIBUTE: An unrecognized attribute or attribute value was passed in the attribute list.";
+ return "EGL_BAD_ATTRIBUTE";
case EGL_BAD_CONTEXT:
- return "EGL_BAD_CONTEXT: An EGLContext argument does not name a valid EGL rendering context.";
+ return "EGL_BAD_CONTEXT";
case EGL_BAD_CONFIG:
- return "EGL_BAD_CONFIG: An EGLConfig argument does not name a valid EGL frame buffer configuration.";
+ return "EGL_BAD_CONFIG";
case EGL_BAD_CURRENT_SURFACE:
- return "EGL_BAD_CURRENT_SURFACE: The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid.";
+ return "EGL_BAD_CURRENT_SURFACE";
case EGL_BAD_DISPLAY:
- return "EGL_BAD_DISPLAY: An EGLDisplay argument does not name a valid EGL display connection.";
+ return "EGL_BAD_DISPLAY";
case EGL_BAD_SURFACE:
- return "EGL_BAD_SURFACE: An EGLSurface argument does not name a valid surface (window, pixel buffer or pixmap) configured for GL rendering.";
+ return "EGL_BAD_SURFACE";
case EGL_BAD_MATCH:
- return "EGL_BAD_MATCH: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).";
+ return "EGL_BAD_MATCH";
case EGL_BAD_PARAMETER:
- return "EGL_BAD_PARAMETER: One or more argument values are invalid.";
+ return "EGL_BAD_PARAMETER";
case EGL_BAD_NATIVE_PIXMAP:
- return "EGL_BAD_NATIVE_PIXMAP: A NativePixmapType argument does not refer to a valid native pixmap.";
+ return "EGL_BAD_NATIVE_PIXMAP";
case EGL_BAD_NATIVE_WINDOW:
- return "EGL_BAD_NATIVE_WINDOW: A NativeWindowType argument does not refer to a valid native window.";
+ return "EGL_BAD_NATIVE_WINDOW";
case EGL_CONTEXT_LOST:
- 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.";
+ return "EGL_CONTEXT_LOST";
default:
- abort();
+ return NULL;
}
}
+static const char* get_egl_error_message_string(EGLenum error)
+{
+ switch(error) {
+ case EGL_SUCCESS:
+ return "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.";
-static inline bool egl_chk(bool result, const char* file, int line, const char* text)
+ case EGL_BAD_ACCESS:
+ return "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.";
+
+ case EGL_BAD_ATTRIBUTE:
+ return "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.";
+
+ case EGL_BAD_CONFIG:
+ return "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.";
+
+ case EGL_BAD_DISPLAY:
+ return "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.";
+
+ case EGL_BAD_MATCH:
+ return "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.";
+
+ case EGL_BAD_NATIVE_PIXMAP:
+ return "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.";
+
+ 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.";
+
+ default:
+ return NULL;
+ }
+}
+
+
+
+static bool egl_chk(bool result, const char* file = NULL, int line = 0, const char* text = NULL)
{
if (!result) {
- fprintf(stderr, "EGL Error: %s\n", get_egl_error_string(eglGetError()));
- fprintf(stderr, "%s(%d): %s\n", file, line, text);
+ EGLenum error = eglGetError();
+
+ const char* code = get_egl_error_enum_string(error),
+ const char* msg = get_egl_error_message_string(error);
+
+#ifndef NDEBUG
+ fprintf(
+ stderr,
+ "%s(%d): EGL Error (%4X): %s: %s\n",
+ file,
+ line,
+ text,
+ error,
+ code ? code : "Unknown Code",
+ msg ? msg : "Unknown Error");
+#else
+ fprintf(
+ stderr,
+ "EGL Error (%4X): %s: %s\n",
+ error,
+ code ? code : "Unknown Code",
+ msg ? msg : "Unknown Error");
+#endif
}
return result;
}
-
-
+#ifndef NDEBUG
#define EGL_CHK(x) egl_chk((x), __FILE__, __LINE__, #x)
+#else
+#define EGL_CHK(x) egl_chk(x)
+#endif
@@ -123,10 +199,6 @@
-bool GHOST_ContextEGL::s_eglewInitialized = false;
-
-
-
EGLContext GHOST_ContextEGL::s_gl_sharedContext = NULL;
EGLint GHOST_ContextEGL::s_gl_sharedCount = 0;
@@ -181,9 +253,6 @@
{
removeDrawingContext();
- // Note: If multiple GHOST_ContextEGL are initialized with the same EGLNativeDisplayType then
- // those other GHOST_ContextEGL will become invalid after this call to eglTerminate.
- // See EGL 1.4 spec section 3.2
EGL_CHK(::eglTerminate(m_display));
}
@@ -205,20 +274,14 @@
-GHOST_TSuccess GHOST_ContextEGL::init_eglew()
+static bool init_eglew()
{
- if (!s_eglewInitialized) {
- if (eglewInit() == GLEW_OK) {
- s_eglewInitialized = true;
- return GHOST_kSuccess;
- }
- else {
- return GHOST_kFailure;
- }
- }
- else {
- return GHOST_kSuccess;
- }
+ static bool eglewInitialized = false;
+
+ if (!eglewInitialized && eglewInit() == GLEW_OK)
+ eglewInitialized = true;
+
+ return eglewInitialized;
}
@@ -268,7 +331,7 @@
goto error;
if (!init_eglew())
- goto error;
+ fprintf(stderr, "EGLEW failed to initialize.\n");
bindAPI(m_api);
@@ -323,7 +386,7 @@
attrib_list.clear();
- if (m_api == EGL_OPENGL_ES_API) {
+ if (m_api == EGL_OPENGL_ES_API && m_contextClientVersion != 0) {
attrib_list.push_back(EGL_CONTEXT_CLIENT_VERSION);
attrib_list.push_back(m_contextClientVersion);
}
@@ -351,7 +414,7 @@
EGL_CHK(eglTerminate(m_display));
m_display = EGL_NO_DISPLAY;
- eglMakeCurrent(prev_display, prev_draw, prev_read, prev_context);
+ EGL_CHK(eglMakeCurrent(prev_display, prev_draw, prev_read, prev_context));
return GHOST_kFailure;
}
@@ -362,22 +425,24 @@
{
bindAPI(m_api);
- if (m_context == ::eglGetCurrentContext())
- EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+ if (m_context != EGL_NO_CONTEXT) {
+ if (m_context == ::eglGetCurrentContext())
+ EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
- if (m_context != m_sharedContext || m_sharedCount == 1) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list