MetalUI

0.1.0

🤘 Metal with SwiftUI
0xLet/MetalUI

What's New

Rendering & Presenting

2020-12-09T01:50:17Z

MetalView

#if os(iOS)
public struct MetalView<Content>: UIViewRepresentable where Content: MetalPresenting
#elseif os(macOS)
public struct MetalView<Content>: NSViewRepresentable where Content: MetalPresenting
#endif

Rendering

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)
}

Presenting

public protocol MetalPresenting: MTKView {
    var renderer: MetalRendering! { get set }
    
    init()
    
    func configure(device: MTLDevice?)
    
    func configureMTKView()
    func renderer(forDevice device: MTLDevice) -> MetalRendering
}

MetalUI

Metal with SwiftUI

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

  • None
Last updated: Mon Nov 11 2024 06:30:07 GMT-1000 (Hawaii-Aleutian Standard Time)