Post

Replies

Boosts

Views

Activity

Reply to How to make the Swift UI window display the frosted glass effect normally in the metal immersive space
this is my code: @main struct SwiftUItest: App { init() {} var body: some Scene { //... ImmersiveSpace(id: "ImmersiveSpace"){ CompositorLayer(configuration: ContentStageConfiguration()){ layerRenderer in Renderer(layerRenderer: layerRenderer) //CompositorLayer is a necessary layer for loading metal in vision os. } } } class Renderer: NSObject { public init(layerRenderer: LayerRenderer, sceneData: SceneData) { self.layerRenderer = layerRenderer super.init() startRenderLoop() } func startRenderLoop() { Task { do { openWindow(id:"origin window")//Open swift ui window try await arSession.run([worldTracking]) } catch { fatalError("Failed to initialize ARSession") } let renderThread = Thread { while true { //metal rendering model //.... guard let encoder = commandBuffer.makeRenderCommandEncoder(descriptor: renderPassDescriptor) else { return } scene.originSkyBox.update(drawable) scene.originSkyBox.render(encoder: encoder) encoder.endEncoding() drawable.encodePresent(commandBuffer: commandBuffer) commandBuffer.commit() // --------- end render a frame frame.endSubmission() } } renderThread.name = "RenderThread" renderThread.start() } } } I hope someone can help me solve this problem,Thanks
Mar ’24