Author Topic: create OpenGL Context under OSX  (Read 662 times)


  • New Member
  • *
  • Posts: 21
create OpenGL Context under OSX
« on: April 16, 2021, 08:57:17 pm »
I wanna create an OpenGL Context under OSX whithout using 3th Party Frameworks Like Glut, SDL or glfw and such.
How to?



  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1523
  • Former Delphi 1-7, 10.2 user
Re: create OpenGL Context under OSX
« Reply #1 on: April 17, 2021, 12:35:00 am »
Bear in mind that the macOS OpenGL implementation is stuck at version 4.1 from 2010 and was deprecated by Apple on the release of macOS 10.14 (Mojave).

As to the how, see the Apple Documentation and the Wiki Modern OpenGl using macOS which links to examples.
« Last Edit: April 17, 2021, 12:57:19 am by trev »
Lazarus 2.1 r65061 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.3 r65500 FPC 3.3.1 r49634 macOS 11.5.1 aarch64 Xcode 12.5.1
Lazarus 2.1 r61574 FPC 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM


  • Full Member
  • ***
  • Posts: 178
Re: create OpenGL Context under OSX
« Reply #2 on: April 17, 2021, 12:52:46 am »
Могу предложить ZenGL только для x86-64?
Но наверно вам больше подойдёт для начала GLPT
Вручную создавать контекст для MacOS - это не лучшая идея.

google translate: Can I suggest ZenGL for x86-64 only?
But GLPT is probably more suitable for you to start.
Manually creating context for macOS is not a good idea.

also look -,42306.0.html - there you can choose OpenGL instead of Metal


  • Full Member
  • ***
  • Posts: 214
Re: create OpenGL Context under OSX
« Reply #3 on: April 17, 2021, 01:08:25 pm »

MacOS can run legacy OpenGL up to version 2.1. If you want to use more recent features, you must use the OpenGL Core specification which has no fixed function pipeline and removes all legacy calls. Therefore, common targets for MacOS are OpenGL 2.1 or OpenGL Core 3.3. Note that with Windows and Linux the OpenGL runs in "compatibility" mode, which allows you to mix legacy OpenGL as well as modern OpenGL. Therefore, if you Lazarus OpenGL program works on MacOS, it should be easy to compile on Linux/Windows, but the reverse is not true.

So for MacOS you have three choices (all demonstrated by the projects below):
 1. Compile Legacy OpenGL and use no features greater than OpenGL 2.1
 2. Use OpenGL Core (e.g. OpenGL 3.3) and never use any legacy functions.
 3. Use Metal for your MacOS projects, and OpenGL for Windows/Linux
If you want to have your OpenGL projects run on a M1 Mac, be aware there are some quirks, which I mention here:

Here are Lazarus projects that compile with "modern" OpenGL core on MacOS, Windows and Linux, without any other components (The "Legacy" folder provides legacy OpenGL for some of these projects):

For MacOS, here are projects that will compile using Metal (e.g. "clrbar.lpi"), but some of these projects can also be compiled as OpenGL (for projects with the "_gl" in the filename, e.g. "clrbar_gl.lpi"). The OpenGL projects can be either compiled to legacy OpenGL or OpenGL core, depending on the "{$DEFINE COREGL}" compiler directive in


TinyPortal © 2005-2018