The Skung Rockification of Ziggy Skungdust and the SIMD's

This commit is contained in:
2024-05-13 01:11:03 +10:00
parent b62cd056b5
commit 6c44476062
40 changed files with 2066 additions and 386 deletions

View File

@ -44,16 +44,10 @@ extension ContentManager
public mutating func create(texture: Image, params: Texture2DParameters = .init()) throws -> Texture2D
{
try texture.pixels.withUnsafeBytes
{
raw in
let data = raw.baseAddress!
let rendTex = try renderer.createTexture(
data: data, width: texture.width, height: texture.height,
filter: params.magFilter, mipMode: params.mipMode)
resources.append(rendTex)
return Texture2D(id: rendTex, width: texture.width, height: texture.height)
}
let rendTex = try renderer.createTexture(image: texture,
filter: params.magFilter, mipMode: params.mipMode)
resources.append(rendTex)
return Texture2D(id: rendTex, width: texture.width, height: texture.height)
}
public func getResource(_ path: String) throws -> URL
@ -153,6 +147,23 @@ extension ContentManager
let renderResource = try self.create(mesh: mesh)
return renderResource as! T
}
if T.self == RenderMesh<VMeshVertex>.self
{
guard let mesh = resource as? Mesh<VMeshVertex> else { throw ContentError.loadFailure }
let renderResource = try self.create(mesh: mesh)
return renderResource as! T
}
if T.self == Image.self
{
guard let image = resource as? Image else { throw ContentError.loadFailure }
return image as! T
}
if T.self == Texture2D.self
{
guard let image = resource as? Image else { throw ContentError.loadFailure }
let texture2D = try self.create(texture: image)
return texture2D as! T
}
throw ContentError.loadFailure
}