Recent

Author Topic: Metal Framework for MacOS  (Read 4003 times)

ChrisR

  • Full Member
  • ***
  • Posts: 110
Metal Framework for MacOS
« on: August 22, 2018, 04:09:07 pm »
I have created a few Lazarus projects that can be compiled for Apple's new Metal API.
  https://github.com/neurolabusc/Metal-Demos
Most of these projects can also be compiled to support OpenGL 3.3 Core - providing support for Windows, Linux and older Macs. By keeping a thin layer for either OpenGL or Metal, one can retain most of Lazarus' "write once, compile everywhere" magic.

  The documentation is sparse, but both the main page and the line project include some useful information
  https://github.com/neurolabusc/Metal-Demos/tree/master/lines

The Metal support uses Ryan Joseph's lazmetalcontrol
  https://github.com/genericptr/Metal-Framework
My examples all use Lazarus. However, Ryan's repository also includes some examples of how to use Metal directly from freepascal without Lazarus.

Ryan deserves incredible credit - has framework provides a great a very simple way to use this powerful but complex API.

Igor Kokarev

  • Jr. Member
  • **
  • Posts: 92
Re: Metal Framework for MacOS
« Reply #1 on: December 26, 2019, 12:16:46 pm »
Hi Chris,

Thanks for your demos with Metal API on macOS!

Can you check MeshProj project with Lazarus 2.0.6?

We have the following error during compilation on macOS High Sierra:

glcocoanscontext(506,45) Error: identifier idents no member "KeyEvent"
glcocoanscontext(512,45) Error: identifier idents no member "KeyEvent"
glcocoanscontext(518,45) Error: identifier idents no member "KeyEvent"

Project: Metal-Demos-master/mesh/MeshProj.lpi

trev

  • Sr. Member
  • ****
  • Posts: 407
  • Former Delphi 7 and Delphi 10.2 User
Re: Metal Framework for MacOS
« Reply #2 on: December 26, 2019, 01:43:36 pm »
I've added this overlooked macOS gem to the Wiki: https://wiki.freepascal.org/Metal_Framework
o Lazarus v2.1.0 r62452, FPC v3.3.1 r42644, macOS 10.14.6 (with sup update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

Igor Kokarev

  • Jr. Member
  • **
  • Posts: 92
Re: Metal Framework for MacOS
« Reply #3 on: December 26, 2019, 02:06:35 pm »
Thanks, one correction:
"to use Metal you will need macOS 10.12 (Sierra)"

Metal was introduced in macOS 10.11 (El Capitan).

ChrisR

  • Full Member
  • ***
  • Posts: 110
Re: Metal Framework for MacOS
« Reply #4 on: December 26, 2019, 02:50:59 pm »
The Lazarus 2.0.6 release for MacOS contained a regression for OpenGL support.
   https://bugs.freepascal.org/view.php?id=35797
GLCocoaNSContext.pas now requires "cocoa_extra" in uses section. You can either edit your copy or get a new copy from trunk
  https://github.com/graemeg/lazarus/tree/upstream/components/opengl

Alternatively, you can use Lazarus trunk rather than 2.0.6.   

trev

  • Sr. Member
  • ****
  • Posts: 407
  • Former Delphi 7 and Delphi 10.2 User
Re: Metal Framework for MacOS
« Reply #5 on: December 26, 2019, 11:28:27 pm »
Thanks, one correction:
"to use Metal you will need macOS 10.12 (Sierra)"

Metal was introduced in macOS 10.11 (El Capitan).

Thanks, fixed!
o Lazarus v2.1.0 r62452, FPC v3.3.1 r42644, macOS 10.14.6 (with sup update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

Igor Kokarev

  • Jr. Member
  • **
  • Posts: 92
Re: Metal Framework for MacOS
« Reply #6 on: December 28, 2019, 06:37:13 pm »
Chris,

Thanks! I'll try next week.