diff --git a/Fltk/Draw.cpp b/Fltk/Draw.cpp
index d6ee794d85a8931d8862a5b7452a8d1794a42731..06c4ca36530a2d0dbbfd3d9e0ebc073e6481c5bd 100644
--- a/Fltk/Draw.cpp
+++ b/Fltk/Draw.cpp
@@ -4,6 +4,7 @@
 // bugs and problems to <gmsh@geuz.org>.
 
 #include <string.h>
+#include <FL/gl.h>
 #include "GUI.h"
 #include "graphicWindow.h"
 #include "optionWindow.h"
@@ -134,3 +135,28 @@ int GetFontSize()
     else               return 15;
   }
 }
+
+void SetFont(int fontid, int fontsize)
+{
+  gl_font(fontid, fontsize);
+}
+
+double GetStringWidth(const char *str)
+{
+  return gl_width(str);
+}
+
+int GetStringHeight()
+{
+  return gl_height();
+}
+
+int GetStringDescent()
+{
+  return gl_descent();
+}
+
+void DrawString(const char *str)
+{
+  gl_draw(str);
+}
diff --git a/Fltk/Draw.h b/Fltk/Draw.h
index 6206230767da154fd1e0ea1736eb186a2cacd826..14ad67816f473d5236a95b4ccd40f668fbe866c2 100644
--- a/Fltk/Draw.h
+++ b/Fltk/Draw.h
@@ -6,7 +6,8 @@
 #ifndef _DRAW_H_
 #define _DRAW_H_
 
-#include <string>
+// FLTK-dependent drawing functions (need to be redefined when linking
+// the graphics lib with another widget toolkit)
 
 void Draw();
 void DrawPlugin(void (*draw)(void *context));
@@ -16,5 +17,10 @@ int GetFontEnum(int index);
 const char *GetFontName(int index);
 int GetFontAlign(const char *alignstr);
 int GetFontSize();
+void SetFont(int fontid, int fontsize);
+double GetStringWidth(const char *str);
+int GetStringHeight();
+int GetStringDescent();
+void DrawString(const char *str);
 
 #endif
diff --git a/Fltk/openglWindow.cpp b/Fltk/openglWindow.cpp
index 3a563d7445edc16606c30fd246bd7993fe89a426..7524c183dd73a9ee9eea2c41d3054037a7fd5b7e 100644
--- a/Fltk/openglWindow.cpp
+++ b/Fltk/openglWindow.cpp
@@ -92,22 +92,22 @@ void openglWindow::drawScreenMessage()
     return;
 
   glColor4ubv((GLubyte *) & CTX::instance()->color.text);
-  gl_font(CTX::instance()->glFontEnum, CTX::instance()->glFontSize);
-  double h = gl_height();
+  SetFont(CTX::instance()->glFontEnum, CTX::instance()->glFontSize);
+  double h = GetStringHeight();
   
   if(screenMessage[0].size()){
     const char *txt = screenMessage[0].c_str();
-    double w = gl_width(txt);
+    double w = GetStringWidth(txt);
     glRasterPos2d(_ctx->viewport[2] / 2. - w / 2., 
                   _ctx->viewport[3] - 1.2 * h);
-    gl_draw(txt);
+    DrawString(txt);
   }
   if(screenMessage[1].size()){
     const char *txt = screenMessage[1].c_str();
-    double w = gl_width(txt);
+    double w = GetStringWidth(txt);
     glRasterPos2d(_ctx->viewport[2] / 2. - w / 2.,
                   _ctx->viewport[3] - 2.4 * h);
-    gl_draw(txt);
+    DrawString(txt);
   }
 }
 
diff --git a/Graphics/Makefile b/Graphics/Makefile
index 3d4bfc680bcf9685c708a92b2355673fa85b76a8..832d6f5e2647a1a53d6ee26c1c9ddd4b5acb8ee5 100644
--- a/Graphics/Makefile
+++ b/Graphics/Makefile
@@ -65,19 +65,19 @@ ReadImg${OBJEXT}: ReadImg.cpp ReadImg.h ../Common/GmshMessage.h ../Post/PView.h
   ../Geo/SPoint3.h ../Post/PViewDataList.h ../Post/PViewData.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Numeric/GmshMatrix.h \
   ../Common/GmshConfig.h ../Common/ListUtils.h
-drawContext${OBJEXT}: drawContext.cpp ../Common/GmshMessage.h drawContext.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h Trackball.h \
-  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h \
-  ../Numeric/Numeric.h ../Numeric/GmshMatrix.h ../Common/GmshConfig.h \
-  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/GPoint.h \
-  ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
-  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
-  ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
-  ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
-  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Post/PView.h ../Post/PViewOptions.h \
-  ../Post/ColorTable.h gl2ps.h
+drawContext${OBJEXT}: drawContext.cpp ../Common/GmshConfig.h \
+  ../Common/GmshMessage.h drawContext.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h Trackball.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/meshPartitionOptions.h ../Numeric/Numeric.h \
+  ../Numeric/GmshMatrix.h ../Geo/GModel.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
+  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h \
+  ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
+  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Post/PView.h \
+  ../Post/PViewOptions.h ../Post/ColorTable.h gl2ps.h
 drawMesh${OBJEXT}: drawMesh.cpp drawContext.h ../Geo/SBoundingBox3d.h \
   ../Geo/SPoint3.h ../Common/GmshMessage.h ../Common/GmshDefines.h \
   ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
@@ -118,24 +118,24 @@ drawPost${OBJEXT}: drawPost.cpp ../Common/GmshConfig.h ../Common/GmshMessage.h \
   ../Common/SmoothData.h ../Common/Context.h ../Geo/CGNSOptions.h \
   ../Mesh/meshPartitionOptions.h gl2ps.h
 drawAxes${OBJEXT}: drawAxes.cpp drawContext.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
-  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/GPoint.h \
-  ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
-  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
-  ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
-  ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
-  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Common/Context.h ../Geo/CGNSOptions.h \
-  ../Mesh/meshPartitionOptions.h ../Numeric/Numeric.h \
-  ../Numeric/GmshMatrix.h ../Common/GmshConfig.h ../Common/GmshMessage.h \
-  gl2ps.h
+  ../Geo/SPoint3.h ../Fltk/Draw.h ../Geo/GModel.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
+  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h \
+  ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
+  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Common/Context.h \
+  ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h \
+  ../Numeric/Numeric.h ../Numeric/GmshMatrix.h ../Common/GmshConfig.h \
+  ../Common/GmshMessage.h gl2ps.h
 drawScales${OBJEXT}: drawScales.cpp drawContext.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PView.h ../Post/PViewOptions.h \
+  ../Geo/SPoint3.h ../Fltk/Draw.h ../Post/PView.h ../Post/PViewOptions.h \
   ../Post/ColorTable.h ../Post/PViewData.h ../Numeric/GmshMatrix.h \
   ../Common/GmshConfig.h ../Common/GmshMessage.h ../Common/Context.h \
   ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h gl2ps.h
 drawGraph2d${OBJEXT}: drawGraph2d.cpp drawContext.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PView.h ../Post/PViewOptions.h \
+  ../Geo/SPoint3.h ../Fltk/Draw.h ../Post/PView.h ../Post/PViewOptions.h \
   ../Post/ColorTable.h ../Post/PViewData.h ../Numeric/GmshMatrix.h \
   ../Common/GmshConfig.h ../Common/GmshMessage.h gl2ps.h \
   ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h \
diff --git a/Graphics/PixelBuffer.h b/Graphics/PixelBuffer.h
index 1b69d882214334184a56553e8345f4a86958a164..4669b11afea4edff9144238b079fea8963a466f5 100644
--- a/Graphics/PixelBuffer.h
+++ b/Graphics/PixelBuffer.h
@@ -7,11 +7,18 @@
 #define _PIXEL_BUFFER_H_
 
 #include <string.h>
-#include <FL/gl.h>
 #include "GmshConfig.h"
 #include "GmshMessage.h"
 #include "Draw.h"
 
+#if defined(__APPLE__)
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#else
+#include <GL/gl.h>
+#include <GL/glu.h>
+#endif
+
 #if defined(HAVE_OSMESA)
 #include <GL/osmesa.h>
 #endif
diff --git a/Graphics/ReadImg.cpp b/Graphics/ReadImg.cpp
index 68d97ea87c5c6e110d254c54c020666a57cbc23c..ef174f89f35cfed3f746e78a6a597c4f8d5419c1 100644
--- a/Graphics/ReadImg.cpp
+++ b/Graphics/ReadImg.cpp
@@ -4,14 +4,18 @@
 // bugs and problems to <gmsh@geuz.org>.
 
 #include <string.h>
-#include <FL/Fl_JPEG_Image.H>
-#include <FL/Fl_PNM_Image.H>
-#include <FL/Fl_PNG_Image.H>
-#include <FL/Fl_BMP_Image.H>
 #include "ReadImg.h"
 #include "GmshMessage.h"
 #include "PView.h"
 #include "PViewDataList.h"
+#include "GmshConfig.h"
+
+#if defined(HAVE_FLTK)
+
+#include <FL/Fl_JPEG_Image.H>
+#include <FL/Fl_PNM_Image.H>
+#include <FL/Fl_PNG_Image.H>
+#include <FL/Fl_BMP_Image.H>
 
 // from an image, we create a post-procession view
 
@@ -131,3 +135,12 @@ int read_bmp(std::string fileName)
   Fl_BMP_Image img(fileName.c_str());
   return EndPos(fileName.c_str(), Img2Data(img));
 }
+
+#else
+
+int read_pnm(std::string fileName){ return 0; }
+int read_jpeg(std::string fileName){ return 0; }
+int read_png(std::string fileName){ return 0; }
+int read_bmp(std::string fileName){ return 0; }
+
+#endif
diff --git a/Graphics/drawAxes.cpp b/Graphics/drawAxes.cpp
index 992a1838a0985ccabb7782e0b97067c643770c42..cd997b371d57f1ad9c1b9c30babac613c05d9f75 100644
--- a/Graphics/drawAxes.cpp
+++ b/Graphics/drawAxes.cpp
@@ -5,8 +5,8 @@
 
 #include <string>
 #include <string.h>
-#include <FL/gl.h>
 #include "drawContext.h"
+#include "Draw.h"
 #include "GModel.h"
 #include "Context.h"
 #include "Numeric.h"
@@ -87,15 +87,15 @@ static int drawTics(drawContext *ctx, int comp, int n, std::string &format,
     double winp[3], winr[3];
     ctx->world2Viewport(p, winp);
     ctx->world2Viewport(r, winr);
-    gl_font(CTX::instance()->glFontEnum, CTX::instance()->glFontSize);
+    SetFont(CTX::instance()->glFontEnum, CTX::instance()->glFontSize);
     if(fabs(winr[0] - winp[0]) < 2.) // center align
-      winr[0] -= gl_width(str) / 2.;
+      winr[0] -= GetStringWidth(str) / 2.;
     else if(winr[0] < winp[0]) // right align
-      winr[0] -= gl_width(str);
+      winr[0] -= GetStringWidth(str);
     if(fabs(winr[1] - winp[1]) < 2.) // center align
-      winr[1] -= gl_height() / 3.;
+      winr[1] -= GetStringHeight() / 3.;
     else if(winr[1] < winp[1]) // top align
-      winr[1] -= gl_height();
+      winr[1] -= GetStringHeight();
     ctx->viewport2World(winr, r);
     glRasterPos3d(r[0], r[1], r[2]);
     ctx->drawString(str);
diff --git a/Graphics/drawContext.cpp b/Graphics/drawContext.cpp
index 3d5b99f27563b380a1cc616a2f3bab6e7a3377f9..876b0304a51cce2b2ef477bf1e60f1abf478a5b5 100644
--- a/Graphics/drawContext.cpp
+++ b/Graphics/drawContext.cpp
@@ -4,9 +4,7 @@
 // bugs and problems to <gmsh@geuz.org>.
 
 #include <string>
-#include <FL/gl.h>
-#include <FL/Fl_JPEG_Image.H>
-#include <FL/Fl_PNG_Image.H>
+#include "GmshConfig.h"
 #include "GmshMessage.h"
 #include "drawContext.h"
 #include "Trackball.h"
@@ -17,6 +15,11 @@
 #include "PViewOptions.h"
 #include "gl2ps.h"
 
+#if defined(HAVE_FLTK)
+#include <FL/Fl_JPEG_Image.H>
+#include <FL/Fl_PNG_Image.H>
+#endif
+
 drawContext::drawContext(drawTransform *transform) 
   : _transform(transform)
 {
@@ -391,6 +394,7 @@ void drawContext::initProjection(int xpick, int ypick, int wpick, int hpick)
 
     // background image
     if(CTX::instance()->bgImageFileName.size()){
+#if defined(HAVE_FLTK)
       if(_bgImage.empty()){
         int idot = CTX::instance()->bgImageFileName.find_last_of('.');
         std::string ext;
@@ -436,6 +440,7 @@ void drawContext::initProjection(int xpick, int ypick, int wpick, int hpick)
                    (void*)&_bgImage[0]);
       gl2psDrawPixels(_bgImageSize[0], _bgImageSize[1], 0, 0, GL_RGB, GL_FLOAT,
                       (void*)&_bgImage[0]);
+#endif
     }
 
     glPopMatrix();
diff --git a/Graphics/drawContext.h b/Graphics/drawContext.h
index fefb3dacefd7c57efcf37b2a561b856506380de5..1fae498a7436210a3cb1509239ee9339c93fac10 100644
--- a/Graphics/drawContext.h
+++ b/Graphics/drawContext.h
@@ -9,18 +9,16 @@
 #include <string>
 #include <vector>
 #include <set>
-#include <FL/gl.h>
+#include "SBoundingBox3d.h"
 
-//FIXME: work around faulty fltk installs
-//#include <FL/glu.h>
-#ifdef __APPLE__
-#  include <OpenGL/glu.h>
+#if defined(__APPLE__)
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
 #else
-#  include <GL/glu.h>
+#include <GL/gl.h>
+#include <GL/glu.h>
 #endif
 
-#include "SBoundingBox3d.h"
-
 class PView;
 class GModel;
 
diff --git a/Graphics/drawGeom.cpp b/Graphics/drawGeom.cpp
index ceca4292b6a0c0aa7dc54eec9cad26560d5fafb2..ebca002be37ab4eb1893ff5284a04081a3f51093 100644
--- a/Graphics/drawGeom.cpp
+++ b/Graphics/drawGeom.cpp
@@ -3,7 +3,6 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
-#include <FL/gl.h>
 #include "drawContext.h"
 #include "Context.h"
 #include "gl2ps.h"
diff --git a/Graphics/drawGlyph.cpp b/Graphics/drawGlyph.cpp
index 7ae4313d68944e5dde8f9059e8b4c6c94bfdf853..3858a80f013e4ca53282ec260cc6c21d746480f6 100644
--- a/Graphics/drawGlyph.cpp
+++ b/Graphics/drawGlyph.cpp
@@ -4,7 +4,6 @@
 // bugs and problems to <gmsh@geuz.org>.
 
 #include <string.h>
-#include <FL/gl.h>
 #include "drawContext.h"
 #include "Draw.h"
 #include "GmshDefines.h"
@@ -27,9 +26,9 @@ void drawContext::drawString(std::string s, std::string &font_name, int font_enu
       GLdouble pos[4];
       glGetDoublev(GL_CURRENT_RASTER_POSITION, pos);
       double x[3], w[3] = {pos[0], pos[1], pos[2]};
-      gl_font(font_enum, font_size);
-      float width = gl_width(s.c_str());
-      float height = gl_height();
+      SetFont(font_enum, font_size);
+      float width = GetStringWidth(s.c_str());
+      float height = GetStringHeight();
       switch(align){
       case 1: w[0] -= width/2.;                     break; // bottom center
       case 2: w[0] -= width;                        break; // bottom right
@@ -47,8 +46,8 @@ void drawContext::drawString(std::string s, std::string &font_name, int font_enu
   }
   
   if(!CTX::instance()->printing){
-    gl_font(font_enum, font_size);
-    gl_draw(s.c_str());
+    SetFont(font_enum, font_size);
+    DrawString(s.c_str());
   }
   else{
     if(CTX::instance()->print.format == FORMAT_TEX){
@@ -76,8 +75,8 @@ void drawContext::drawString(std::string s, std::string &font_name, int font_enu
       gl2psText(s.c_str(), font_name.c_str(), font_size);
     }
     else{
-      gl_font(font_enum, font_size);
-      gl_draw(s.c_str());
+      SetFont(font_enum, font_size);
+      DrawString(s.c_str());
     }
   }
 }
diff --git a/Graphics/drawGraph2d.cpp b/Graphics/drawGraph2d.cpp
index 6f2d6aaf6501641b726a66e9209c0c741438a95e..e6f84263c142a405c3e87ecdc0f57146c7eeca22 100644
--- a/Graphics/drawGraph2d.cpp
+++ b/Graphics/drawGraph2d.cpp
@@ -3,8 +3,8 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
-#include <FL/gl.h>
 #include "drawContext.h"
+#include "Draw.h"
 #include "PView.h"
 #include "PViewOptions.h"
 #include "PViewData.h"
@@ -149,9 +149,9 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop,
 
   if(!opt->axes) return;
 
-  char label[1024];    
-  float font_h = gl_height() ? gl_height() : 1; // total font height
-  float font_a = font_h - gl_descent(); // height above ref. point
+  char label[1024];
+  float font_h = GetStringHeight() ? GetStringHeight() : 1; // total font height
+  float font_a = font_h - GetStringDescent(); // height above ref. point
 
   const double tic = 5.;
 
@@ -246,8 +246,8 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop,
     int nb = opt->axesTics[0];
     if(opt->axes){
       sprintf(label, opt->axesFormat[0].c_str(), - M_PI * 1.e-4);
-      if((nb - 1) * gl_width(label) > width)
-        nb = (int)(width / gl_width(label)) + 1;
+      if((nb - 1) * GetStringWidth(label) > width)
+        nb = (int)(width / GetStringWidth(label)) + 1;
     }
     if(nb == 1) nb++;
     
@@ -418,13 +418,13 @@ void drawContext::drawGraph2d()
   }
   if(graphs.empty()) return;
 
-  gl_font(CTX::instance()->glFontEnum, CTX::instance()->glFontSize);
-  double xsep = 0., ysep = 5 * gl_height();
+  SetFont(CTX::instance()->glFontEnum, CTX::instance()->glFontSize);
+  double xsep = 0., ysep = 5 * GetStringHeight();
   char label[1024];
   for(unsigned int i = 0; i < graphs.size(); i++){
     PViewOptions *opt = graphs[i]->getOptions();
     sprintf(label, opt->format.c_str(), -M_PI * 1.e-4);
-    xsep = std::max(xsep, gl_width(label));
+    xsep = std::max(xsep, GetStringWidth(label));
   }
   
   for(unsigned int i = 0; i < graphs.size(); i++){
diff --git a/Graphics/drawMesh.cpp b/Graphics/drawMesh.cpp
index 9c2640d70d2eeef871326229a725b15c6666caf7..417457655b966f55bc8b41ca000a44214612b378 100644
--- a/Graphics/drawMesh.cpp
+++ b/Graphics/drawMesh.cpp
@@ -4,7 +4,6 @@
 // bugs and problems to <gmsh@geuz.org>.
 
 #include <math.h>
-#include <FL/gl.h>
 #include "drawContext.h"
 #include "GmshMessage.h"
 #include "GmshDefines.h"
diff --git a/Graphics/drawPost.cpp b/Graphics/drawPost.cpp
index 78d77b1abea8ac6a52cfc19977e02b7659ed3a5d..06615c6bc8a49079f4404ca21c20dc5b92664b93 100644
--- a/Graphics/drawPost.cpp
+++ b/Graphics/drawPost.cpp
@@ -5,7 +5,6 @@
 
 #include <math.h>
 #include <algorithm>
-#include <FL/gl.h>
 #include "GmshConfig.h"
 #include "GmshMessage.h"
 #include "drawContext.h"
@@ -173,7 +172,7 @@ static void applyGeneralRaise(PView *p, int numNodes, int numComp,
     }
 #else
     for(int i = 0; i < 3; i++){
-      int comp = (int)opt->genRaiseFunction[i];
+      int comp = (int)(long int)opt->genRaiseFunction[i];
       if(comp >= 0)
         xyz[k][i] += opt->genRaiseFactor * d[comp];
     }
diff --git a/Graphics/drawScales.cpp b/Graphics/drawScales.cpp
index 4e3644ad4a111cc2de49ff6d93eb31fb4d962681..e2cb4870fca13bcba1c77cd5d011beb8680b17fa 100644
--- a/Graphics/drawScales.cpp
+++ b/Graphics/drawScales.cpp
@@ -3,8 +3,8 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
-#include <FL/gl.h>
 #include "drawContext.h"
+#include "Draw.h"
 #include "PView.h"
 #include "PViewOptions.h"
 #include "PViewData.h"
@@ -89,13 +89,13 @@ static void drawScaleValues(drawContext *ctx, PView *p, double xmin, double ymin
 
   if(!opt->nbIso) return;
 
-  gl_font(CTX::instance()->glFontEnum, CTX::instance()->glFontSize);
-  double font_h = gl_height(); // total font height
-  double font_a = gl_height() - gl_descent(); // height above ref pt
+  SetFont(CTX::instance()->glFontEnum, CTX::instance()->glFontSize);
+  double font_h = GetStringHeight(); // total font height
+  double font_a = GetStringHeight() - GetStringDescent(); // height above ref pt
 
   char label[1024];
   sprintf(label, opt->format.c_str(), -M_PI * 1.e-4);
-  double maxw = gl_width(label);
+  double maxw = GetStringWidth(label);
 
   int nbv = opt->nbIso;
   double f = (opt->intervalsType == PViewOptions::Discrete ||
@@ -164,8 +164,8 @@ static void drawScaleLabel(drawContext *ctx, PView *p, double xmin, double ymin,
   else
     data = p->getData();
 
-  gl_font(CTX::instance()->glFontEnum, CTX::instance()->glFontSize);
-  double font_h = gl_height();
+  SetFont(CTX::instance()->glFontEnum, CTX::instance()->glFontSize);
+  double font_h = GetStringHeight();
 
   char label[1024];
 
@@ -233,13 +233,13 @@ void drawContext::drawScales()
   }
   if(scales.empty()) return;
 
-  gl_font(CTX::instance()->glFontEnum, CTX::instance()->glFontSize);
+  SetFont(CTX::instance()->glFontEnum, CTX::instance()->glFontSize);
   char label[1024];
   double maxw = 0.;
   for(unsigned int i = 0; i < scales.size(); i++) {
     PViewOptions *opt = scales[i]->getOptions();
     sprintf(label, opt->format.c_str(), -M_PI * 1.e-4);
-    maxw = std::max(maxw, gl_width(label));
+    maxw = std::max(maxw, GetStringWidth(label));
   }
 
   const double tic = 10., bar_size = 16.;
@@ -273,13 +273,13 @@ void drawContext::drawScales()
         double h = bar_size;
         double x = xc - (i % 2 ? -xsep / 1.5 : w + xsep / 1.5);
         double y = viewport[1] + ysep + 
-          (i / 2) * (bar_size + tic + 2 * gl_height() + ysep);
+          (i / 2) * (bar_size + tic + 2 * GetStringHeight() + ysep);
         drawScale(this, p, x, y, w, h, tic, 1);
       }
     }
     else{
       double xsep = 20.;
-      double dy = 2. * gl_height();
+      double dy = 2. * GetStringHeight();
       if(scales.size() == 1){
         double ysep = (viewport[3] - viewport[1]) / 6.;
         double w = bar_size, h = viewport[3] - viewport[1] - 2 * ysep - dy;
@@ -297,7 +297,7 @@ void drawContext::drawScales()
       // compute width
       width_prev = width;
       sprintf(label, opt->format.c_str(), -M_PI * 1.e-4);
-      width = bar_size + tic + gl_width(label);
+      width = bar_size + tic + GetStringWidth(label);
       if(opt->showTime){
         char tmp[256];
         sprintf(tmp, opt->format.c_str(), data->getTime(opt->timeStep));
@@ -305,7 +305,7 @@ void drawContext::drawScales()
       }
       else
         sprintf(label, "%s", data->getName().c_str());
-      width = std::max(width, gl_width(label));
+      width = std::max(width, GetStringWidth(label));
       if(i % 2) width_total += std::max(bar_size + width, bar_size + width_prev);
     }
   }