renderer-mvp/asset-pipeline #53
|
@ -24,7 +24,7 @@ pub fn main() !void {
|
||||||
|
|
||||||
fn load(display: coral.Write(ona.gfx.Display), actors: coral.Write(Actors), assets: coral.Write(ona.gfx.Assets)) !void {
|
fn load(display: coral.Write(ona.gfx.Display), actors: coral.Write(Actors), assets: coral.Write(ona.gfx.Assets)) !void {
|
||||||
display.res.width, display.res.height = .{1280, 720};
|
display.res.width, display.res.height = .{1280, 720};
|
||||||
actors.res.body_texture = try assets.res.open_file("actor.bmp");
|
actors.res.body_texture = try assets.res.open_file(coral.files.bundle, "actor.bmp");
|
||||||
actors.res.quad_mesh_2d = try assets.res.open_quad_mesh_2d(@splat(1));
|
actors.res.quad_mesh_2d = try assets.res.open_quad_mesh_2d(@splat(1));
|
||||||
|
|
||||||
try actors.res.instances.push_grow(.{0, 0});
|
try actors.res.instances.push_grow(.{0, 0});
|
||||||
|
|
|
@ -4,8 +4,12 @@ const gfx = @import("../gfx.zig");
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
pub fn bmp_file_desc(arena: *std.heap.ArenaAllocator, path: []const u8) gfx.Assets.Format.Error!gfx.Desc {
|
pub fn bmp_file_desc(
|
||||||
const header = try coral.files.bundle.read_little(path, 0, extern struct {
|
arena: *std.heap.ArenaAllocator,
|
||||||
|
storage: coral.files.Storage,
|
||||||
|
path: []const u8,
|
||||||
|
) gfx.Assets.Format.Error!gfx.Desc {
|
||||||
|
const header = try storage.read_little(path, 0, extern struct {
|
||||||
type: [2]u8 align (1),
|
type: [2]u8 align (1),
|
||||||
file_size: u32 align (1),
|
file_size: u32 align (1),
|
||||||
reserved: [2]u16 align (1),
|
reserved: [2]u16 align (1),
|
||||||
|
@ -47,7 +51,7 @@ pub fn bmp_file_desc(arena: *std.heap.ArenaAllocator, path: []const u8) gfx.Asse
|
||||||
while (buffer_offset < pixels.len) {
|
while (buffer_offset < pixels.len) {
|
||||||
const line = pixels[buffer_offset .. buffer_offset + byte_stride];
|
const line = pixels[buffer_offset .. buffer_offset + byte_stride];
|
||||||
|
|
||||||
if (try coral.files.bundle.read_bytes(path, file_offset, line) != byte_stride) {
|
if (try storage.read_bytes(path, file_offset, line) != byte_stride) {
|
||||||
return error.FormatUnsupported;
|
return error.FormatUnsupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue