【发布时间】:2020-07-12 15:17:28
【问题描述】:
我正在尝试使用以下代码从 url 加载我的纹理:
let textureLoader = MTKTextureLoader(device: device)
var texture: MTLTexture?
let origin = NSString(string: MTKTextureLoader.Origin.bottomLeft.rawValue)
let textureLoaderOptions = [MTKTextureLoader.Option.SRGB: 0, MTKTextureLoader.Option.origin: origin] as [MTKTextureLoader.Option: Any]
do {
texture = try textureLoader.newTexture(URL: my-url-here, options: textureLoaderOptions)
} catch {
print("texture not created")
}
当我从应用程序中加载纹理时,它工作正常,但我似乎无法使用外部 url 让它工作。有人对此有任何运气吗?
我尝试了Load a remote image using MTKTextureLoader,但无法让它按原样工作,而且我还不够了解如何更新它。
【问题讨论】:
-
这能回答你的问题吗? Load a remote image using MTKTextureLoader
-
@warrenm 遗憾的是,没有。我找到了一个,但它不能开箱即用,而且我还不够精明,无法弄清楚如何更新它。