Lazarus
Programming => Graphics and Multimedia => Graphics => Topic started by: Key-Real 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
-
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 (https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_pg_concepts/opengl_pg_concepts.html) and the Wiki Modern OpenGl using macOS (https://wiki.lazarus.freepascal.org/OpenGL_Tutorial#Modern_OpenGL_using_macOS) which links to examples.
-
Могу предложить 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
-
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