Now I think you have enough background knowledge to get started with Metal. Let's start building our demo together.
We will go through the code together and explain the most important parts of it in how to draw this triangle.
Open GameViewController.swift
, and you will see that we have to first import Metal framework. Then, if you checked the first two attributes, you should see something like this:
let device = { MTLCreateSystemDefaultDevice() }() let metalLayer = { CAMetalLayer() }()
Creating devices is considered the first step in your Metal code. Devices are the abstractions over GPU in your iOS device. Devices conform to protocol MTLDevice
, and you can consider...