#if os(iOS)
public struct MetalView<Content>: UIViewRepresentable where Content: MetalPresenting
#elseif os(macOS)
public struct MetalView<Content>: NSViewRepresentable where Content: MetalPresenting
#endif
public protocol MetalRendering: NSObject, MTKViewDelegate {
var commandQueue: MTLCommandQueue? { get set }
var renderPipelineState: MTLRenderPipelineState? { get set }
var vertexBuffer: MTLBuffer? { get set }
var vertices: [MetalRenderingVertex] { get set }
init()
init(
vertices: [MetalRenderingVertex],
device: MTLDevice
)
func createCommandQueue(device: MTLDevice)
func createPipelineState(
withLibrary library: MTLLibrary?,
forDevice device: MTLDevice
)
func createBuffers(device: MTLDevice)
// MARK: MTKViewDelegate
func mtkView(_ view: MTKView, drawableSizeWillChange size: CGSize)
func draw(in view: MTKView)
}
public protocol MetalPresenting: MTKView {
var renderer: MetalRendering! { get set }
init()
func configure(device: MTLDevice?)
func configureMTKView()
func renderer(forDevice device: MTLDevice) -> MetalRendering
}