[Bf-blender-cvs] [0f1cac0] soc-2013-viewport_fx: stub version of refactored GHOST for OSX Cocoa CGL
Jason Wilkins
noreply at git.blender.org
Wed Feb 19 18:12:23 CET 2014
Commit: 0f1cac0d872669c77deac859621d217c18db86fd
Author: Jason Wilkins
Date: Tue Feb 18 19:52:25 2014 -0600
https://developer.blender.org/rB0f1cac0d872669c77deac859621d217c18db86fd
stub version of refactored GHOST for OSX Cocoa CGL
===================================================================
M intern/ghost/intern/GHOST_ContextCGL.h
M intern/ghost/intern/GHOST_ContextCGL.mm
M intern/ghost/intern/GHOST_ContextWGL.h
M intern/ghost/intern/GHOST_Window.h
M intern/ghost/intern/GHOST_WindowCocoa.h
M intern/ghost/intern/GHOST_WindowCocoa.mm
===================================================================
diff --git a/intern/ghost/intern/GHOST_ContextCGL.h b/intern/ghost/intern/GHOST_ContextCGL.h
index aec6872..c0c680c 100644
--- a/intern/ghost/intern/GHOST_ContextCGL.h
+++ b/intern/ghost/intern/GHOST_ContextCGL.h
@@ -34,4 +34,61 @@
#define __GHOST_CONTEXTCGL_H__
+#include "GHOST_Context.h"
+
+
+
+#ifndef GHOST_OPENGL_CGL_CONTEXT_FLAGS
+#define GHOST_OPENGL_CGL_CONTEXT_FLAGS 0
+#endif
+
+
+
+class GHOST_ContextCGL : public GHOST_Context
+{
+public:
+ /**
+ * Constructor.
+ */
+ GHOST_ContextCGL(
+ int contextProfileMask = 0,
+ int contextMajorVersion = 0,
+ int contextMinorVersion = 0,
+ int contextFlags = GHOST_OPENGL_CGL_CONTEXT_FLAGS);
+
+ /**
+ * Destructor.
+ */
+ virtual ~GHOST_ContextCGL();
+
+ /**
+ * Swaps front and back buffers of a window.
+ * \return A boolean success indicator.
+ */
+ virtual GHOST_TSuccess swapBuffers();
+
+ /**
+ * Activates the drawing context of this window.
+ * \return A boolean success indicator.
+ */
+ virtual GHOST_TSuccess activateDrawingContext();
+
+ /**
+ * 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 initialization has succeeded.
+ */
+ virtual GHOST_TSuccess initializeDrawingContext(bool stereoVisual = false, GHOST_TUns16 numOfAASamples = 0);
+
+ /**
+ * Checks if it is OK for a remove the native display
+ * \return Indication as to whether removal has succeeded.
+ */
+ virtual GHOST_TSuccess releaseNativeHandles();
+};
+
+
+
+
#endif // __GHOST_CONTEXTCGL_H__
diff --git a/intern/ghost/intern/GHOST_ContextCGL.mm b/intern/ghost/intern/GHOST_ContextCGL.mm
index 474d7c4..b4e0bae 100644
--- a/intern/ghost/intern/GHOST_ContextCGL.mm
+++ b/intern/ghost/intern/GHOST_ContextCGL.mm
@@ -30,3 +30,50 @@
* Definition of GHOST_ContextCGL class.
*/
+#include "GHOST_ContextCGL.h"
+
+
+
+GHOST_ContextCGL::GHOST_ContextCGL(
+ int contextProfileMask,
+ int contextMajorVersion,
+ int contextMinorVersion,
+ int contextFlags)
+{
+
+}
+
+
+
+GHOST_ContextCGL::~GHOST_ContextCGL()
+{
+
+}
+
+
+
+GHOST_TSuccess GHOST_ContextCGL::swapBuffers()
+{
+ return GHOST_kFailure;
+}
+
+
+
+GHOST_TSuccess GHOST_ContextCGL::activateDrawingContext()
+{
+ return GHOST_kFailure;
+}
+
+
+
+GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext(bool stereoVisual, GHOST_TUns16 numOfAASamples)
+{
+ return GHOST_kFailure;
+}
+
+
+
+GHOST_TSuccess GHOST_ContextCGL::releaseNativeHandles()
+{
+ return GHOST_kFailure;
+}
diff --git a/intern/ghost/intern/GHOST_ContextWGL.h b/intern/ghost/intern/GHOST_ContextWGL.h
index 6b75ace..b82b8e0 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.h
+++ b/intern/ghost/intern/GHOST_ContextWGL.h
@@ -41,8 +41,8 @@ extern "C" WGLEWContext* wglewContext;
-#ifndef GHOST_OPENGL_CONTEXT_FLAGS
-#define GHOST_OPENGL_CONTEXT_FLAGS 0
+#ifndef GHOST_OPENGL_WGL_CONTEXT_FLAGS
+#define GHOST_OPENGL_WGL_CONTEXT_FLAGS 0
#endif
@@ -59,7 +59,7 @@ public:
int contextProfileMask = 0,
int contextMajorVersion = 0,
int contextMinorVersion = 0,
- int contextFlags = GHOST_OPENGL_CONTEXT_FLAGS);
+ int contextFlags = GHOST_OPENGL_WGL_CONTEXT_FLAGS);
/**
* Destructor.
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index 5670846..67fa0d8 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -92,27 +92,6 @@ public:
const GHOST_TUns16 numOfAASamples = 0);
/**
- * \section Interface inherited from GHOST_IWindow left for derived class
- * implementation.
- * virtual bool getValid() const = 0;
- * virtual void setTitle(const STR_String& title) = 0;
- * virtual void getTitle(STR_String& title) const = 0;
- * virtual void getWindowBounds(GHOST_Rect& bounds) const = 0;
- * virtual void getClientBounds(GHOST_Rect& bounds) const = 0;
- * virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width) = 0;
- * virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height) = 0;
- * virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height) = 0;
- * virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
- * virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
- * virtual GHOST_TWindowState getState() const = 0;
- * virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
- * virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
- * virtual GHOST_TSuccess swapBuffers() = 0;
- * virtual GHOST_TSuccess activateDrawingContext() = 0;
- * virtual GHOST_TSuccess invalidate() = 0;
- */
-
- /**
* Destructor.
* Closes the window and disposes resources allocated.
*/
@@ -234,7 +213,7 @@ public:
/**
* Tries to install a rendering context in this window.
- * Child classes do not need to overload this method.
+ * Child classes do not need to overload this method,
* They should overload newDrawingContext instead.
* \param type The type of rendering context installed.
* \return Indication as to whether installation has succeeded.
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.h b/intern/ghost/intern/GHOST_WindowCocoa.h
index fe0830e..83aaa37 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.h
+++ b/intern/ghost/intern/GHOST_WindowCocoa.h
@@ -42,6 +42,9 @@
@class CocoaWindow;
@class CocoaOpenGLView;
+ at class NSCursor;
+ at class NSOpenGLContext;
+ at class NSScreen;
class GHOST_SystemCocoa;
@@ -272,18 +275,24 @@ public:
protected:
- /**
- * Tries to install a rendering context in this window.
- * \param type The type of rendering context installed.
- * \return Indication as to whether installation has succeeded.
- */
- virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
+ ///**
+ // * Tries to install a rendering context in this window.
+ // * \param type The type of rendering context installed.
+ // * \return Indication as to whether installation has succeeded.
+ // */
+ //virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
/**
- * Removes the current drawing context.
- * \return Indication as to whether removal has succeeded.
+ * \param type The type of rendering context create.
+ * \return Indication of success.
*/
- virtual GHOST_TSuccess removeDrawingContext();
+ virtual GHOST_Context* newDrawingContext(GHOST_TDrawingContextType type);
+
+ ///**
+ // * Removes the current drawing context.
+ // * \return Indication as to whether removal has succeeded.
+ // */
+ //virtual GHOST_TSuccess removeDrawingContext();
/**
* Invalidates the contents of this window.
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index caa67d9..151c575 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -20,12 +20,26 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): Maarten Gribnau 05/2001
- Damien Plisson 10/2009
+ * Contributor(s): Maarten Gribnau 05/2001
+ * Damien Plisson 10/2009
+ * Jason Wilkins 02/2014
*
* ***** END GPL LICENSE BLOCK *****
*/
+#include "GHOST_WindowCocoa.h"
+#include "GHOST_SystemCocoa.h"
+#include "GHOST_ContextNone.h"
+#include "GHOST_Debug.h"
+
+#if defined(WITH_GL_SYSTEM_DESKTOP)
+#include "GHOST_ContextCGL.h"
+#endif
+
+#if defined(WITH_GL_SYSTEM_EMBEDDED)
+#include "GHOST_ContextEGL.h"
+#endif
+
#include <Cocoa/Cocoa.h>
#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1050
@@ -33,17 +47,14 @@
#include <Carbon/Carbon.h>
#endif
-#include <OpenGL/gl.h>
-#include <OpenGL/CGLRenderers.h>
+//#include <OpenGL/gl.h>
+//#include <OpenGL/CGLRenderers.h>
/***** Multithreaded opengl code : uncomment for enabling
#include <OpenGL/OpenGL.h>
*/
-
-#include "GHOST_WindowCocoa.h"
-#include "GHOST_SystemCocoa.h"
-#include "GHOST_Debug.h"
+
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
/* Lion style fullscreen support when building with the 10.6 SDK */
enum {
@@ -1264,7 +1275,7 @@ GHOST_TSuccess GHOST_WindowCocoa::activateDrawingContext()
return GHOST_kFailure;
}
-
+#if 0
GHOST_TSuccess GHOST_WindowCocoa::installDrawingContext(GHOST_TDrawingContextType type)
{
GHOST_TSuccess success = GHOST_kFailure;
@@ -1344,6 +1355,51 @@ GHOST_TSuccess GHOST_WindowCocoa::removeDrawingContext()
return GHOST_kFailure;
}
}
+#endif
+
+
+
+GHOST_Context* GHOST_WindowCocoa::newDrawingContext(GHOST_TDrawingContextType type)
+{
+ if (type == GHOST_kDrawingContextTypeOpenGL) {
+#if defined(WITH_GL_SYSTEM_DESKTOP)
+
+#if defined(WITH_GL_PROFILE_CORE)
+ // XXX jwilkins: some implementations will only give you 3.2 even if later compatible versions are available
+ GHOST_Context* context = new GHOST_ContextCGL(WGL_CONTEXT_CORE_PROFILE_BIT_ARB, 3, 2);
+#elif defined(WITH_GL_PROFILE_ES20)
+ GHOST_Context* context = new GHOST_ContextCGL(WGL_CONTEXT_ES2_PROFILE_BIT_EXT, 2, 0);
+#elif defined(WITH_GL_PROFILE_COMPAT)
+ GHOST_Context* context = new GHOST_ContextCGL();
+#else
+#error
+#endif
+
+#elif defined(WITH_GL_SYSTEM_EMBEDDED)
+
+#if defined(WITH_GL_PROFILE_CORE)
+ // XXX jwilkins: not sure yet how to request a core context from EGL
+ GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_API);
+#elif defined(WITH_GL_PROFILE_ES20)
+ GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_ES_API, 2);
+#elif defined(WITH_GL_PROFILE_COMPAT)
+ GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_API);
+#else
+#error
+#endif
+
+#else
+#error
+#endif
+ if (context->initializeDrawingContext(m_stereoVisual, m_numOfAASamples))
+ return context;
+ else
+ delete context;
+ }
+
+ return NULL;
+}
+
GHOST_TSuccess GHOST_WindowCocoa::invalidate()
More information about the Bf-blender-cvs
mailing list