all: rename parameters foo_mod -> foo

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-04-16 19:14:37 -07:00
parent f1dbc3955c
commit 3d8c28a361
5 changed files with 73 additions and 73 deletions

View file

@ -63,7 +63,7 @@ fn init(
} }
fn afterInit( fn afterInit(
sprite_mod: *gfx.Sprite.Mod, sprite: *gfx.Sprite.Mod,
sprite_pipeline: *gfx.SpritePipeline.Mod, sprite_pipeline: *gfx.SpritePipeline.Mod,
glyphs: *Glyphs.Mod, glyphs: *Glyphs.Mod,
game: *Mod, game: *Mod,
@ -82,12 +82,12 @@ fn afterInit(
// type than the `.physics2d` module's `.location` component if you desire. // type than the `.physics2d` module's `.location` component if you desire.
const r = glyphs.state().regions.get('?').?; const r = glyphs.state().regions.get('?').?;
const player = try sprite_mod.newEntity(); const player = try sprite.newEntity();
try sprite_mod.set(player, .transform, Mat4x4.translate(vec3(-0.02, 0, 0))); try sprite.set(player, .transform, Mat4x4.translate(vec3(-0.02, 0, 0)));
try sprite_mod.set(player, .pipeline, pipeline); try sprite.set(player, .pipeline, pipeline);
try sprite_mod.set(player, .size, vec2(@floatFromInt(r.width), @floatFromInt(r.height))); try sprite.set(player, .size, vec2(@floatFromInt(r.width), @floatFromInt(r.height)));
try sprite_mod.set(player, .uv_transform, Mat3x3.translate(vec2(@floatFromInt(r.x), @floatFromInt(r.y)))); try sprite.set(player, .uv_transform, Mat3x3.translate(vec2(@floatFromInt(r.x), @floatFromInt(r.y))));
sprite_mod.send(.update, .{}); sprite.send(.update, .{});
game.init(.{ game.init(.{
.timer = try mach.Timer.start(), .timer = try mach.Timer.start(),
@ -104,7 +104,7 @@ fn afterInit(
fn tick( fn tick(
engine: *mach.Engine.Mod, engine: *mach.Engine.Mod,
sprite_mod: *gfx.Sprite.Mod, sprite: *gfx.Sprite.Mod,
sprite_pipeline: *gfx.SpritePipeline.Mod, sprite_pipeline: *gfx.SpritePipeline.Mod,
glyphs: *Glyphs.Mod, glyphs: *Glyphs.Mod,
game: *Mod, game: *Mod,
@ -142,7 +142,7 @@ fn tick(
game.state().direction = direction; game.state().direction = direction;
game.state().spawning = spawning; game.state().spawning = spawning;
var player_transform = sprite_mod.get(game.state().player, .transform).?; var player_transform = sprite.get(game.state().player, .transform).?;
var player_pos = player_transform.translation(); var player_pos = player_transform.translation();
if (!spawning and game.state().spawn_timer.read() > 1.0 / 60.0) { if (!spawning and game.state().spawn_timer.read() > 1.0 / 60.0) {
// Spawn new entities // Spawn new entities
@ -156,10 +156,10 @@ fn tick(
const r = glyphs.state().regions.entries.get(rand_index).value; const r = glyphs.state().regions.entries.get(rand_index).value;
const new_entity = try engine.newEntity(); const new_entity = try engine.newEntity();
try sprite_mod.set(new_entity, .transform, Mat4x4.translate(new_pos).mul(&Mat4x4.scaleScalar(0.3))); try sprite.set(new_entity, .transform, Mat4x4.translate(new_pos).mul(&Mat4x4.scaleScalar(0.3)));
try sprite_mod.set(new_entity, .size, vec2(@floatFromInt(r.width), @floatFromInt(r.height))); try sprite.set(new_entity, .size, vec2(@floatFromInt(r.width), @floatFromInt(r.height)));
try sprite_mod.set(new_entity, .uv_transform, Mat3x3.translate(vec2(@floatFromInt(r.x), @floatFromInt(r.y)))); try sprite.set(new_entity, .uv_transform, Mat3x3.translate(vec2(@floatFromInt(r.x), @floatFromInt(r.y))));
try sprite_mod.set(new_entity, .pipeline, game.state().pipeline); try sprite.set(new_entity, .pipeline, game.state().pipeline);
game.state().sprites += 1; game.state().sprites += 1;
} }
} }
@ -189,7 +189,7 @@ fn tick(
transform = transform.mul(&Mat4x4.scale(Vec3.splat(@max(math.cos(game.state().time / 2.0), 0.2)))); transform = transform.mul(&Mat4x4.scale(Vec3.splat(@max(math.cos(game.state().time / 2.0), 0.2))));
// TODO: .set() API is substantially slower due to internals // TODO: .set() API is substantially slower due to internals
// try sprite_mod.set(id, .transform, transform); // try sprite.set(id, .transform, transform);
old_transform.* = transform; old_transform.* = transform;
} }
} }
@ -202,8 +202,8 @@ fn tick(
player_transform = Mat4x4.translate(player_pos).mul( player_transform = Mat4x4.translate(player_pos).mul(
&Mat4x4.scale(Vec3.splat(1.0)), &Mat4x4.scale(Vec3.splat(1.0)),
); );
try sprite_mod.set(game.state().player, .transform, player_transform); try sprite.set(game.state().player, .transform, player_transform);
sprite_mod.send(.update, .{}); sprite.send(.update, .{});
// Perform pre-render work // Perform pre-render work
sprite_pipeline.send(.pre_render, .{}); sprite_pipeline.send(.pre_render, .{});

View file

@ -52,7 +52,7 @@ pub const global_events = .{
fn init( fn init(
engine: *mach.Engine.Mod, engine: *mach.Engine.Mod,
sprite_mod: *gfx.Sprite.Mod, sprite: *gfx.Sprite.Mod,
sprite_pipeline: *gfx.SpritePipeline.Mod, sprite_pipeline: *gfx.SpritePipeline.Mod,
game: *Mod, game: *Mod,
) !void { ) !void {
@ -71,11 +71,11 @@ fn init(
// Create our player sprite // Create our player sprite
const player = try engine.newEntity(); const player = try engine.newEntity();
try sprite_mod.set(player, .transform, Mat4x4.translate(vec3(-0.02, 0, 0))); try sprite.set(player, .transform, Mat4x4.translate(vec3(-0.02, 0, 0)));
try sprite_mod.set(player, .size, vec2(32, 32)); try sprite.set(player, .size, vec2(32, 32));
try sprite_mod.set(player, .uv_transform, Mat3x3.translate(vec2(0, 0))); try sprite.set(player, .uv_transform, Mat3x3.translate(vec2(0, 0)));
try sprite_mod.set(player, .pipeline, pipeline); try sprite.set(player, .pipeline, pipeline);
sprite_mod.send(.update, .{}); sprite.send(.update, .{});
game.init(.{ game.init(.{
.timer = try mach.Timer.start(), .timer = try mach.Timer.start(),
@ -93,7 +93,7 @@ fn init(
fn tick( fn tick(
engine: *mach.Engine.Mod, engine: *mach.Engine.Mod,
sprite_mod: *gfx.Sprite.Mod, sprite: *gfx.Sprite.Mod,
sprite_pipeline: *gfx.SpritePipeline.Mod, sprite_pipeline: *gfx.SpritePipeline.Mod,
game: *Mod, game: *Mod,
) !void { ) !void {
@ -130,7 +130,7 @@ fn tick(
game.state().direction = direction; game.state().direction = direction;
game.state().spawning = spawning; game.state().spawning = spawning;
var player_transform = sprite_mod.get(game.state().player, .transform).?; var player_transform = sprite.get(game.state().player, .transform).?;
var player_pos = player_transform.translation(); var player_pos = player_transform.translation();
if (spawning and game.state().spawn_timer.read() > 1.0 / 60.0) { if (spawning and game.state().spawn_timer.read() > 1.0 / 60.0) {
// Spawn new entities // Spawn new entities
@ -141,10 +141,10 @@ fn tick(
new_pos.v[1] += game.state().rand.random().floatNorm(f32) * 25; new_pos.v[1] += game.state().rand.random().floatNorm(f32) * 25;
const new_entity = try engine.newEntity(); const new_entity = try engine.newEntity();
try sprite_mod.set(new_entity, .transform, Mat4x4.translate(new_pos).mul(&Mat4x4.scale(Vec3.splat(0.3)))); try sprite.set(new_entity, .transform, Mat4x4.translate(new_pos).mul(&Mat4x4.scale(Vec3.splat(0.3))));
try sprite_mod.set(new_entity, .size, vec2(32, 32)); try sprite.set(new_entity, .size, vec2(32, 32));
try sprite_mod.set(new_entity, .uv_transform, Mat3x3.translate(vec2(0, 0))); try sprite.set(new_entity, .uv_transform, Mat3x3.translate(vec2(0, 0)));
try sprite_mod.set(new_entity, .pipeline, game.state().pipeline); try sprite.set(new_entity, .pipeline, game.state().pipeline);
game.state().sprites += 1; game.state().sprites += 1;
} }
} }
@ -171,7 +171,7 @@ fn tick(
transform = transform.mul(&Mat4x4.scaleScalar(@min(math.cos(game.state().time / 2.0), 0.5))); transform = transform.mul(&Mat4x4.scaleScalar(@min(math.cos(game.state().time / 2.0), 0.5)));
// TODO: .set() API is substantially slower due to internals // TODO: .set() API is substantially slower due to internals
// try sprite_mod.set(id, .transform, transform); // try sprite.set(id, .transform, transform);
old_transform.* = transform; old_transform.* = transform;
} }
} }
@ -181,8 +181,8 @@ fn tick(
const speed = 200.0; const speed = 200.0;
player_pos.v[0] += direction.x() * speed * delta_time; player_pos.v[0] += direction.x() * speed * delta_time;
player_pos.v[1] += direction.y() * speed * delta_time; player_pos.v[1] += direction.y() * speed * delta_time;
try sprite_mod.set(game.state().player, .transform, Mat4x4.translate(player_pos)); try sprite.set(game.state().player, .transform, Mat4x4.translate(player_pos));
sprite_mod.send(.update, .{}); sprite.send(.update, .{});
// Perform pre-render work // Perform pre-render work
sprite_pipeline.send(.pre_render, .{}); sprite_pipeline.send(.pre_render, .{});

View file

@ -69,7 +69,7 @@ const text2: []const []const u8 = &.{"!$?😊"};
fn init( fn init(
engine: *mach.Engine.Mod, engine: *mach.Engine.Mod,
text_mod: *Text.Mod, text: *Text.Mod,
text_style: *gfx.TextStyle.Mod, text_style: *gfx.TextStyle.Mod,
game: *Mod, game: *Mod,
) !void { ) !void {
@ -100,8 +100,8 @@ fn init(
// Create some text // Create some text
const player = try engine.newEntity(); const player = try engine.newEntity();
try text_mod.set(player, .pipeline, @intFromEnum(Pipeline.default)); try text.set(player, .pipeline, @intFromEnum(Pipeline.default));
try text_mod.set(player, .transform, Mat4x4.scaleScalar(upscale).mul(&Mat4x4.translate(vec3(0, 0, 0)))); try text.set(player, .transform, Mat4x4.scaleScalar(upscale).mul(&Mat4x4.translate(vec3(0, 0, 0))));
// TODO: better storage mechanism for this // TODO: better storage mechanism for this
// TODO: this is a leak // TODO: this is a leak
@ -110,10 +110,10 @@ fn init(
styles[0] = style1; styles[0] = style1;
styles[1] = style2; styles[1] = style2;
styles[2] = style3; styles[2] = style3;
try text_mod.set(player, .text, text1); try text.set(player, .text, text1);
try text_mod.set(player, .style, styles); try text.set(player, .style, styles);
text_mod.send(.init_pipeline, .{Text.PipelineOptions{ text.send(.init_pipeline, .{Text.PipelineOptions{
.pipeline = @intFromEnum(Pipeline.default), .pipeline = @intFromEnum(Pipeline.default),
}}); }});
@ -137,7 +137,7 @@ fn deinit(engine: *mach.Engine.Mod) !void {
fn tick( fn tick(
engine: *mach.Engine.Mod, engine: *mach.Engine.Mod,
text_mod: *Text.Mod, text: *Text.Mod,
game: *Mod, game: *Mod,
) !void { ) !void {
// TODO(engine): event polling should occur in mach.Engine module and get fired as ECS events. // TODO(engine): event polling should occur in mach.Engine module and get fired as ECS events.
@ -173,7 +173,7 @@ fn tick(
game.state().direction = direction; game.state().direction = direction;
game.state().spawning = spawning; game.state().spawning = spawning;
var player_transform = text_mod.get(game.state().player, .transform).?; var player_transform = text.get(game.state().player, .transform).?;
var player_pos = player_transform.translation().divScalar(upscale); var player_pos = player_transform.translation().divScalar(upscale);
if (spawning and game.state().spawn_timer.read() > 1.0 / 60.0) { if (spawning and game.state().spawn_timer.read() > 1.0 / 60.0) {
// Spawn new entities // Spawn new entities
@ -184,15 +184,15 @@ fn tick(
new_pos.v[1] += game.state().rand.random().floatNorm(f32) * 25; new_pos.v[1] += game.state().rand.random().floatNorm(f32) * 25;
const new_entity = try engine.newEntity(); const new_entity = try engine.newEntity();
try text_mod.set(new_entity, .pipeline, @intFromEnum(Pipeline.default)); try text.set(new_entity, .pipeline, @intFromEnum(Pipeline.default));
try text_mod.set(new_entity, .transform, Mat4x4.scaleScalar(upscale).mul(&Mat4x4.translate(new_pos))); try text.set(new_entity, .transform, Mat4x4.scaleScalar(upscale).mul(&Mat4x4.translate(new_pos)));
// TODO: better storage mechanism for this // TODO: better storage mechanism for this
// TODO: this is a leak // TODO: this is a leak
const styles = try game.state().allocator.alloc(mach.EntityID, 1); const styles = try game.state().allocator.alloc(mach.EntityID, 1);
styles[0] = game.state().style1; styles[0] = game.state().style1;
try text_mod.set(new_entity, .text, text2); try text.set(new_entity, .text, text2);
try text_mod.set(new_entity, .style, styles); try text.set(new_entity, .style, styles);
game.state().texts += 1; game.state().texts += 1;
} }
@ -220,7 +220,7 @@ fn tick(
transform = transform.mul(&Mat4x4.scaleScalar(@min(math.cos(game.state().time / 2.0), 0.5))); transform = transform.mul(&Mat4x4.scaleScalar(@min(math.cos(game.state().time / 2.0), 0.5)));
// TODO: .set() API is substantially slower due to internals // TODO: .set() API is substantially slower due to internals
// try text_mod.set(id, .transform, transform); // try text.set(id, .transform, transform);
old_transform.* = transform; old_transform.* = transform;
} }
} }
@ -230,15 +230,15 @@ fn tick(
const speed = 200.0 / upscale; const speed = 200.0 / upscale;
player_pos.v[0] += direction.x() * speed * delta_time; player_pos.v[0] += direction.x() * speed * delta_time;
player_pos.v[1] += direction.y() * speed * delta_time; player_pos.v[1] += direction.y() * speed * delta_time;
try text_mod.set(game.state().player, .transform, Mat4x4.scaleScalar(upscale).mul(&Mat4x4.translate(player_pos))); try text.set(game.state().player, .transform, Mat4x4.scaleScalar(upscale).mul(&Mat4x4.translate(player_pos)));
text_mod.send(.updated, .{@intFromEnum(Pipeline.default)}); text.send(.updated, .{@intFromEnum(Pipeline.default)});
// Perform pre-render work // Perform pre-render work
text_mod.send(.pre_render, .{@intFromEnum(Pipeline.default)}); text.send(.pre_render, .{@intFromEnum(Pipeline.default)});
// Render a frame // Render a frame
engine.send(.begin_pass, .{gpu.Color{ .r = 1.0, .g = 1.0, .b = 1.0, .a = 1.0 }}); engine.send(.begin_pass, .{gpu.Color{ .r = 1.0, .g = 1.0, .b = 1.0, .a = 1.0 }});
text_mod.send(.render, .{@intFromEnum(Pipeline.default)}); text.send(.render, .{@intFromEnum(Pipeline.default)});
engine.send(.end_pass, .{}); engine.send(.end_pass, .{});
engine.send(.frame_done, .{}); // Present the frame engine.send(.frame_done, .{}); // Present the frame

View file

@ -44,7 +44,7 @@ pub const local_events = .{
.update = .{ .handler = update }, .update = .{ .handler = update },
}; };
fn update(engine: *Engine.Mod, sprite_mod: *Mod, sprite_pipeline: *gfx.SpritePipeline.Mod) !void { fn update(engine: *Engine.Mod, sprite: *Mod, sprite_pipeline: *gfx.SpritePipeline.Mod) !void {
var archetypes_iter = sprite_pipeline.entities.query(.{ .all = &.{ var archetypes_iter = sprite_pipeline.entities.query(.{ .all = &.{
.{ .mach_gfx_sprite_pipeline = &.{ .{ .mach_gfx_sprite_pipeline = &.{
.built, .built,
@ -54,14 +54,14 @@ fn update(engine: *Engine.Mod, sprite_mod: *Mod, sprite_pipeline: *gfx.SpritePip
const ids = archetype.slice(.entity, .id); const ids = archetype.slice(.entity, .id);
const built_pipelines = archetype.slice(.mach_gfx_sprite_pipeline, .built); const built_pipelines = archetype.slice(.mach_gfx_sprite_pipeline, .built);
for (ids, built_pipelines) |pipeline_id, *built| { for (ids, built_pipelines) |pipeline_id, *built| {
try updatePipeline(engine, sprite_mod, sprite_pipeline, pipeline_id, built); try updatePipeline(engine, sprite, sprite_pipeline, pipeline_id, built);
} }
} }
} }
fn updatePipeline( fn updatePipeline(
engine: *Engine.Mod, engine: *Engine.Mod,
sprite_mod: *Mod, sprite: *Mod,
sprite_pipeline: *gfx.SpritePipeline.Mod, sprite_pipeline: *gfx.SpritePipeline.Mod,
pipeline_id: mach.EntityID, pipeline_id: mach.EntityID,
built: *gfx.SpritePipeline.BuiltPipeline, built: *gfx.SpritePipeline.BuiltPipeline,
@ -70,7 +70,7 @@ fn updatePipeline(
const encoder = device.createCommandEncoder(null); const encoder = device.createCommandEncoder(null);
defer encoder.release(); defer encoder.release();
var archetypes_iter = sprite_mod.entities.query(.{ .all = &.{ var archetypes_iter = sprite.entities.query(.{ .all = &.{
.{ .mach_gfx_sprite = &.{ .{ .mach_gfx_sprite = &.{
.uv_transform, .uv_transform,
.transform, .transform,

View file

@ -168,13 +168,13 @@ pub const PipelineOptions = struct {
pipeline_layout: ?*gpu.PipelineLayout = null, pipeline_layout: ?*gpu.PipelineLayout = null,
}; };
fn deinit(text_mod: *Mod) !void { fn deinit(text: *Mod) !void {
for (text_mod.state().pipelines.entries.items(.value)) |*pipeline| pipeline.deinit(text_mod.state().allocator); for (text.state().pipelines.entries.items(.value)) |*pipeline| pipeline.deinit(text.state().allocator);
text_mod.state().pipelines.deinit(text_mod.state().allocator); text.state().pipelines.deinit(text.state().allocator);
} }
fn init(text_mod: *Mod) void { fn init(text: *Mod) void {
text_mod.init(.{ text.init(.{
.allocator = gpa.allocator(), .allocator = gpa.allocator(),
}); });
} }
@ -182,14 +182,14 @@ fn init(text_mod: *Mod) void {
// TODO(text): no args // TODO(text): no args
fn initPipeline( fn initPipeline(
engine: *Engine.Mod, engine: *Engine.Mod,
text_mod: *Mod, text: *Mod,
opt: PipelineOptions, opt: PipelineOptions,
) !void { ) !void {
const device = engine.state().device; const device = engine.state().device;
const pipeline = try text_mod.state().pipelines.getOrPut(text_mod.state().allocator, opt.pipeline); const pipeline = try text.state().pipelines.getOrPut(text.state().allocator, opt.pipeline);
if (pipeline.found_existing) { if (pipeline.found_existing) {
pipeline.value_ptr.*.deinit(text_mod.state().allocator); pipeline.value_ptr.*.deinit(text.state().allocator);
} }
// Prepare texture for the font atlas. // Prepare texture for the font atlas.
@ -204,7 +204,7 @@ fn initPipeline(
}, },
}); });
const texture_atlas = try gfx.Atlas.init( const texture_atlas = try gfx.Atlas.init(
text_mod.state().allocator, text.state().allocator,
img_size.width, img_size.width,
.rgba, .rgba,
); );
@ -343,10 +343,10 @@ fn initPipeline(
// TODO(text): no args // TODO(text): no args
fn updated( fn updated(
engine: *Engine.Mod, engine: *Engine.Mod,
text_mod: *Mod, text: *Mod,
pipeline_id: u32, pipeline_id: u32,
) !void { ) !void {
const pipeline = text_mod.state().pipelines.getPtr(pipeline_id).?; const pipeline = text.state().pipelines.getPtr(pipeline_id).?;
const device = engine.state().device; const device = engine.state().device;
// TODO: make sure these entities only belong to the given pipeline // TODO: make sure these entities only belong to the given pipeline
@ -395,7 +395,7 @@ fn updated(
_ = font_name; // TODO: actually use font name _ = font_name; // TODO: actually use font name
const font_bytes = @import("font-assets").fira_sans_regular_ttf; const font_bytes = @import("font-assets").fira_sans_regular_ttf;
var font = try gfx.Font.initBytes(font_bytes); var font = try gfx.Font.initBytes(font_bytes);
defer font.deinit(text_mod.state().allocator); defer font.deinit(text.state().allocator);
const font_size = engine.entities.getComponent(style, .mach_gfx_text_style, .font_size).?; const font_size = engine.entities.getComponent(style, .mach_gfx_text_style, .font_size).?;
const font_weight = engine.entities.getComponent(style, .mach_gfx_text_style, .font_weight); const font_weight = engine.entities.getComponent(style, .mach_gfx_text_style, .font_weight);
@ -420,16 +420,16 @@ fn updated(
const codepoint = segment[glyph.cluster]; const codepoint = segment[glyph.cluster];
// TODO: use flags(?) to detect newline, or at least something more reliable? // TODO: use flags(?) to detect newline, or at least something more reliable?
if (codepoint != '\n') { if (codepoint != '\n') {
const region = try pipeline.regions.getOrPut(text_mod.state().allocator, .{ const region = try pipeline.regions.getOrPut(text.state().allocator, .{
.index = glyph.glyph_index, .index = glyph.glyph_index,
.size = @bitCast(font_size), .size = @bitCast(font_size),
}); });
if (!region.found_existing) { if (!region.found_existing) {
const rendered_glyph = try font.render(text_mod.state().allocator, glyph.glyph_index, .{ const rendered_glyph = try font.render(text.state().allocator, glyph.glyph_index, .{
.font_size_px = run.font_size_px, .font_size_px = run.font_size_px,
}); });
if (rendered_glyph.bitmap) |bitmap| { if (rendered_glyph.bitmap) |bitmap| {
var glyph_atlas_region = try pipeline.texture_atlas.reserve(text_mod.state().allocator, rendered_glyph.width, rendered_glyph.height); var glyph_atlas_region = try pipeline.texture_atlas.reserve(text.state().allocator, rendered_glyph.width, rendered_glyph.height);
pipeline.texture_atlas.set(glyph_atlas_region, @as([*]const u8, @ptrCast(bitmap.ptr))[0 .. bitmap.len * 4]); pipeline.texture_atlas.set(glyph_atlas_region, @as([*]const u8, @ptrCast(bitmap.ptr))[0 .. bitmap.len * 4]);
texture_update = true; texture_update = true;
@ -454,7 +454,7 @@ fn updated(
const r = region.value_ptr.*; const r = region.value_ptr.*;
const size = vec2(@floatFromInt(r.width), @floatFromInt(r.height)); const size = vec2(@floatFromInt(r.width), @floatFromInt(r.height));
try glyphs.append(text_mod.state().allocator, .{ try glyphs.append(text.state().allocator, .{
.pos = vec2( .pos = vec2(
origin_x + glyph.offset.x(), origin_x + glyph.offset.x(),
origin_y - (size.y() - glyph.offset.y()), origin_y - (size.y() - glyph.offset.y()),
@ -479,7 +479,7 @@ fn updated(
// TODO: could writeBuffer check for zero? // TODO: could writeBuffer check for zero?
if (glyphs.items.len > 0) encoder.writeBuffer(pipeline.glyphs, 0, glyphs.items); if (glyphs.items.len > 0) encoder.writeBuffer(pipeline.glyphs, 0, glyphs.items);
defer glyphs.deinit(text_mod.state().allocator); defer glyphs.deinit(text.state().allocator);
if (texture_update) { if (texture_update) {
// rgba32_pixels // rgba32_pixels
// TODO: use proper texture dimensions here // TODO: use proper texture dimensions here
@ -505,10 +505,10 @@ fn updated(
// TODO(text): no args // TODO(text): no args
fn preRender( fn preRender(
engine: *Engine.Mod, engine: *Engine.Mod,
text_mod: *Mod, text: *Mod,
pipeline_id: u32, pipeline_id: u32,
) !void { ) !void {
const pipeline = text_mod.state().pipelines.get(pipeline_id).?; const pipeline = text.state().pipelines.get(pipeline_id).?;
// Update uniform buffer // Update uniform buffer
const proj = Mat4x4.projection2D(.{ const proj = Mat4x4.projection2D(.{
@ -534,10 +534,10 @@ fn preRender(
// TODO(text): no args // TODO(text): no args
fn render( fn render(
engine: *Engine.Mod, engine: *Engine.Mod,
text_mod: *Mod, text: *Mod,
pipeline_id: u32, pipeline_id: u32,
) !void { ) !void {
const pipeline = text_mod.state().pipelines.get(pipeline_id).?; const pipeline = text.state().pipelines.get(pipeline_id).?;
// Draw the text batch // Draw the text batch
const pass = engine.state().pass; const pass = engine.state().pass;