Recent

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

Key-Real

  • Full Member
  • ***
  • Posts: 185
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?

Thx

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • 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 »

Seenkao

  • Hero Member
  • *****
  • Posts: 546
    • New ZenGL.
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.

https://github.com/daar/GLPT

also look - https://forum.lazarus.freepascal.org/index.php/topic,42306.0.html - there you can choose OpenGL instead of Metal
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

ChrisR

  • Full Member
  • ***
  • Posts: 247
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:
   https://github.com/neurolabusc/AppleSiliconForNeuroimaging




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):

https://github.com/neurolabusc/OpenGLCoreTutorials
https://github.com/neurolabusc/plyview

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 glopts.inc
  https://github.com/neurolabusc/Metal-Demos

 

TinyPortal © 2005-2018