0024148: Test case bugs/vis/bug24131_markers works wrong on software MS OpenGL
authorkgv <kgv@opencascade.com>
Thu, 26 Sep 2013 16:21:06 +0000 (20:21 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 26 Sep 2013 16:22:05 +0000 (20:22 +0400)
Add pre-rendered images for custom markers.
OpenGl_Window - drop overcomplicated find_pixel_format() function
OpenGl_Caps - add option to force software OpenGL imlementation (MS or Apple)
Remove TODO from test case
Add grayscale custom marker to the test
Correct color bitness in attributes list

data/images/marker_box1.png [new file with mode: 0644]
data/images/marker_box2.png [new file with mode: 0644]
data/images/marker_dot.png [new file with mode: 0644]
src/OpenGl/OpenGl_Caps.cxx
src/OpenGl/OpenGl_Caps.hxx
src/OpenGl/OpenGl_PrimitiveArray.cxx
src/OpenGl/OpenGl_Window.cxx
src/OpenGl/OpenGl_Window_1.mm
src/ViewerTest/ViewerTest_ViewerCommands.cxx
tests/bugs/vis/bug24131_markers

diff --git a/data/images/marker_box1.png b/data/images/marker_box1.png
new file mode 100644 (file)
index 0000000..f87ea93
Binary files /dev/null and b/data/images/marker_box1.png differ
diff --git a/data/images/marker_box2.png b/data/images/marker_box2.png
new file mode 100644 (file)
index 0000000..e2e1324
Binary files /dev/null and b/data/images/marker_box2.png differ
diff --git a/data/images/marker_dot.png b/data/images/marker_dot.png
new file mode 100644 (file)
index 0000000..e010ee2
Binary files /dev/null and b/data/images/marker_dot.png differ
index cf1e93d1ee494c067913bacfb142529802289511..e5b3c99ae4cab1aea118b6ca0902738bac37428a 100644 (file)
@@ -29,7 +29,9 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Caps, Standard_Transient)
 OpenGl_Caps::OpenGl_Caps()
 : vboDisable        (Standard_False),
   pntSpritesDisable (Standard_False),
-  contextDebug      (Standard_False)
+  contextStereo     (Standard_False),
+  contextDebug      (Standard_False),
+  contextNoAccel    (Standard_False)
 {
   //
 }
@@ -42,7 +44,9 @@ OpenGl_Caps& OpenGl_Caps::operator= (const OpenGl_Caps& theCopy)
 {
   vboDisable        = theCopy.vboDisable;
   pntSpritesDisable = theCopy.pntSpritesDisable;
+  contextStereo     = theCopy.contextStereo;
   contextDebug      = theCopy.contextDebug;
+  contextNoAccel    = theCopy.contextNoAccel;
   return *this;
 }
 
index 18552f82b8b1c08c7dfea8644f9991b60e34ab23..4ca46fc4cbc82d9c1c20fc82c3c65c21030af86d 100644 (file)
 class OpenGl_Caps : public Standard_Transient
 {
 
-public: //! @name flags to disable particular functionality
+public: //! @name flags to disable particular functionality, should be used only for testing purposes!
 
   Standard_Boolean vboDisable;        //!< flag permits VBO usage, will significantly affect performance (OFF by default)
   Standard_Boolean pntSpritesDisable; //!< flag permits Point Sprites usage, will significantly affect performance (OFF by default)
 
 public: //! @name context creation parameters
 
-  Standard_Boolean contextDebug; //!< request debug GL context (requires support in OpenGL driver), useful for debugging of visualization code (OFF by default, currently implemented only fow Windows)
+  /**
+   * Request stereoscopic context (with Quad Buffer). This flag requires support in OpenGL driver.
+   *
+   * OFF by default.
+   */
+  Standard_Boolean contextStereo;
+
+  /**
+   * Request debug GL context. This flag requires support in OpenGL driver.
+   *
+   * When turned on OpenGL driver emits error and warning messages to provided callback
+   * (see OpenGl_Context - messages will be printed to standard output).
+   * Affects performance - thus should not be turned on by products in released state.
+   *
+   * OFF by default. Currently implemented only for Windows (WGL).
+   */
+  Standard_Boolean contextDebug;
+
+  /**
+   * Disable hardware acceleration.
+   *
+   * This flag overrides default behavior, when accelerated context always preferred over software ones:
+   * - on Windows will force Microsoft software implementation;
+   * - on Mac OS X, forces Apple software implementation.
+   *
+   * Software implementations are dramatically slower - should never be used.
+   *
+   * OFF by default. Currently implemented only for Windows (WGL) and Mac OS X (Cocoa).
+   */
+  Standard_Boolean contextNoAccel;
 
 public: //! @name class methods
 
index 6a2a1f2e00e55993a122a4594332adc4fe5b171b..396258df3d6a1b45017424dacca915222ed98982 100755 (executable)
@@ -575,21 +575,21 @@ void OpenGl_PrimitiveArray::DrawMarkers (const Handle(OpenGl_Workspace)& theWork
   }
 
   // Textured markers will be drawn with the glBitmap
-  const GLfloat aPntSize = anAspectMarker->Type() == Aspect_TOM_POINT
-                         ? anAspectMarker->MarkerSize()
-                         : 0.0f;
-  if (aPntSize > 0.0f)
-  {
-    glPointSize (aPntSize);
-  }
   if (anAspectMarker->Type() == Aspect_TOM_POINT
    || anAspectMarker->Type() == Aspect_TOM_O_POINT)
   {
+    const GLfloat aPntSize = anAspectMarker->Type() == Aspect_TOM_POINT
+                           ? anAspectMarker->MarkerSize()
+                           : 0.0f;
+    if (aPntSize > 0.0f)
+    {
+      glPointSize (aPntSize);
+    }
     glDrawArrays (myDrawMode, 0, toDrawVbo() ? myVbos[VBOVertices]->GetElemsNb() : myPArray->num_vertexs);
-  }
-  if (aPntSize > 0.0f)
-  {
-    glPointSize (1.0f);
+    if (aPntSize > 0.0f)
+    {
+      glPointSize (1.0f);
+    }
   }
 
   if (anAspectMarker->Type() != Aspect_TOM_POINT
index 14090d63288acd249764c080bd9168f37f8985e8..fa7f10a748f78fd1aee4a247cbb894d463436327 100644 (file)
@@ -40,6 +40,62 @@ namespace
 
 #if defined(_WIN32)
 
+  // WGL_ARB_pixel_format
+#ifndef WGL_NUMBER_PIXEL_FORMATS_ARB
+  #define WGL_NUMBER_PIXEL_FORMATS_ARB            0x2000
+  #define WGL_DRAW_TO_WINDOW_ARB                  0x2001
+  #define WGL_DRAW_TO_BITMAP_ARB                  0x2002
+  #define WGL_ACCELERATION_ARB                    0x2003
+  #define WGL_NEED_PALETTE_ARB                    0x2004
+  #define WGL_NEED_SYSTEM_PALETTE_ARB             0x2005
+  #define WGL_SWAP_LAYER_BUFFERS_ARB              0x2006
+  #define WGL_SWAP_METHOD_ARB                     0x2007
+  #define WGL_NUMBER_OVERLAYS_ARB                 0x2008
+  #define WGL_NUMBER_UNDERLAYS_ARB                0x2009
+  #define WGL_TRANSPARENT_ARB                     0x200A
+  #define WGL_TRANSPARENT_RED_VALUE_ARB           0x2037
+  #define WGL_TRANSPARENT_GREEN_VALUE_ARB         0x2038
+  #define WGL_TRANSPARENT_BLUE_VALUE_ARB          0x2039
+  #define WGL_TRANSPARENT_ALPHA_VALUE_ARB         0x203A
+  #define WGL_TRANSPARENT_INDEX_VALUE_ARB         0x203B
+  #define WGL_SHARE_DEPTH_ARB                     0x200C
+  #define WGL_SHARE_STENCIL_ARB                   0x200D
+  #define WGL_SHARE_ACCUM_ARB                     0x200E
+  #define WGL_SUPPORT_GDI_ARB                     0x200F
+  #define WGL_SUPPORT_OPENGL_ARB                  0x2010
+  #define WGL_DOUBLE_BUFFER_ARB                   0x2011
+  #define WGL_STEREO_ARB                          0x2012
+  #define WGL_PIXEL_TYPE_ARB                      0x2013
+  #define WGL_COLOR_BITS_ARB                      0x2014
+  #define WGL_RED_BITS_ARB                        0x2015
+  #define WGL_RED_SHIFT_ARB                       0x2016
+  #define WGL_GREEN_BITS_ARB                      0x2017
+  #define WGL_GREEN_SHIFT_ARB                     0x2018
+  #define WGL_BLUE_BITS_ARB                       0x2019
+  #define WGL_BLUE_SHIFT_ARB                      0x201A
+  #define WGL_ALPHA_BITS_ARB                      0x201B
+  #define WGL_ALPHA_SHIFT_ARB                     0x201C
+  #define WGL_ACCUM_BITS_ARB                      0x201D
+  #define WGL_ACCUM_RED_BITS_ARB                  0x201E
+  #define WGL_ACCUM_GREEN_BITS_ARB                0x201F
+  #define WGL_ACCUM_BLUE_BITS_ARB                 0x2020
+  #define WGL_ACCUM_ALPHA_BITS_ARB                0x2021
+  #define WGL_DEPTH_BITS_ARB                      0x2022
+  #define WGL_STENCIL_BITS_ARB                    0x2023
+  #define WGL_AUX_BUFFERS_ARB                     0x2024
+
+  #define WGL_NO_ACCELERATION_ARB                 0x2025
+  #define WGL_GENERIC_ACCELERATION_ARB            0x2026
+  #define WGL_FULL_ACCELERATION_ARB               0x2027
+
+  #define WGL_SWAP_EXCHANGE_ARB                   0x2028
+  #define WGL_SWAP_COPY_ARB                       0x2029
+  #define WGL_SWAP_UNDEFINED_ARB                  0x202A
+
+  #define WGL_TYPE_RGBA_ARB                       0x202B
+  #define WGL_TYPE_COLORINDEX_ARB                 0x202C
+#endif // WGL_NUMBER_PIXEL_FORMATS_ARB
+
   // WGL_ARB_create_context_profile
 #ifndef WGL_CONTEXT_MAJOR_VERSION_ARB
   #define WGL_CONTEXT_MAJOR_VERSION_ARB           0x2091
@@ -61,91 +117,6 @@ namespace
   {
     return DefWindowProcW (theWin, theMsg, theParamW, theParamL);
   }
-
-  static int find_pixel_format (HDC                    theDevCtx,
-                                PIXELFORMATDESCRIPTOR& thePixelFrmt,
-                                const Standard_Boolean theIsDoubleBuff)
-  {
-    PIXELFORMATDESCRIPTOR aPixelFrmtTmp;
-    memset (&aPixelFrmtTmp, 0, sizeof (PIXELFORMATDESCRIPTOR));
-    aPixelFrmtTmp.nSize      = sizeof (PIXELFORMATDESCRIPTOR);
-    aPixelFrmtTmp.nVersion   = 1;
-    aPixelFrmtTmp.dwFlags    = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | (theIsDoubleBuff ? PFD_DOUBLEBUFFER : PFD_SUPPORT_GDI);
-    aPixelFrmtTmp.iPixelType = PFD_TYPE_RGBA;
-    aPixelFrmtTmp.iLayerType = PFD_MAIN_PLANE;
-
-    const int BUFF_BITS_STENCIL[] = {  8,  1     };
-    const int BUFF_BITS_COLOR[]   = { 32, 24     };
-    const int BUFF_BITS_DEPTH[]   = { 32, 24, 16 };
-
-    int aGoodBits[] = { 0, 0, 0 };
-    int aPixelFrmtIdLast = 0;
-    int aPixelFrmtIdGood = 0;
-    Standard_Size aStencilIter = 0, aColorIter = 0, aDepthIter = 0;
-    for (aStencilIter = 0; aStencilIter < sizeof(BUFF_BITS_STENCIL) / sizeof(int); ++aStencilIter)
-    {
-      aPixelFrmtTmp.cStencilBits = (BYTE)(BUFF_BITS_STENCIL[aStencilIter]);
-      for (aDepthIter = 0; aDepthIter < sizeof(BUFF_BITS_DEPTH) / sizeof(int); ++aDepthIter)
-      {
-        aPixelFrmtTmp.cDepthBits = (BYTE)(BUFF_BITS_DEPTH[aDepthIter]);
-        aPixelFrmtIdGood = 0;
-        for (aColorIter = 0; aColorIter < sizeof(BUFF_BITS_COLOR) / sizeof(int); ++aColorIter)
-        {
-          aPixelFrmtTmp.cColorBits = (BYTE)(BUFF_BITS_COLOR[aColorIter]);
-          aPixelFrmtIdLast = ChoosePixelFormat (theDevCtx, &aPixelFrmtTmp);
-          if (aPixelFrmtIdLast == 0)
-          {
-            continue;
-          }
-
-          thePixelFrmt.cDepthBits   = 0;
-          thePixelFrmt.cColorBits   = 0;
-          thePixelFrmt.cStencilBits = 0;
-          DescribePixelFormat (theDevCtx, aPixelFrmtIdLast, sizeof(PIXELFORMATDESCRIPTOR), &thePixelFrmt);
-          if (thePixelFrmt.cColorBits   >= BUFF_BITS_COLOR[aColorIter]
-           && thePixelFrmt.cDepthBits   >= BUFF_BITS_DEPTH[aDepthIter]
-           && thePixelFrmt.cStencilBits >= BUFF_BITS_STENCIL[aStencilIter])
-          {
-            break;
-          }
-          if (thePixelFrmt.cColorBits > aGoodBits[0])
-          {
-            aGoodBits[0] = thePixelFrmt.cColorBits;
-            aGoodBits[1] = thePixelFrmt.cDepthBits;
-            aGoodBits[2] = thePixelFrmt.cStencilBits;
-            aPixelFrmtIdGood = aPixelFrmtIdLast;
-          }
-          else if (thePixelFrmt.cColorBits == aGoodBits[0])
-          {
-            if (thePixelFrmt.cDepthBits > aGoodBits[1])
-            {
-              aGoodBits[1] = thePixelFrmt.cDepthBits;
-              aGoodBits[2] = thePixelFrmt.cStencilBits;
-              aPixelFrmtIdGood = aPixelFrmtIdLast;
-            }
-            else if (thePixelFrmt.cDepthBits == aGoodBits[1])
-            {
-              if(thePixelFrmt.cStencilBits > aGoodBits[2])
-              {
-                aGoodBits[2] = thePixelFrmt.cStencilBits;
-                aPixelFrmtIdGood = aPixelFrmtIdLast;
-              }
-            }
-          }
-        }
-        if (aColorIter < sizeof(BUFF_BITS_COLOR) / sizeof(int))
-        {
-          break;
-        }
-      }
-      if (aDepthIter < sizeof(BUFF_BITS_DEPTH) / sizeof(int))
-      {
-        break;
-      }
-    }
-
-    return (aPixelFrmtIdLast == 0) ? aPixelFrmtIdGood : aPixelFrmtIdLast;
-  }
 #else
   static Bool WaitForNotify (Display* theDisp, XEvent* theEv, char* theArg)
   {
@@ -186,7 +157,21 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay,
   HGLRC aGContext = (HGLRC )theGContext;
 
   PIXELFORMATDESCRIPTOR aPixelFrmt;
-  const int aPixelFrmtId = find_pixel_format (aWindowDC, aPixelFrmt, myDisplay->DBuffer());
+  memset (&aPixelFrmt, 0, sizeof(aPixelFrmt));
+  aPixelFrmt.nSize        = sizeof(PIXELFORMATDESCRIPTOR);
+  aPixelFrmt.nVersion     = 1;
+  aPixelFrmt.dwFlags      = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
+  aPixelFrmt.iPixelType   = PFD_TYPE_RGBA;
+  aPixelFrmt.cColorBits   = 24;
+  aPixelFrmt.cDepthBits   = 24;
+  aPixelFrmt.cStencilBits = 8;
+  aPixelFrmt.iLayerType   = PFD_MAIN_PLANE;
+  if (theCaps->contextStereo)
+  {
+    aPixelFrmt.dwFlags |= PFD_STEREO;
+  }
+
+  int aPixelFrmtId = ChoosePixelFormat (aWindowDC, &aPixelFrmt);
   if (aPixelFrmtId == 0)
   {
     ReleaseDC (aWindow, aWindowDC);
@@ -197,6 +182,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay,
     return;
   }
 
+  DescribePixelFormat (aWindowDC, aPixelFrmtId, sizeof(aPixelFrmt), &aPixelFrmt);
   if (aPixelFrmt.dwFlags & PFD_NEED_PALETTE)
   {
     WINDOW_DATA* aWndData = (WINDOW_DATA* )GetWindowLongPtr (aWindow, GWLP_USERDATA);
@@ -215,16 +201,6 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay,
     myBackDither = (aPixelFrmt.cColorBits <= 8);
   }
 
-  if (!SetPixelFormat (aWindowDC, aPixelFrmtId, &aPixelFrmt))
-  {
-    ReleaseDC (aWindow, aWindowDC);
-
-    TCollection_AsciiString aMsg("OpenGl_Window::CreateWindow: SetPixelFormat failed. Error code: ");
-    aMsg += (int )GetLastError();
-    Aspect_GraphicDeviceDefinitionError::Raise (aMsg.ToCString());
-    return;
-  }
-
   HGLRC aSlaveCtx = !theShareCtx.IsNull() ? (HGLRC )theShareCtx->myGContext : NULL;
   if (aGContext == NULL)
   {
@@ -238,7 +214,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay,
     HWND  aWinTmp     = NULL;
     HDC   aDevCtxTmp  = NULL;
     HGLRC aRendCtxTmp = NULL;
-    if (!theCaps->contextDebug
+    if ((!theCaps->contextDebug && !theCaps->contextNoAccel)
      || RegisterClassW (&aClass) == 0)
     {
       aClass.lpszClassName = NULL;
@@ -257,36 +233,86 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay,
       SetPixelFormat (aDevCtxTmp, aPixelFrmtId, &aPixelFrmt);
       aRendCtxTmp = wglCreateContext (aDevCtxTmp);
     }
+
+    typedef BOOL (WINAPI *wglChoosePixelFormatARB_t)(HDC           theDevCtx,
+                                                     const int*    theIntAttribs,
+                                                     const float*  theFloatAttribs,
+                                                     unsigned int  theMaxFormats,
+                                                     int*          theFormatsOut,
+                                                     unsigned int* theNumFormatsOut);
+    typedef HGLRC (WINAPI *wglCreateContextAttribsARB_t)(HDC        theDevCtx,
+                                                         HGLRC      theShareContext,
+                                                         const int* theAttribs);
+    wglChoosePixelFormatARB_t    aChoosePixProc = NULL;
+    wglCreateContextAttribsARB_t aCreateCtxProc = NULL;
     if (aRendCtxTmp != NULL)
     {
       wglMakeCurrent (aDevCtxTmp, aRendCtxTmp);
 
       typedef const char* (WINAPI *wglGetExtensionsStringARB_t)(HDC theDeviceContext);
-      typedef HGLRC (WINAPI *wglCreateContextAttribsARB_t)(HDC        theDevCtx,
-                                                           HGLRC      theShareContext,
-                                                           const int* theAttribs);
-      wglGetExtensionsStringARB_t  aGetExtensions = (wglGetExtensionsStringARB_t  )wglGetProcAddress ("wglGetExtensionsStringARB");
-      wglCreateContextAttribsARB_t aCreateCtxProc = (wglCreateContextAttribsARB_t )wglGetProcAddress ("wglCreateContextAttribsARB");
-      const char* aWglExts = aGetExtensions (wglGetCurrentDC());
-      if (aCreateCtxProc != NULL
-       && OpenGl_Context::CheckExtension (aWglExts, "WGL_ARB_create_context_profile"))
+      wglGetExtensionsStringARB_t aGetExtensions = (wglGetExtensionsStringARB_t  )wglGetProcAddress ("wglGetExtensionsStringARB");
+      const char* aWglExts = (aGetExtensions != NULL) ? aGetExtensions (wglGetCurrentDC()) : NULL;
+      if (OpenGl_Context::CheckExtension (aWglExts, "WGL_ARB_pixel_format"))
+      {
+        aChoosePixProc = (wglChoosePixelFormatARB_t    )wglGetProcAddress ("wglChoosePixelFormatARB");
+      }
+      if (OpenGl_Context::CheckExtension (aWglExts, "WGL_ARB_create_context_profile"))
+      {
+        aCreateCtxProc = (wglCreateContextAttribsARB_t )wglGetProcAddress ("wglCreateContextAttribsARB");
+      }
+    }
+
+    // choose extended pixel format
+    if (aChoosePixProc != NULL)
+    {
+      const int aPixAttribs[] =
+      {
+        WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
+        WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
+        WGL_DOUBLE_BUFFER_ARB,  GL_TRUE,
+        WGL_STEREO_ARB,         theCaps->contextStereo ? GL_TRUE : GL_FALSE,
+        WGL_PIXEL_TYPE_ARB,     WGL_TYPE_RGBA_ARB,
+        //WGL_SAMPLE_BUFFERS_ARB, 1,
+        //WGL_SAMPLES_ARB,        8,
+        WGL_COLOR_BITS_ARB,     24,
+        WGL_DEPTH_BITS_ARB,     24,
+        WGL_STENCIL_BITS_ARB,   8,
+        WGL_ACCELERATION_ARB,   theCaps->contextNoAccel ? WGL_NO_ACCELERATION_ARB : WGL_FULL_ACCELERATION_ARB,
+        0, 0,
+      };
+      unsigned int aFrmtsNb = 0;
+      aChoosePixProc (aWindowDC, aPixAttribs, NULL, 1, &aPixelFrmtId, &aFrmtsNb);
+    }
+
+    // setup pixel format - may be set only once per window
+    if (!SetPixelFormat (aWindowDC, aPixelFrmtId, &aPixelFrmt))
+    {
+      ReleaseDC (aWindow, aWindowDC);
+
+      TCollection_AsciiString aMsg("OpenGl_Window::CreateWindow: SetPixelFormat failed. Error code: ");
+      aMsg += (int )GetLastError();
+      Aspect_GraphicDeviceDefinitionError::Raise (aMsg.ToCString());
+      return;
+    }
+
+    // create GL context with extra options
+    if (aCreateCtxProc != NULL)
+    {
+      // Beware! NVIDIA drivers reject context creation when WGL_CONTEXT_PROFILE_MASK_ARB are specified
+      // but not WGL_CONTEXT_MAJOR_VERSION_ARB/WGL_CONTEXT_MINOR_VERSION_ARB.
+      int aCtxAttribs[] =
+      {
+        //WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
+        //WGL_CONTEXT_MINOR_VERSION_ARB, 2,
+        //WGL_CONTEXT_PROFILE_MASK_ARB,  WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, //WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
+        WGL_CONTEXT_FLAGS_ARB,         theCaps->contextDebug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0,
+        0, 0
+      };
+
+      aGContext = aCreateCtxProc (aWindowDC, aSlaveCtx, aCtxAttribs);
+      if (aGContext != NULL)
       {
-        // Beware! NVIDIA drivers reject context creation when WGL_CONTEXT_PROFILE_MASK_ARB are specified
-        // but not WGL_CONTEXT_MAJOR_VERSION_ARB/WGL_CONTEXT_MINOR_VERSION_ARB.
-        int aCtxAttribs[] =
-        {
-          //WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
-          //WGL_CONTEXT_MINOR_VERSION_ARB, 2,
-          //WGL_CONTEXT_PROFILE_MASK_ARB,  WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, //WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
-          WGL_CONTEXT_FLAGS_ARB,         theCaps->contextDebug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0,
-          0, 0
-        };
-
-        aGContext = aCreateCtxProc (aWindowDC, aSlaveCtx, aCtxAttribs);
-        if (aGContext != NULL)
-        {
-          aSlaveCtx = NULL;
-        }
+        aSlaveCtx = NULL;
       }
     }
 
@@ -309,6 +335,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay,
 
     if (aGContext == NULL)
     {
+      // create context using obsolete functionality
       aGContext = wglCreateContext (aWindowDC);
     }
     if (aGContext == NULL)
index 2b7e2f68a363eb0695f46714c50b0788eb6379ce..8812a1e82590937ea841fde111d618fa4af13a88 100644 (file)
 #include <Cocoa_LocalPool.hxx>
 #include <TCollection_AsciiString.hxx>
 
+#include <OpenGL/CGLRenderers.h>
+
 namespace
 {
   static const TEL_COLOUR THE_DEFAULT_BG_COLOR = { { 0.F, 0.F, 0.F, 1.F } };
-  static const NSOpenGLPixelFormatAttribute THE_DOUBLE_BUFF[] = {
-    //NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute )32,
-    NSOpenGLPFADepthSize,   (NSOpenGLPixelFormatAttribute )24,
-    NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute )8,
-    NSOpenGLPFADoubleBuffer,
-    NSOpenGLPFAAccelerated,
-    0
-  };
-
 };
 
 // =======================================================================
@@ -70,11 +63,31 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay,
   Cocoa_LocalPool aLocalPool;
   //NSOpenGLContext* aGContext = (NSOpenGLContext* )theGContext;
 
+  const NSOpenGLPixelFormatAttribute aDummyAttrib = NSOpenGLPFACompliant;
+  NSOpenGLPixelFormatAttribute anAttribs[] = {
+    theCaps->contextStereo ? NSOpenGLPFAStereo : aDummyAttrib,
+    //NSOpenGLPFAColorSize,  32,
+    NSOpenGLPFADepthSize,    24,
+    NSOpenGLPFAStencilSize,  8,
+    NSOpenGLPFADoubleBuffer,
+    theCaps->contextNoAccel ? NSOpenGLPFARendererID : NSOpenGLPFAAccelerated,
+    theCaps->contextNoAccel ? (NSOpenGLPixelFormatAttribute )kCGLRendererGenericFloatID : 0,
+    0
+  };
+
   // all GL context within one OpenGl_GraphicDriver should be shared!
   NSOpenGLContext*     aGLCtxShare = theShareCtx.IsNull() ? NULL : (NSOpenGLContext* )theShareCtx->myGContext;
-  NSOpenGLPixelFormat* aGLFormat   = [[[NSOpenGLPixelFormat alloc] initWithAttributes: THE_DOUBLE_BUFF] autorelease];
+  NSOpenGLPixelFormat* aGLFormat   = [[[NSOpenGLPixelFormat alloc] initWithAttributes: anAttribs] autorelease];
   NSOpenGLContext*     aGLContext  = [[NSOpenGLContext alloc] initWithFormat: aGLFormat
                                                                 shareContext: aGLCtxShare];
+  if (aGLContext == NULL
+   && theCaps->contextStereo)
+  {
+    anAttribs[0] = aDummyAttrib;
+    aGLForma     = [[[NSOpenGLPixelFormat alloc] initWithAttributes: anAttribs] autorelease];
+    aGLContext   = [[NSOpenGLContext alloc] initWithFormat: aGLFormat
+                                              shareContext: aGLCtxShare];
+  }
   if (aGLContext == NULL)
   {
     TCollection_AsciiString aMsg ("OpenGl_Window::CreateWindow: NSOpenGLContext creation failed");
index e038eb4929d0ab1cd5f4ef1a71dc4d50792575e4..58b45b3a5134afd50713ac2f96c2fcd2dc6737fe 100755 (executable)
@@ -647,7 +647,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
 #if defined(_WIN32) || defined(__WIN32__)
       VT_GetWindow() = new WNT_Window (aTitle.ToCString(),
                                        Handle(WNT_WClass)::DownCast (WClass()),
-                                       WS_OVERLAPPEDWINDOW,
+                                       Draw_VirtualWindows ? WS_POPUPWINDOW : WS_OVERLAPPEDWINDOW,
                                        aPxLeft, aPxTop,
                                        aPxWidth, aPxHeight,
                                        Quantity_NOC_BLACK);
@@ -3895,6 +3895,7 @@ static int VCaps (Draw_Interpretor& theDI,
   {
     theDI << "VBO:     " << (aCaps->vboDisable        ? "0" : "1") << "\n";
     theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
+    theDI << "SoftMode:" << (aCaps->contextNoAccel    ? "1" : "0") << "\n";
     return 0;
   }
 
@@ -3909,6 +3910,10 @@ static int VCaps (Draw_Interpretor& theDI,
     {
       aCaps->pntSpritesDisable = anArg.Token ("=", 2).IntegerValue() == 0;
     }
+    else if (anArg.Search ("soft=") > -1)
+    {
+      aCaps->contextNoAccel = anArg.Token ("=", 2).IntegerValue() != 0;
+    }
     else
     {
       std::cerr << "Unknown argument: " << anArg << "\n";
@@ -5402,7 +5407,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects",
     __FILE__, VVbo, group);
   theCommands.Add ("vcaps",
-    "vcaps [vbo={0|1}] [sprites={0|1}] : modify particular graphic driver options",
+    "vcaps [vbo={0|1}] [sprites={0|1}] [soft={0|1}] : modify particular graphic driver options",
     __FILE__, VCaps, group);
   theCommands.Add ("vmemgpu",
     "vmemgpu [f]: print system-dependent GPU memory information if available;"
index 22085dcb95c637c5aa9487d7a0d007f9504a6f8f..cc2993ca664a2e5ff77e915d7bc8ee0a30c24f86 100644 (file)
@@ -1,6 +1,3 @@
-puts "TODO DEBUG_24148 Windows: Tcl Exception: Dumping failed!"
-puts "TODO DEBUG_24148 Windows: TEST INCOMPLETE"
-
 puts "========"
 puts "OCC24131 Markers using Point Sprites"
 puts "========"
@@ -23,20 +20,11 @@ set aMarkerTypeNames {
   Aspect_TOM_USERDEFINED
 }
 
-# generate custom marker
-set aCustom1 $imagedir/${casename}_m1.png
-set aCustom2 $imagedir/${casename}_m2.png
-box b 1 1 1
-vinit name=Driver0/Viewer1/View1 l=32 t=32 w=512 h=512
-vclear
-vdisplay b
-vaxo
-vfit
-vdump $aCustom1 rgba 32 32
-vsetdispmode b 1
-vsetcolor b RED
-vrotate 1 0 0
-vdump $aCustom2 rgba 32 32
+
+# custom marker
+set aCustom1 [locate_data_file images/marker_box1.png]
+set aCustom2 [locate_data_file images/marker_box2.png]
+set aCustom3 [locate_data_file images/marker_dot.png]
 
 # draw box in advance which should fit all our markers
 box b -8 -8 0 16 16 2
@@ -64,6 +52,8 @@ for { set aMode 0 } { $aMode <= 1 } { incr aMode } {
       vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 PointsOnSide=1 FileName=$aCustom1
       set aCol [expr $aCol - 1]
       vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 PointsOnSide=1 FileName=$aCustom2
+      set aCol [expr $aCol - 1]
+      vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 PointsOnSide=1 FileName=$aCustom3
     } else {
       for { set aMarkerScale 1.0 } { $aMarkerScale <= 7 } { set aMarkerScale [expr $aMarkerScale + 0.5] } {
         vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 MarkerType=$aMarkerType Scale=$aMarkerScale PointsOnSide=1