basisu: add bindings for basis-universal (supercompressed textures) (#477)
This commit is contained in:
parent
88558b7d52
commit
4a0802639c
13 changed files with 1075 additions and 0 deletions
45
basisu/src/main.zig
Normal file
45
basisu/src/main.zig
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
pub usingnamespace @import("encoder.zig");
|
||||
pub usingnamespace @import("transcoder.zig");
|
||||
|
||||
pub const BasisTextureFormat = enum(u1) {
|
||||
etc1s = 0,
|
||||
uastc4x4 = 1,
|
||||
};
|
||||
|
||||
// Test
|
||||
|
||||
const t = @import("transcoder.zig");
|
||||
const e = @import("encoder.zig");
|
||||
const testing = @import("std").testing;
|
||||
|
||||
test "reference decls" {
|
||||
testing.refAllDeclsRecursive(t);
|
||||
testing.refAllDeclsRecursive(e);
|
||||
}
|
||||
|
||||
test "encode/transcode" {
|
||||
// Encode
|
||||
e.init_encoder();
|
||||
|
||||
const params = e.CompressorParams.init(1);
|
||||
params.setGenerateMipMaps(true);
|
||||
params.setBasisFormat(.uastc4x4);
|
||||
params.setPackUASTCFlags(.{ .fastest = true });
|
||||
defer params.deinit();
|
||||
|
||||
const image = params.getImageSource(0);
|
||||
image.fill(@embedFile("../test/ziggy.png"), 379, 316, 4);
|
||||
|
||||
const comp = try e.Compressor.init(params);
|
||||
try comp.process();
|
||||
|
||||
// Transcode
|
||||
t.init_transcoder();
|
||||
|
||||
const trans = try t.Transcoder.init(comp.output());
|
||||
defer trans.deinit();
|
||||
|
||||
var out_buf = try testing.allocator.alloc(u8, try trans.calcTranscodedSize(0, 0, .astc_4x4_rgba));
|
||||
defer testing.allocator.free(out_buf);
|
||||
try trans.transcode(out_buf, 0, 0, .astc_4x4_rgba, .{});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue