Salome HOME
Merge branch 'master' into pre/V8_2_BR
[modules/gui.git] / src / GLViewer / GLViewer_Drawer.cxx
index 089d8a8109c809a48852c99747aa7a12feb2b5c7..13d5e8acbef14f0b6bbaffb3abc2e4e93ceba5ec 100644 (file)
@@ -36,7 +36,9 @@
 #include <QPainter>
 #include <QFile>
 
-#ifndef WIN32
+#if defined(__APPLE__)
+#include <OpenGL/CGLCurrent.h>
+#elif !defined(WIN32)
 #include <GL/glx.h>
 #endif
 
@@ -377,7 +379,7 @@ static GLuint displayListBase( QFont* theFont )
   aFindFont.myIsUndl = theFont->underline();
   aFindFont.myPointSize = theFont->pointSize();
 
-#ifdef WIN32
+#if defined(WIN32)
   HGLRC ctx = ::wglGetCurrentContext();
   if ( !ctx )
     return aList;  
@@ -406,6 +408,33 @@ static GLuint displayListBase( QFont* theFont )
     aList = listBase;
     GLViewer_TexFont::BitmapFontCache[aFindFont] = aList;
   }
+#elif defined(__APPLE__)
+  CGLContextObj ctx = ::CGLGetCurrentContext();
+  if ( !ctx )
+    return aList;
+
+  aFindFont.myViewPortId = (long)ctx;
+
+  if ( GLViewer_TexFont::BitmapFontCache.contains( aFindFont ) )
+    aList = GLViewer_TexFont::BitmapFontCache[aFindFont];
+  else
+  {
+    GLuint listBase = 0;
+    QMap<GLViewer_TexFindId, GLuint>::iterator it = GLViewer_TexFont::BitmapFontCache.begin();
+    for ( ; it != GLViewer_TexFont::BitmapFontCache.end(); ++it )
+    {
+      if ( it.key().myViewPortId == (long)ctx && it.value() > listBase )
+        listBase = it.value();
+    }
+    listBase += 256;
+
+    //HDC glHdc = ::wglGetCurrentDC();
+    //::SelectObject( glHdc, theFont->handle() );
+    //if ( !::wglUseFontBitmaps( glHdc, 0, 256, listBase ) )
+    //  listBase = 0;
+    aList = listBase;
+    GLViewer_TexFont::BitmapFontCache[aFindFont] = aList;
+  }
 #else //X Window
   Display* aDisp = glXGetCurrentDisplay();
   if( !aDisp )