Pass size to render callback.
This commit is contained in:
parent
4823d8113c
commit
705c6b6740
|
@ -16,7 +16,7 @@ struct DemoView: View {
|
|||
vgerRestore(vger)
|
||||
}
|
||||
|
||||
func draw(vger: vgerContext) {
|
||||
func draw(vger: vgerContext, size: CGSize) {
|
||||
vgerSave(vger)
|
||||
|
||||
let bezPaint = vgerLinearGradient(vger, .init(x: 50, y: 450), .init(x: 100, y: 450), cyan, magenta, 0.0)
|
||||
|
|
|
@ -6,7 +6,7 @@ struct HelloView: View {
|
|||
let cyan = SIMD4<Float>(0,1,1,1)
|
||||
|
||||
var body: some View {
|
||||
VgerView { vger in
|
||||
VgerView { vger, _ in
|
||||
vgerText(vger, "Hello world. This is V'Ger.", cyan, 0)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ struct TigerView: View {
|
|||
|
||||
var body: some View {
|
||||
GeometryReader { geom in
|
||||
VgerView { vger in
|
||||
VgerView { vger, _ in
|
||||
model.draw(vger: vger, size: geom.size)
|
||||
}
|
||||
.gesture(MagnificationGesture().onChanged({ scale in
|
||||
|
|
|
@ -9,7 +9,7 @@ class Renderer: NSObject, MTKViewDelegate {
|
|||
var vg = vgerNew(0)
|
||||
var device: MTLDevice!
|
||||
var queue: MTLCommandQueue!
|
||||
var renderCallback : ((OpaquePointer) -> Void)?
|
||||
var renderCallback : ((vgerContext, CGSize) -> Void)?
|
||||
|
||||
static let MaxBuffers = 3
|
||||
private let inflightSemaphore = DispatchSemaphore(value: MaxBuffers)
|
||||
|
@ -46,7 +46,7 @@ class Renderer: NSObject, MTKViewDelegate {
|
|||
semaphore.signal()
|
||||
}
|
||||
|
||||
renderCallback?(vg!)
|
||||
renderCallback?(vg!, size)
|
||||
|
||||
if let renderPassDescriptor = view.currentRenderPassDescriptor, let currentDrawable = view.currentDrawable {
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ import vger
|
|||
|
||||
public struct VgerView: NSViewRepresentable {
|
||||
|
||||
var renderCallback : (OpaquePointer) -> Void
|
||||
var renderCallback : (vgerContext, CGSize) -> Void
|
||||
|
||||
public init(renderCallback: @escaping (OpaquePointer) -> Void) {
|
||||
public init(renderCallback: @escaping (vgerContext, CGSize) -> Void) {
|
||||
self.renderCallback = renderCallback
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,9 @@ public struct VgerView: NSViewRepresentable {
|
|||
|
||||
public struct VgerView: UIViewRepresentable {
|
||||
|
||||
var renderCallback : (OpaquePointer) -> Void
|
||||
var renderCallback : (vgerContext, CGSize) -> Void
|
||||
|
||||
public init(renderCallback: @escaping (OpaquePointer) -> Void) {
|
||||
public init(renderCallback: @escaping (vgerContext, CGSize) -> Void) {
|
||||
self.renderCallback = renderCallback
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public struct VgerView: UIViewRepresentable {
|
|||
|
||||
struct VgerView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VgerView(renderCallback: { vger in
|
||||
VgerView(renderCallback: { vger, _ in
|
||||
vgerText(vger, "hello world", SIMD4<Float>(repeating: 1), 0)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue