X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGLViewer%2FGLViewer_Drawer.cxx;h=13d5e8acbef14f0b6bbaffb3abc2e4e93ceba5ec;hb=e7ede3527d1022d9df3cc38cd9d00d2eefb9f80f;hp=d8bd48cd3459cf5a2835a4f413bd10bf6412af00;hpb=53415443fa7c248984f053da559cc8765623088c;p=modules%2Fgui.git diff --git a/src/GLViewer/GLViewer_Drawer.cxx b/src/GLViewer/GLViewer_Drawer.cxx index d8bd48cd3..13d5e8acb 100644 --- a/src/GLViewer/GLViewer_Drawer.cxx +++ b/src/GLViewer/GLViewer_Drawer.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -36,7 +36,9 @@ #include #include -#ifndef WIN32 +#if defined(__APPLE__) +#include +#elif !defined(WIN32) #include #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; @@ -398,12 +400,41 @@ static GLuint displayListBase( QFont* theFont ) listBase += 256; HDC glHdc = ::wglGetCurrentDC(); + #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) ::SelectObject( glHdc, theFont->handle() ); + #endif if ( !::wglUseFontBitmaps( glHdc, 0, 256, listBase ) ) listBase = 0; 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::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 )