Commit: 85fdb5adefd9560885ae66b91687c44e644f6c86
Author: Jason Wilkins
Date:   Wed Jul 9 18:13:49 2014 -0500
https://developer.blender.org/rB85fdb5adefd9560885ae66b91687c44e644f6c86

some readability edits for ghost context classes
also added code to clear screen immediately after context creation, similar to 
how it is done for glX

===================================================================

M       intern/ghost/intern/GHOST_Context.h
M       intern/ghost/intern/GHOST_ContextCGL.h
M       intern/ghost/intern/GHOST_ContextCGL.mm
M       intern/ghost/intern/GHOST_ContextEGL.cpp
M       intern/ghost/intern/GHOST_ContextEGL.h
M       intern/ghost/intern/GHOST_ContextWGL.cpp
M       intern/ghost/intern/GHOST_ContextWGL.h
M       intern/ghost/intern/GHOST_WindowCocoa.mm
M       intern/ghost/intern/GHOST_WindowWin32.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_Context.h 
b/intern/ghost/intern/GHOST_Context.h
index d545e11..37c202d 100644
--- a/intern/ghost/intern/GHOST_Context.h
+++ b/intern/ghost/intern/GHOST_Context.h
@@ -129,7 +129,7 @@ public:
 protected:
        void initContextGLEW();
 
-       void activateGLEW() const {
+       inline void activateGLEW() const {
                glewSetContext(m_glewContext);
        }
 
diff --git a/intern/ghost/intern/GHOST_ContextCGL.h 
b/intern/ghost/intern/GHOST_ContextCGL.h
index 8da6fab..1ea9e28 100644
--- a/intern/ghost/intern/GHOST_ContextCGL.h
+++ b/intern/ghost/intern/GHOST_ContextCGL.h
@@ -15,7 +15,7 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * The Original Code is Copyright (C) 2013 Blender Foundation.
+ * The Original Code is Copyright (C) 2014 Blender Foundation.
  * All rights reserved.
  *
  * The Original Code is: all of this file.
@@ -30,17 +30,14 @@
  * Declaration of GHOST_ContextCGL class.
  */
 
-#ifndef __GHOST_CONTEXTCGL_H__
-#define __GHOST_CONTEXTCGL_H__
-
+#ifndef _GHOST_CONTEXTCGL_H_
+#define _GHOST_CONTEXTCGL_H_
 
 #include "GHOST_Context.h"
 
-
-
-@class NSWindow;
-@class NSOpenGLView;
-@class NSOpenGLContext;
+//#define cglewGetContext() cglewContext
+//#include <GL/cglew.h>
+//extern "C" CGLEWContext* cglewContext;
 
 
 
@@ -54,6 +51,12 @@
 
 
 
+@class NSWindow;
+@class NSOpenGLView;
+@class NSOpenGLContext;
+
+
+
 class GHOST_ContextCGL : public GHOST_Context
 {
 public:
@@ -97,15 +100,8 @@ public:
        virtual GHOST_TSuccess initializeDrawingContext();
 
        /**
-        * Updates the drawing context of this window. Needed
-        * whenever the window is changed.
-        * \return Indication of success.
-        */
-       virtual GHOST_TSuccess updateDrawingContext();
-
-       /**
-        * Checks if it is OK for a remove the native display
-        * \return Indication as to whether removal has succeeded.
+        * Removes references to native handles from this context and then 
returns
+        * \return GHOST_kSuccess if it is OK for the parent to release the 
handles and GHOST_kFailure if releasing the handles will interfere with sharing
         */
        virtual GHOST_TSuccess releaseNativeHandles();
 
@@ -123,7 +119,20 @@ public:
         */
        virtual GHOST_TSuccess getSwapInterval(int&);
 
+       /**
+        * Updates the drawing context of this window.
+        * Needed whenever the window is changed.
+        * \return Indication of success.
+        */
+       virtual GHOST_TSuccess updateDrawingContext();
+
+//protected:
+//     inline void activateCGLEW() const {
+//             cglewContext = m_cglewContext;
+//     }
+
 private:
+       //void initContextCGLEW()
 
        /** The window containing the OpenGL view */
        NSWindow *m_window;
@@ -131,21 +140,22 @@ private:
        /** The openGL view */
        NSOpenGLView *m_openGLView; 
 
-       int m_contextProfileMask;
-       int m_contextMajorVersion;
-       int m_contextMinorVersion;
-       int m_contextFlags;
-       int m_contextResetNotificationStrategy;
+       const int m_contextProfileMask;
+       const int m_contextMajorVersion;
+       const int m_contextMinorVersion;
+       const int m_contextFlags;
+       const int m_contextResetNotificationStrategy;
 
        /** The opgnGL drawing context */
        NSOpenGLContext *m_openGLContext;
        
+       //static CGLEWContext* s_cglewContext;
+
        /** The first created OpenGL context (for sharing display lists) */
        static NSOpenGLContext *s_sharedOpenGLContext;  
        static int              s_sharedCount;
-
 };
 
 
 
-#endif // __GHOST_CONTEXTCGL_H__
+#endif // _GHOST_CONTEXTCGL_H_
diff --git a/intern/ghost/intern/GHOST_ContextCGL.mm 
b/intern/ghost/intern/GHOST_ContextCGL.mm
index 12837a6..abec628 100644
--- a/intern/ghost/intern/GHOST_ContextCGL.mm
+++ b/intern/ghost/intern/GHOST_ContextCGL.mm
@@ -132,11 +132,15 @@ GHOST_TSuccess GHOST_ContextCGL::getSwapInterval(int& 
intervalOut)
 {
        if (m_openGLContext != nil) {
                GLint interval;
+
                NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
                [m_openGLContext setValues:&interval 
forParameter:NSOpenGLCPSwapInterval];
+
                [pool drain];
 
-               intervalOut = (int)interval;
+               intervalOut = static_cast<int>(interval);
+
                return GHOST_kSuccess;
        }
        else {
@@ -335,6 +339,10 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext()
 
        initContextGLEW();
 
+       glClearColor(0.447, 0.447, 0.447, 0.000);
+       glClear(GL_COLOR_BUFFER_BIT);
+       glClearColor(0.000, 0.000, 0.000, 0.000);
+
        [pool drain];
 
        return GHOST_kSuccess;
diff --git a/intern/ghost/intern/GHOST_ContextEGL.cpp 
b/intern/ghost/intern/GHOST_ContextEGL.cpp
index 6ddbfc5..2d17d84 100644
--- a/intern/ghost/intern/GHOST_ContextEGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextEGL.cpp
@@ -208,13 +208,13 @@ HMODULE GHOST_ContextEGL::s_d3dcompiler = NULL;
 
 
 
-EGLContext GHOST_ContextEGL::s_gl_sharedContext   = NULL;
+EGLContext GHOST_ContextEGL::s_gl_sharedContext   = EGL_NO_CONTEXT;
 EGLint     GHOST_ContextEGL::s_gl_sharedCount     = 0;
 
-EGLContext GHOST_ContextEGL::s_gles_sharedContext = NULL;
+EGLContext GHOST_ContextEGL::s_gles_sharedContext = EGL_NO_CONTEXT;
 EGLint     GHOST_ContextEGL::s_gles_sharedCount   = 0;
 
-EGLContext GHOST_ContextEGL::s_vg_sharedContext   = NULL;
+EGLContext GHOST_ContextEGL::s_vg_sharedContext   = EGL_NO_CONTEXT;
 EGLint     GHOST_ContextEGL::s_vg_sharedCount     = 0;
 
 
@@ -242,22 +242,22 @@ GHOST_ContextEGL::GHOST_ContextEGL(
        GHOST_TUns16         numOfAASamples,
        EGLNativeWindowType  nativeWindow,
        EGLNativeDisplayType nativeDisplay,
-       EGLenum              api,
        EGLint               contextProfileMask,
        EGLint               contextMajorVersion,
        EGLint               contextMinorVersion,
        EGLint               contextFlags,
-       EGLint               contextResetNotificationStrategy
+       EGLint               contextResetNotificationStrategy,
+       EGLenum              api
 )
        : GHOST_Context(stereoVisual, numOfAASamples)
        , m_nativeWindow (nativeWindow)
        , m_nativeDisplay(nativeDisplay)
-       , m_api(api)
        , m_contextProfileMask              (contextProfileMask)
        , m_contextMajorVersion             (contextMajorVersion)
        , m_contextMinorVersion             (contextMinorVersion)
        , m_contextFlags                    (contextFlags)
        , m_contextResetNotificationStrategy(contextResetNotificationStrategy)
+       , m_api(api)
        , m_swap_interval(1)
        , m_display(EGL_NO_DISPLAY)
        , m_surface(EGL_NO_SURFACE)
@@ -334,7 +334,8 @@ GHOST_TSuccess GHOST_ContextEGL::setSwapInterval(int 
interval)
 
 GHOST_TSuccess GHOST_ContextEGL::getSwapInterval(int& intervalOut)
 {
-       intervalOut = m_swap_interval;
+       intervalOut = m_swap_interval; // XXX jwilkins: make sure there is no 
way to query this?
+
        return GHOST_kSuccess;
 }
 
@@ -357,7 +358,7 @@ GHOST_TSuccess GHOST_ContextEGL::activateDrawingContext()
 
 
 
-void GHOST_ContextEGL::initContextEGLEW(EGLDisplay display)
+void GHOST_ContextEGL::initContextEGLEW()
 {
        eglewContext = new EGLEWContext;
        memset(eglewContext, 0, sizeof(EGLEWContext));
@@ -365,7 +366,7 @@ void GHOST_ContextEGL::initContextEGLEW(EGLDisplay display)
        delete m_eglewContext;
        m_eglewContext = eglewContext;
 
-       GLEW_CHK(eglewInit(display));
+       GLEW_CHK(eglewInit(m_display));
 }
 
 
@@ -435,7 +436,7 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
        if (!EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, 
EGL_NO_SURFACE, EGL_NO_CONTEXT)))
                goto error;
 
-       initContextEGLEW(m_display);
+       initContextEGLEW();
 
        if (!bindAPI(m_api))
                goto error;
@@ -632,6 +633,10 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
 
        initContextGLEW();
 
+       glClearColor(0.447, 0.447, 0.447, 0.000);
+       glClear(GL_COLOR_BUFFER_BIT);
+       glClearColor(0.000, 0.000, 0.000, 0.000);
+
        return GHOST_kSuccess;
 
 error:
diff --git a/intern/ghost/intern/GHOST_ContextEGL.h 
b/intern/ghost/intern/GHOST_ContextEGL.h
index 9d72f96..59681cd 100644
--- a/intern/ghost/intern/GHOST_ContextEGL.h
+++ b/intern/ghost/intern/GHOST_ContextEGL.h
@@ -30,8 +30,8 @@
  * Declaration of GHOST_ContextEGL class.
  */
 
-#ifndef __GHOST_CONTEXTEGL_H__
-#define __GHOST_CONTEXTEGL_H__
+#ifndef _GHOST_CONTEXTEGL_H_
+#define _GHOST_CONTEXTEGL_H_
 
 #include "GHOST_Context.h"
 
@@ -62,12 +62,12 @@ public:
                GHOST_TUns16         numOfAASamples,
                EGLNativeWindowType  nativeWindow,
                EGLNativeDisplayType nativeDisplay,
-               EGLenum              api,
                EGLint               contextProfileMask,
                EGLint               contextMajorVersion,
                EGLint               contextMinorVersion,
                EGLint               contextFlags,
-               EGLint               contextResetNotificationStrategy
+               EGLint               contextResetNotificationStrategy,
+               EGLenum              api
        );
 
        /**
@@ -88,18 +88,14 @@ public:
        virtual GHOST_TSuccess activateDrawingContext();
 
        /**
-        * Tries to install a rendering context in this window.
-        * \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.
+        * Call immediately after new to initialize.  If this fails then 
immediately delete the object.
+        * \return Indication as to whether initialization has succeeded.
         */
        virtual GHOST_TSuccess initializeDrawingContext();
 
        /**
         * Removes references to native handles from this context and then 
returns
-        * GHOST_kSuccess if it is OK for the parent to release the handles
-        * and GHOST_kFailure if releasing the handles will interfere with 
sharing
-        * \return Indication as to whether removal has succeeded.
+        * \return GHOST_kSuccess if it is OK for the parent to release the 
handles and GHOST_kFailure if releasing the handles will interfere with sharing
         */
        virtual GHOST_TSuccess releaseNativeHandles();
 
@@ -115,37 +111,38 @@ public:
         * \param intervalOut Variable to store the swap interval if it can be 
read.
         * \return Whether the swap interval can be read.
         */
-       GHOST_TSuccess getSwapInterval(int& intervalOut)
+       GHOST_TSuccess getSwapInterval(int& intervalOut);
 
 protected:
-       void activateEGLEW() const {
+       inline void activateEGLEW() const {
                eglewContext = m_eglewContext;
        }
 
 private:
-       void initContextEGLEW(EGLDisplay display);
+       void initContextEGLEW();
 
        EGLNativeDisplayType m_nativeDisplay;
        EGLNativeWindowType  m_nativeWindow;
 
-       const EGLenum m_api;
-       const EGL

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to