-// Copyright (C) 2007-2012 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
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <QPainter>
#include <QFile>
-#ifndef WIN32
+#if defined(__APPLE__)
+#include <OpenGL/CGLCurrent.h>
+#elif !defined(WIN32)
#include <GL/glx.h>
#endif
aFindFont.myIsUndl = theFont->underline();
aFindFont.myPointSize = theFont->pointSize();
-#ifdef WIN32
+#if defined(WIN32)
HGLRC ctx = ::wglGetCurrentContext();
if ( !ctx )
return aList;
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<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 )
int aFontCont = 0;
QString aFontDef = theFont->toString();
char** xFontList = XListFonts( aDisp, aFontDef.toLatin1()/*aFindFont.myFontString.data()*/, 1, &aFontCont );
+// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
if( !theFont->handle() )
- {
+ {
+#endif
#ifdef _DEBUG_
printf( "Can't load font %s. loading default font....\n", aFontDef.toLatin1().data()/*aFindFont.myFontString.data()*/ );
#endif
aFontMask += "-*-*-*-m-*-*-*";
xFontList = XListFonts( aDisp, aFontMask.toLatin1().constData()/*"-*-*-*-r-*-*-12-*-*-*-m-*-*-*"*/, 1, &aFontCont );
if( aFontCont == 0 )
- {
+ {
#ifdef _DEBUG_
printf( "Can't load default font\n" );
#endif
return 0;
}
glXUseXFont( (Font)(XLoadFont( aDisp,xFontList[0] )), 0, 256, listBase );
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
}
else
glXUseXFont( (Font)(theFont->handle()), 0, 256, listBase );
-
+#endif
aList = listBase;
GLViewer_TexFont::BitmapFontCache[aFindFont] = aList;
}