Index: FL/Enumerations.H
===================================================================
--- FL/Enumerations.H	(revision 10844)
+++ FL/Enumerations.H	(working copy)
@@ -1094,7 +1094,8 @@
   FL_RGB8	= 64,
   FL_MULTISAMPLE= 128,
   FL_STEREO     = 256,
-  FL_FAKE_SINGLE = 512	// Fake single buffered windows using double-buffer
+  FL_FAKE_SINGLE = 512,	// Fake single buffered windows using double-buffer
+  FL_OPENGL3    = 1024
 };
 
 // image alpha blending
Index: FL/Fl_Gl_Window.H
===================================================================
--- FL/Fl_Gl_Window.H	(revision 10862)
+++ FL/Fl_Gl_Window.H	(working copy)
@@ -149,6 +149,7 @@
    - \c FL_DEPTH - depth buffer
    - \c FL_STENCIL - stencil buffer
    - \c FL_MULTISAMPLE - multisample antialiasing
+   - \c FL_OPENGL3 - use OpenGL version 3.0 or more when running Mac OS.
    
    FL_RGB and FL_SINGLE have a value of zero, so they
    are "on" unless you give FL_INDEX or FL_DOUBLE.
@@ -167,6 +168,19 @@
    
    mode() must not be called within draw() since it
    changes the current context.
+   
+   \note On the <b>MSWindows and Unix/Linux platforms</b>, FLTK produces
+   contexts for the highest OpenGL version supported by the hardware. Such contexts
+   are also compatible with lower OpenGL versions. On the <b>Apple OS X
+   platform</b>, it is necessary to decide whether the source code targets
+   OpenGL versions higher or lower than 3.0. By default, FLTK
+   creates contexts adequate for OpenGL versions 1 and 2. To get contexts
+   for OpenGL 3.0 or higher, the <tt>FL_OPENGL3</tt> flag and Mac OS
+   version 10.7 or higher are required (in that case the context is NOT 
+   compatible with OpenGL versions 1 or 2). The <tt>FL_OPENGL3</tt> flag has no
+   effect on non-Apple platforms.
+   
+   \version the <tt>FL_OPENGL3</tt> flag appeared in version 1.3.4
    */
   int mode(int a) {return mode(a,0);}
   /** Set the OpenGL capabilites of the window using platform-specific data.
@@ -179,8 +193,6 @@
    <p><b>Mac OS X platform</b>: attributes belong to the <tt>CGLPixelFormatAttribute</tt> enumeration
    (defined by including <tt><OpenGL/OpenGL.h></tt>, e.g., <tt>kCGLPFADoubleBuffer</tt>)
    and may be followed by adequate attribute values.
-   The pair <tt>kCGLPFAOpenGLProfile, kCGLOGLPVersion_3_2_Core</tt> allows to create an OpenGL V3.2 profile
-   under Mac OS X 10.7 and above.
    */
   int mode(const int *a) {return mode(0, a);}
   /** Returns a pointer to the GLContext that this window is using.
Index: FL/gl.h
===================================================================
--- FL/gl.h	(revision 10853)
+++ FL/gl.h	(working copy)
@@ -55,6 +55,10 @@
 #  endif
 
 #  ifdef __APPLE__
+#    include <AvailabilityMacros.h>
+#    if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+#      include <OpenGL/gl3.h> // defines OpenGL 3.0+ functions
+#    endif
 #    include <OpenGL/gl.h>
 #    ifdef FL_LIBRARY
 #      include <FL/x.H>
Index: documentation/src/opengl.dox
===================================================================
--- documentation/src/opengl.dox	(revision 10788)
+++ documentation/src/opengl.dox	(working copy)
@@ -449,7 +449,45 @@
 a collection of 3D objects in a \p csGroup.  The scene is redrawn
 after this call.
 
+\section opengl3 Using OpenGL 3.0 (or higher versions)
 
+The examples subdirectory contains OpenGL3test.cxx an example program
+showing how to use OpenGL 3.0 with FLTK in a cross-platform fashion.
+OpenGL3-glut-test.cxx therein shows how to use FLTK's GLUT compatibility
+and OpenGL 3.
+
+\par MSWindows and Unix/Linux platforms 
+FLTK creates contexts
+implementing the highest OpenGL version supported by the hardware,
+which are also compatible with lower OpenGL versions. Thus, FLTK allows
+source code targeting any version of OpenGL. However, on these platforms,
+OpenGL versions above 1.1 require to load at runtime pointers to all used OpenGL 
+functions. It is very convenient to use the GLEW library which performs all of this. 
+Using GLEW involves 3 steps:
+\n
+1) include <GL/glew.h> in all source files before <FL/gl.h> as follows:
+\code
+#ifndef __APPLE__
+#  if defined(WIN32)
+#    define GLEW_STATIC 1
+#  endif
+#  include <GL/glew.h>
+#endif
+#include <FL/gl.h>
+\endcode
+2) call glewInit() once before drawing the first OpenGL window. The example 
+programs mentioned above show one possible way to do that. \n
+3) link with libGLEW.so (on Unix/Linux) or libglew32.a (on MSWindows)
+
+\par Mac OS X platform
+FLTK creates by default contexts implementing OpenGL versions 1 or 2. 
+To access OpenGL 3.0 (or higher versions),
+add the <tt>FL_OPENGL3</tt> flag when calling Fl_Gl_Window::mode(int a)
+or glutInitDisplayMode().
+The resulting context will implement the highest OpenGL version 
+supported by the hardware. Also, Mac OS version 10.7 or more is required. 
+No change to the build process is needed. Don't use the GLEW library.
+
 \htmlonly
 <hr>
 <table summary="navigation bar" width="100%" border="0">
Index: examples/OpenGL3-glut-test.cxx
===================================================================
--- examples/OpenGL3-glut-test.cxx	(revision 0)
+++ examples/OpenGL3-glut-test.cxx	(working copy)
@@ -0,0 +1,206 @@
+#include <stdio.h>
+#ifndef __APPLE__
+#  if defined(WIN32)
+#    define GLEW_STATIC 1 // to use a static glew library
+#  endif
+#  include <GL/glew.h>  // for glewInit()
+#endif
+#include <FL/glut.h> // must be after <GL/glew.h>
+
+#if defined(__APPLE__) && FL_MAJOR_VERSION*10000+FL_MINOR_VERSION*100+FL_PATCH_VERSION < 10304
+#error This program requires FLTK 1.3.4 or above
+#endif
+
+
+// Globals
+// Real programs don't use globals :-D
+// Data would normally be read from files
+GLfloat vertices[] = {	-1.0f,0.0f,0.0f,
+  0.0f,1.0f,0.0f,
+  0.0f,0.0f,0.0f };
+GLfloat colours[] = {	1.0f, 0.0f, 0.0f,
+  0.0f, 1.0f, 0.0f,
+  0.0f, 0.0f, 1.0f };
+GLfloat vertices2[] = {	0.0f,0.0f,0.0f,
+  0.0f,-1.0f,0.0f,
+  1.0f,0.0f,0.0f };
+
+// two vertex array objects, one for each object drawn
+unsigned int vertexArrayObjID[2];
+// three vertex buffer objects in this example
+unsigned int vertexBufferObjID[3];
+
+
+void printShaderInfoLog(GLint shader)
+{
+  int infoLogLen = 0;
+  GLchar *infoLog;
+  
+  glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLen);
+  if (infoLogLen > 0)
+  {
+    infoLog = new GLchar[infoLogLen];
+    // error check for fail to allocate memory omitted
+    glGetShaderInfoLog(shader,infoLogLen, NULL, infoLog);
+    fprintf(stderr, "InfoLog:\n%s\n", infoLog);
+    delete [] infoLog;
+  }
+}
+
+
+void init(void)
+{
+  // Would load objects from file here - but using globals in this example
+  
+  // Allocate Vertex Array Objects
+  glGenVertexArrays(2, &vertexArrayObjID[0]);
+  // Setup first Vertex Array Object
+  glBindVertexArray(vertexArrayObjID[0]);
+  glGenBuffers(2, vertexBufferObjID);
+  
+  // VBO for vertex data
+  glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID[0]);
+  glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), vertices, GL_STATIC_DRAW);
+  glVertexAttribPointer((GLuint)0, 3, GL_FLOAT, GL_FALSE, 0, 0);
+  glEnableVertexAttribArray(0);
+  
+  // VBO for colour data
+  glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID[1]);
+  glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), colours, GL_STATIC_DRAW);
+  glVertexAttribPointer((GLuint)1, 3, GL_FLOAT, GL_FALSE, 0, 0);
+  glEnableVertexAttribArray(1);
+  
+  // Setup second Vertex Array Object
+  glBindVertexArray(vertexArrayObjID[1]);
+  glGenBuffers(1, &vertexBufferObjID[2]);
+  
+  // VBO for vertex data
+  glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID[2]);
+  glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), vertices2, GL_STATIC_DRAW);
+  glVertexAttribPointer((GLuint)0, 3, GL_FLOAT, GL_FALSE, 0, 0);
+  glEnableVertexAttribArray(0);
+  
+  glBindVertexArray(0);
+}
+
+
+void initShaders(void)
+{
+  GLuint p, f, v;
+  glClearColor (1.0, 1.0, 1.0, 0.0);
+  
+  v = glCreateShader(GL_VERTEX_SHADER);
+  f = glCreateShader(GL_FRAGMENT_SHADER);
+  
+#ifdef __APPLE__
+#define SHADING_LANG_VERS "140"
+#else
+#define SHADING_LANG_VERS "130"
+#endif
+  // load shaders
+  const char *vv = "#version "SHADING_LANG_VERS"\n\
+  in  vec3 in_Position;\
+  in  vec3 in_Color;\
+  out vec3 ex_Color;\
+  void main(void)\
+  {\
+    ex_Color = in_Color;\
+    gl_Position = vec4(in_Position, 1.0);\
+  }";
+  
+  const char *ff = "#version "SHADING_LANG_VERS"\n\
+  precision highp float;\
+  in  vec3 ex_Color;\
+  out vec4 out_Color;\
+  void main(void)\
+  {\
+    out_Color = vec4(ex_Color,1.0);\
+  }";
+  
+  glShaderSource(v, 1, &vv,NULL);
+  glShaderSource(f, 1, &ff,NULL);
+  
+  GLint compiled;
+  
+  glCompileShader(v);
+  glGetShaderiv(v, GL_COMPILE_STATUS, &compiled);
+  if (!compiled)
+  {
+    fprintf(stderr, "Vertex shader not compiled.\n");
+    printShaderInfoLog(v);
+  }
+  
+  glCompileShader(f);
+  glGetShaderiv(f, GL_COMPILE_STATUS, &compiled);
+  if (!compiled)
+  {
+    fprintf(stderr, "Fragment shader not compiled.\n");
+    printShaderInfoLog(f);
+  }
+  
+  p = glCreateProgram();
+  
+  glAttachShader(p,v);
+  glAttachShader(p,f);
+  glBindAttribLocation(p,0, "in_Position");
+  glBindAttribLocation(p,1, "in_Color");
+
+  glLinkProgram(p);
+  glGetProgramiv(p, GL_LINK_STATUS, &compiled);
+  if (compiled != GL_TRUE) {
+    GLchar *infoLog; GLint length;
+    glGetProgramiv(p, GL_INFO_LOG_LENGTH, &length);
+    infoLog = new GLchar[length];
+    glGetProgramInfoLog(p, length, NULL, infoLog);
+    fprintf(stderr, "Link log=%s\n", infoLog);
+    delete[] infoLog;
+  }
+  glUseProgram(p);
+}
+
+
+void display(void)
+{
+  // clear the screen
+  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+  
+  glBindVertexArray(vertexArrayObjID[0]);	// First VAO
+  glDrawArrays(GL_TRIANGLES, 0, 3);	// draw first object
+  
+  glBindVertexArray(vertexArrayObjID[1]);		// select second VAO
+  glVertexAttrib3f((GLuint)1, 1.0, 0.0, 0.0); // set constant color attribute
+  glDrawArrays(GL_TRIANGLES, 0, 3);	// draw second object
+ }
+
+
+int main (int argc, char* argv[])
+{
+  Fl::use_high_res_GL(true);
+  glutInit(&argc, argv);
+  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | FL_OPENGL3);
+  glutInitWindowSize(400,400);
+  glutCreateWindow("Triangle Test");
+#ifndef __APPLE__
+// on WIN and X11 platforms, call glewInit() and check for success
+  GLenum err = glewInit();
+  if (GLEW_OK != err)
+  {
+    fprintf(stderr, "glewInit failed, aborting.\n");
+    exit (1);
+  }
+  fprintf(stderr, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
+#endif
+  int gl_version_major;
+  const char *glv = (const char*)glGetString(GL_VERSION);
+  fprintf(stderr, "OpenGL version %s supported\n", glv);
+  sscanf(glv, "%d", &gl_version_major);
+  if (gl_version_major < 3) {
+    fprintf(stderr, "\nThis platform does not support OpenGL V3\n\n");
+    exit(1);
+  }
+  initShaders();
+  init();
+  glutDisplayFunc(display);
+  glutMainLoop();
+  return 0;
+}
Index: examples/OpenGL3test.cxx
===================================================================
--- examples/OpenGL3test.cxx	(revision 0)
+++ examples/OpenGL3test.cxx	(working copy)
@@ -0,0 +1,224 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <FL/Fl.H>
+#include <FL/x.H>
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Gl_Window.H>
+#include <FL/Fl_Light_Button.H>
+#include <FL/Fl_Text_Display.H>
+#include <FL/Fl_Text_Buffer.H>
+#ifndef __APPLE__
+#  if defined(WIN32)
+#    define GLEW_STATIC 1
+#  endif
+#  include <GL/glew.h>
+#endif
+#include <FL/gl.h>
+
+#if defined(__APPLE__) && FL_MAJOR_VERSION*10000+FL_MINOR_VERSION*100+FL_PATCH_VERSION < 10304
+#error This program requires FLTK 1.3.4 or above
+#endif
+
+
+void add_output(const char *format, ...);
+
+
+static void glew_initialize() {
+  static bool first = true;
+  if (first) {
+      first = false;
+#ifndef __APPLE__
+      GLenum err = glewInit(); // defines pters to functions of OpenGL V 1.2 and above
+      add_output("%d=glewInit()\n",err);
+#endif
+      add_output("GL_VERSION=%s\n",(const char *)glGetString(GL_VERSION));
+  }
+}
+
+class SimpleGL3Window : public Fl_Gl_Window {
+  GLuint shaderProgram;
+  GLuint vertexArrayObject;
+  GLuint vertexBuffer;
+  
+  GLint positionUniform;
+  GLint colourAttribute;
+  GLint positionAttribute;
+  int gl_version_major;
+public:
+  SimpleGL3Window(int x, int y, int w, int h) :  Fl_Gl_Window(x, y, w, h) {
+    mode(FL_RGB8 | FL_DOUBLE | FL_OPENGL3);
+    shaderProgram = 0;
+  }
+  void draw() {
+    if (!shaderProgram) {
+      glew_initialize();
+      sscanf((const char *)glGetString(GL_VERSION), "%d", &gl_version_major);
+      if (gl_version_major < 3) {
+        add_output("\nThis platform does not support OpenGL V3\n\n");
+      }
+      if (gl_version_major < 2) return;
+      GLuint  vs;
+      GLuint  fs;
+      int Mslv, mslv; // major and minor version numbers of the shading language
+      sscanf((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), "%d.%d", &Mslv, &mslv);
+      add_output("Shading Language Version=%d.%d\n",Mslv, mslv);
+      const char *vss_format="#version %d%d\n\
+      uniform vec2 p;\
+      in vec4 position;\
+      in vec4 colour;\
+      out vec4 colourV;\
+      void main (void)\
+      {\
+      colourV = colour;\
+      gl_Position = vec4(p, 0.0, 0.0) + position;\
+      }";
+      char vss_string[300]; const char *vss = vss_string;
+      sprintf(vss_string, vss_format, Mslv, mslv);
+      const char *fss_format="#version %d%d\n\
+      in vec4 colourV;\
+      out vec4 fragColour;\
+      void main(void)\
+      {\
+      fragColour = colourV;\
+      }";
+      char fss_string[200]; const char *fss = fss_string;
+      sprintf(fss_string, fss_format, Mslv, mslv);
+      GLint err; GLchar CLOG[1000]; GLsizei length;
+      vs = glCreateShader(GL_VERTEX_SHADER);
+      glShaderSource(vs, 1, &vss, NULL);
+      glCompileShader(vs);
+      glGetShaderiv(vs, GL_COMPILE_STATUS, &err);
+      if (err != GL_TRUE) {
+	glGetShaderInfoLog(vs, sizeof(CLOG), &length, CLOG); 
+	add_output("vs ShaderInfoLog=%s\n",CLOG);
+	}
+      fs = glCreateShader(GL_FRAGMENT_SHADER);
+      glShaderSource(fs, 1, &fss, NULL);
+      glCompileShader(fs);
+      glGetShaderiv(fs, GL_COMPILE_STATUS, &err);
+      if (err != GL_TRUE) {
+	glGetShaderInfoLog(fs, sizeof(CLOG), &length, CLOG); 
+	add_output("fs ShaderInfoLog=%s\n",CLOG);
+	}     
+      // Attach the shaders
+      shaderProgram = glCreateProgram();
+      glAttachShader(shaderProgram, vs);
+      glAttachShader(shaderProgram, fs);
+      if (gl_version_major >=3) glBindFragDataLocation(shaderProgram, 0, "fragColour");
+      glLinkProgram(shaderProgram);
+      glGetProgramiv(shaderProgram, GL_LINK_STATUS, &err);
+      if (err != GL_TRUE) {
+        glGetProgramInfoLog(shaderProgram, sizeof(CLOG), &length, CLOG);
+        add_output("link log=%s\n", CLOG);
+      }
+      // Get pointers to uniforms and attributes
+      positionUniform = glGetUniformLocation(shaderProgram, "p");
+      colourAttribute = glGetAttribLocation(shaderProgram, "colour");
+      positionAttribute = glGetAttribLocation(shaderProgram, "position");
+      glDeleteShader(vs);
+      glDeleteShader(fs);
+      add_output("positionUniform: %i, colourAttribute: %i, positionAttribute: %i\n",positionUniform,colourAttribute,positionAttribute);
+      
+      // Upload vertices (1st four values in a row) and colours (following four values)
+      GLfloat vertexData[]= { -0.5,-0.5,0.0,1.0,   1.0,0.0,0.0,1.0,
+        -0.5, 0.5,0.0,1.0,   0.0,1.0,0.0,1.0,
+        0.5, 0.5,0.0,1.0,   0.0,0.0,1.0,1.0,
+        0.5,-0.5,0.0,1.0,   1.0,1.0,1.0,1.0};
+      if (gl_version_major >=3) glGenVertexArrays(1, &vertexArrayObject);
+      if (gl_version_major >=3) glBindVertexArray(vertexArrayObject);
+      
+      glGenBuffers(1, &vertexBuffer);
+      glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
+      glBufferData(GL_ARRAY_BUFFER, 4*8*sizeof(GLfloat), vertexData, GL_STATIC_DRAW);
+      
+      glEnableVertexAttribArray((GLuint)positionAttribute);
+      glEnableVertexAttribArray((GLuint)colourAttribute  );
+      glVertexAttribPointer((GLuint)positionAttribute, 4, GL_FLOAT, GL_FALSE, 8*sizeof(GLfloat), 0);
+      glVertexAttribPointer((GLuint)colourAttribute  , 4, GL_FLOAT, GL_FALSE, 8*sizeof(GLfloat), (char*)0+4*sizeof(GLfloat));
+    }
+    else if ((!valid())) {
+#if FL_MAJOR_VERSION*10000+FL_MINOR_VERSION*100+FL_PATCH_VERSION >= 10304
+      glViewport(0, 0, pixel_w(), pixel_h());
+#else
+      glViewport(0, 0, w(), h());
+#endif
+    }
+    glClearColor(0.08, 0.8, 0.8, 1.0);
+    glClear(GL_COLOR_BUFFER_BIT);
+    glUseProgram(shaderProgram);
+    GLfloat p[]={0,0};
+    glUniform2fv(positionUniform, 1, (const GLfloat *)&p);
+    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+  }
+  int handle(int event) {
+    if (event == FL_PUSH && gl_version_major >= 2) {
+      static float factor = 1.1;
+      GLfloat data[4];
+      glGetBufferSubData(GL_ARRAY_BUFFER, 0, 4*sizeof(GLfloat), data);
+      if (data[0] < -0.88 || data[0] > -0.5) factor = 1/factor;
+      data[0] *= factor;
+      glBufferSubData(GL_ARRAY_BUFFER, 0, 4*sizeof(GLfloat), data);
+      glGetBufferSubData(GL_ARRAY_BUFFER, 24*sizeof(GLfloat), 4*sizeof(GLfloat), data);
+      data[0] *= factor;
+      glBufferSubData(GL_ARRAY_BUFFER, 24*sizeof(GLfloat), 4*sizeof(GLfloat), data);
+      redraw();
+      add_output("push\n");
+      return 1;
+    }
+    return Fl_Gl_Window::handle(event);
+  }
+  void reset() { shaderProgram = 0; }
+};
+
+
+void toggle_double(Fl_Widget *wid, void *data) {
+  static bool doublebuff = true;
+  doublebuff = !doublebuff;
+  SimpleGL3Window *glwin = (SimpleGL3Window*)data;
+  int flags = glwin->mode();
+  if (doublebuff) flags |= FL_DOUBLE; else flags &= ~FL_DOUBLE;
+  glwin->mode(flags);
+  glwin->reset();
+}
+
+
+Fl_Text_Display *output; // shared between output_win() and add_output()
+
+void output_win()
+{
+  Fl_Window *win = new Fl_Window(300, 0, 500,300);
+  output = new Fl_Text_Display(0,0,win->w(), win->h()-20);
+  Fl_Light_Button *lb = new Fl_Light_Button(0, 280, 500, 20, "Double-Buffered");
+  lb->callback(toggle_double);
+  lb->user_data(win->window()->child(0));
+  lb->value(1);
+  win->end();
+  win->resizable(output);
+  output->buffer(new Fl_Text_Buffer());
+}
+
+
+void add_output(const char *format, ...)
+{
+  va_list args;
+  char line_buffer[10000];
+  va_start(args, format);
+  vsnprintf(line_buffer, sizeof(line_buffer)-1, format, args);
+  va_end(args);
+  output->insert(line_buffer);
+}
+
+
+int main(int argc, char **argv)
+{
+  Fl::use_high_res_GL(1);
+  Fl_Window *topwin = new Fl_Window(800, 300);
+  SimpleGL3Window *win = new SimpleGL3Window(0, 0, 300, 300);
+  win->end();
+  output_win();
+  topwin->end();
+  topwin->resizable(win);
+  topwin->label("Click GL panel to reshape");
+  topwin->show();
+  Fl::run();
+}
Index: src/Fl_cocoa.mm
===================================================================
--- src/Fl_cocoa.mm	(revision 10861)
+++ src/Fl_cocoa.mm	(working copy)
@@ -2718,11 +2718,12 @@
 #define NSOpenGLPFAOpenGLProfile      (NSOpenGLPixelFormatAttribute)99
 #define kCGLPFAOpenGLProfile          NSOpenGLPFAOpenGLProfile
 #define NSOpenGLProfileVersionLegacy  (NSOpenGLPixelFormatAttribute)0x1000
+#define NSOpenGLProfileVersion3_2Core  (NSOpenGLPixelFormatAttribute)0x3200
 #define kCGLOGLPVersion_Legacy        NSOpenGLProfileVersionLegacy
 #endif
     if (fl_mac_os_version >= 100700) {
       attribs[n++] = NSOpenGLPFAOpenGLProfile;
-      attribs[n++] = NSOpenGLProfileVersionLegacy; // for now, no public FLTK API for OpenGL v3 profiles
+      attribs[n++] =  (m & FL_OPENGL3) ? NSOpenGLProfileVersion3_2Core : NSOpenGLProfileVersionLegacy;
     }
   } else {
     while (alistp[n] && n < 30) {
