[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58717] branches/soc-2013-viewport_fx: started working on getting blender to run under the core profile ( with deprecated functions turned off), also sketching out a generic pixel format chooser

Jason Wilkins Jason.A.Wilkins at gmail.com
Mon Jul 29 16:47:24 CEST 2013


Revision: 58717
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58717
Author:   jwilkins
Date:     2013-07-29 14:47:23 +0000 (Mon, 29 Jul 2013)
Log Message:
-----------
started working on getting blender to run under the core profile (with deprecated functions turned off), also sketching out a generic pixel format chooser

Modified Paths:
--------------
    branches/soc-2013-viewport_fx/extern/glew-es/src/glew.c
    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_ContextWGL.cpp
    branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_SystemWin32.cpp
    branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_WindowWin32.cpp
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_extensions.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate_glsl.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_object_gles.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_profile.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_safety.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_safety.h
    branches/soc-2013-viewport_fx/source/blender/windowmanager/intern/wm_window.c

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-29 11:42:23 UTC (rev 58716)
+++ branches/soc-2013-viewport_fx/extern/glew-es/src/glew.c	2013-07-29 14:47:23 UTC (rev 58717)
@@ -409,16 +409,39 @@
  */
 static GLboolean _glewSearchExtension (const char* name, const GLubyte *start, const GLubyte *end)
 {
-  const GLubyte* p;
-  GLuint len = _glewStrLen((const GLubyte*)name);
-  p = start;
-  while (p < end)
-  {
-    GLuint n = _glewStrCLen(p, ' ');
-    if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE;
-    p += n+1;
-  }
-  return GL_FALSE;
+	if (start != NULL) {
+	  const GLubyte* p;
+	  GLuint len = _glewStrLen((const GLubyte*)name);
+	  p = start;
+	  while (p < end)
+	  {
+		GLuint n = _glewStrCLen(p, ' ');
+		if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE;
+		p += n+1;
+	  }
+	  return GL_FALSE;
+	}
+	else { // XXX jwilkins: unified extension string is deprecated
+		GLEW_FUN_EXPORT PFNGLGETSTRINGIPROC pglGetStringi = glewGetProcAddress("glGetStringi");
+
+		int max = 0;
+		glGetIntegerv(GL_NUM_EXTENSIONS, &max);
+
+		if (pglGetStringi != NULL) {
+			const char* ext;
+			int i;
+			GLuint len = _glewStrLen((const GLubyte*)name);
+
+			for (i = 0; i < max; i++) {
+				ext = pglGetStringi(GL_EXTENSIONS, i);
+
+				if (_glewStrSame((const GLubyte*)name, ext, len))
+					return GL_TRUE;
+			}
+		}
+	}
+
+	return GL_FALSE;
 }
 
 #if !defined(_WIN32) || !defined(GLEW_MX)
@@ -11775,10 +11798,16 @@
   }		                     
 
   /* query opengl extensions string */
-  extStart = glGetString(GL_EXTENSIONS);
-  if (extStart == 0)
-    extStart = (const GLubyte*)"";
-  extEnd = extStart + _glewStrLen(extStart);
+  if (!GLEW_VERSION_3_0) {
+	  extStart = glGetString(GL_EXTENSIONS);
+	  if (extStart == 0)
+		extStart = (const GLubyte*)"";
+	  extEnd = extStart + _glewStrLen(extStart);
+  }
+  else { // XXX jwilkins: unified extension string is deprecated
+	  extStart = 0;
+	  extEnd   = 0;
+  }
 
   /* initialize extensions */
 #ifdef GL_VERSION_1_1

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-29 11:42:23 UTC (rev 58716)
+++ branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_Context.cpp	2013-07-29 14:47:23 UTC (rev 58717)
@@ -44,33 +44,33 @@
 const char* get_glew_error_message_string(GLenum error)
 {
 	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;
-	}
+		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;
+	}
 }
 
 
@@ -78,33 +78,33 @@
 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;
-	}
+		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;
+	}
 }
 
 
@@ -123,15 +123,15 @@
 			line,
 			text,
 			error,
-			code ? code : "<Unknown>",
-			msg  ? msg  : "<Unknown>");
+			code ? code : "<no symbol>",
+			msg  ? msg  : "<no message>");
 #else
 		fprintf(
 			stderr,
 			"GLEW Error (%04X): %s: %s\n",
 			error,
-			code ? code : "<Unknown>",
-			msg  ? msg  : "<Unknown>");
+			code ? code : "<no symbol>",
+			msg  ? msg  : "<no message>");
 #endif
 	}
 
@@ -150,3 +150,21 @@
 
 	GLEW_CHK(glewInit());
 }
+
+
+
+int GHOST_PixelFormat::computeWeight() const
+{
+}
+
+
+
+void GHOST_PixelFormat::print() const
+{
+}
+
+
+
+int GHOST_ChoosePixelFormat(GHOST_PixelFormatFactory& factory)
+{
+}

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-29 11:42:23 UTC (rev 58716)
+++ branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_Context.h	2013-07-29 14:47:23 UTC (rev 58717)
@@ -111,4 +111,39 @@
 
 
 
+class GHOST_PixelFormat {
+public:
+	enum swap_t { UNKNOWN, COPY, EXCHANGE, UNDEFINED };
+
+	virtual bool   isUsable()     const = 0;
+	virtual int    colorBits()    const = 0;
+	virtual int    alphaBits()    const = 0;
+	virtual int    depthBits()    const = 0;
+	virtual int    stencilBits()  const = 0;
+	virtual int    samples()      const = 0;
+	virtual bool   sRGB()         const = 0;
+	virtual swap_t swapMethod()   const = 0;
+
+	int computeWeight() const;
+
+	void print() const;
+};
+
+
+
+class GHOST_PixelFormatChooser {
+public:
+	int choosePixelFormat(GHOST_PixelFormatFactory& factory);
+
+protected:
+	virtual int                systemChoosePixelFormat() const = 0;
+	virtual int                count()                   const = 0;
+	virtual GHOST_PixelFormat* get(int i)                const = 0;
+};
+
+
+
+
+
+
 #endif // __GHOST_CONTEXT_H__

Modified: branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextWGL.cpp
===================================================================
--- branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextWGL.cpp	2013-07-29 11:42:23 UTC (rev 58716)
+++ branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextWGL.cpp	2013-07-29 14:47:23 UTC (rev 58717)
@@ -154,6 +154,140 @@
 
 
 
+class GHOST_PixelFormatPFD : public GHOST_PixelFormat {
+public:
+	GHOST_PixelFormatPFD(HDC hDC, int i)
+	{
+		int check = ::DescribePixelFormat(hDC, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+		WIN32_CHK(check != 0);
+	}
+
+	virtual bool isUsable() const
+	{
+		const DWORD love = PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER|PFD_TYPE_RGBA;
+		const DWORD hate = PFD_GENERIC_FORMAT;
+
+		return (love & pfd.dwFlags) == love  &&  !(hate & pfd.dwFlags);
+	}
+
+	virtual swap_t swapMethod() const
+	{
+		if (pfd.dwFlags & PFD_SWAP_COPY)
+			return COPY;
+		else if (pfd.dwFlags & PFD_SWAP_EXCHANGE)
+			return EXCHANGE;
+		else
+			return UNKNOWN;
+	}
+
+	virtual int    colorBits()    const { return pfd.cColorBits;   }
+	virtual int    alphaBits()    const { return pfd.cAlphaBits;   }
+	virtual int    depthBits()    const { return pfd.cDepthBits;   }
+	virtual int    stencilBits()  const { return pfd.cStencilBits; }
+	virtual int    samples()      const { return 0;                }
+	virtual bool   sRGB()         const { return false;            }
+
+private:
+	PIXELFORMATDESCRIPTOR pfd;
+};
+
+
+
+class GHOST_PixelFormatARB : public GHOST_PixelFormat {
+public:
+	GHOST_PixelFormatARB(HDC hDC, int iPixelFormat)
+	{
+		valid = ::wglGetPixelFormatAttribivARB(hDC, iPixelFormat, 0, nAttributes, iAttributes, value);
+
+		WIN32_CHK(valid);
+
+		if (WGLEW_ARB_multisample) {
+			int attribute = WGL_SAMPLES_ARB;
+
+			BOOL check = ::wglGetPixelFormatAttribivARB(hDC, iPixelFormat, 0, 1, &attribute, &_samples);
+
+			if (!check)
+				_samples = 0;
+		}
+		else {
+			_samples = 0;
+		}
+
+		if (WGL_ARB_framebuffer_sRGB) {
+			int attribute = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB;
+
+			BOOL check = ::wglGetPixelFormatAttribivARB(hDC, iPixelFormat, 0, 1, &attribute, &_sRGB);
+
+			if (!check)
+				_sRGB = false;
+		}
+		else {
+			_sRGB = false;
+		}
+	}
+
+	virtual bool   isUsable()     const
+	{
+		return
+			valid                                 &&
+			value[0] /* draw to window */         &&
+			value[1] == WGL_FULL_ACCELERATION_ARB &&
+			value[3] /* support opengl */         &&
+			value[4] /* double buffer  */         &&
+			value[6] == WGL_TYPE_RGBA_ARB;
+	}
+
+	virtual swap_t swapMethod() const
+	{
+		switch (value[2]) {
+			case WGL_SWAP_EXCHANGE_ARB:
+				return EXCHANGE;
+
+			case WGL_SWAP_COPY_ARB:
+				return COPY;
+
+			case WGL_SWAP_UNDEFINED_ARB:
+				return UNDEFINED;
+
+			default:
+				return UNKNOWN;
+		}
+	}
+
+	virtual int    colorBits()    const { return value[ 7]; }
+	virtual int    alphaBits()    const { return value[ 8]; }
+	virtual int    depthBits()    const { return value[ 9]; }
+	virtual int    stencilBits()  const { return value[10]; }
+	virtual int    samples()      const { return _samples;  }
+	virtual bool   sRGB()         const { return _sRGB;     }
+
+private:
+	static const int nAttributes = 11;
+	static const int iAttributes[nAttributes];
+
+	bool valid;
+	int value[nAttributes];
+	int _samples;
+	int _sRGB;
+};
+

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list