Recent

Author Topic: OpenGL is deprecated. How to use Metal?  (Read 7205 times)

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 370
OpenGL is deprecated. How to use Metal?
« on: June 07, 2018, 08:23:08 pm »
Quote
"Apps built using OpenGL and OpenCL will continue to run in macOS 10.14, but these legacy technologies are deprecated in macOS 10.14. Games and graphics-intensive apps that use OpenGL should now adopt Metal."

https://developer.apple.com/macos/whats-new/

How to use Metal with Lazarus?

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: OpenGL is deprecated. How to use Metal?
« Reply #1 on: June 07, 2018, 09:05:02 pm »
Translate the headers...
BTW: OpenGL is by no means deprecated on all platforms.
Specialize a type, not a var.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: OpenGL is deprecated. How to use Metal?
« Reply #2 on: June 07, 2018, 09:14:11 pm »
For corporate solutions there’s MoltenGL library

It's actually for OpenGL ES  (rather than OpenGL), but the company might provide OpenGL wrapper as well, with the news of the OpenGL deprecation.
« Last Edit: June 07, 2018, 09:19:08 pm by skalogryz »

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: OpenGL is deprecated. How to use Metal?
« Reply #3 on: June 07, 2018, 09:32:22 pm »
Metal is only supported on iOS, macOS, tvOS.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: OpenGL is deprecated. How to use Metal?
« Reply #4 on: June 07, 2018, 10:49:14 pm »
Metal is only supported on iOS, macOS, tvOS.
You might want to put it easier - Metal is only supported on Apple platforms.

Metal is pretty much Apple's version of Vulkan API (started by Khronos Group).
Presumably, it has the similar functionality, with some Apple's needs on top (such as using Objective-C on the top).
Apple didn't adopt Vulkan API, because it started its own development either earlier (or in parallel with Vulkan API).
Metal API was initially released in 2014, while Vulkan API followed only 2 years after that in 2016.

That makes Metal quite easy to use in FPC world, since it's supports ObjC out of the box.
The only issue is to have Metal headers handy.
« Last Edit: June 07, 2018, 10:50:58 pm by skalogryz »

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: OpenGL is deprecated. How to use Metal?
« Reply #5 on: June 07, 2018, 10:52:32 pm »
How to use Metal with Lazarus?

If you want to see what the Metal framework API looks like in Pascal, download the iOS interface units from here:

https://github.com/genericptr

These units were based on iOS 8.0, which already included Metal. Metal was not added to macOS until 10.11, so the interface units from that site for macOS don't include it (units were based on 10.10).

If Metal is what you're interested in using, you'll need to use the parser given on that site. Metal is an Objective C API, not just straight C, so you'll need a parser that can parse ObjC header files in addition to C header files. That parser is not perfect (few are) but it should do most of the parsing work for you. I recently used it to parse both the Mapbox header files (ObjC) and the TensorFlow header files (C) and it saved me a lot of trouble.

Remember that to do ObjC classes from Pascal, you'll need to use FPC's $modeswitch ObjectiveC1. See the FPC wiki for extensive documentation on that Pascal "dialect" if you're unfamiliar with it.

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 370
Re: OpenGL is deprecated. How to use Metal?
« Reply #6 on: June 08, 2018, 10:13:30 am »
Thanks for your replies!

The only problem is to find Freepascal headers for Metal 2 for macOS.

It's a serious problem for us.

Phil,

Please can you give me a direct link to the parser of ObjC headers to Pascal? I will try it.
« Last Edit: June 08, 2018, 11:00:39 am by Igor Kokarev »

 

TinyPortal © 2005-2018