Skip to content

Commit ffed03b

Browse files
committed
core: comments, examples: fix core-custom-entrypoint
1 parent 59826b4 commit ffed03b

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

examples/core-custom-entrypoint/App.zig

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,18 @@ pub fn init(
2828
core.on_tick = app_mod.id.tick;
2929
core.on_exit = app_mod.id.deinit;
3030

31+
const main_window = core.windows.getValue(core.main_window);
32+
3133
// Create our shader module
32-
const shader_module = core.device.createShaderModuleWGSL("shader.wgsl", @embedFile("shader.wgsl"));
34+
const shader_module = main_window.device.createShaderModuleWGSL("shader.wgsl", @embedFile("shader.wgsl"));
3335
defer shader_module.release();
3436

3537
// Blend state describes how rendered colors get blended
3638
const blend = gpu.BlendState{};
3739

3840
// Color target describes e.g. the pixel format of the window we are rendering to.
3941
const color_target = gpu.ColorTargetState{
40-
.format = core.windows.get(core.main_window, .framebuffer_format).?,
42+
.format = main_window.framebuffer_format,
4143
.blend = &blend,
4244
};
4345

@@ -58,7 +60,7 @@ pub fn init(
5860
.entry_point = "vertex_main",
5961
},
6062
};
61-
const pipeline = core.device.createRenderPipeline(&pipeline_descriptor);
63+
const pipeline = main_window.device.createRenderPipeline(&pipeline_descriptor);
6264

6365
// Store our render pipeline in our module's state, so we can access it later on.
6466
app.* = .{
@@ -78,14 +80,16 @@ pub fn tick(core: *mach.Core, app: *App) !void {
7880
}
7981
}
8082

83+
const main_window = core.windows.getValue(core.main_window);
84+
8185
// Grab the back buffer of the swapchain
8286
// TODO(Core)
83-
const back_buffer_view = core.swap_chain.getCurrentTextureView().?;
87+
const back_buffer_view = main_window.swap_chain.getCurrentTextureView().?;
8488
defer back_buffer_view.release();
8589

8690
// Create a command encoder
8791
const label = @tagName(mach_module) ++ ".tick";
88-
const encoder = core.device.createCommandEncoder(&.{ .label = label });
92+
const encoder = main_window.device.createCommandEncoder(&.{ .label = label });
8993
defer encoder.release();
9094

9195
// Begin render pass
@@ -112,7 +116,7 @@ pub fn tick(core: *mach.Core, app: *App) !void {
112116
// Submit our commands to the queue
113117
var command = encoder.finish(&.{ .label = label });
114118
defer command.release();
115-
core.queue.submit(&[_]*gpu.CommandBuffer{command});
119+
main_window.queue.submit(&[_]*gpu.CommandBuffer{command});
116120

117121
// update the window title every second
118122
if (app.title_timer.read() >= 1.0) {

src/Core.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ windows: mach.Objects(
4646
framebuffer_format: gpu.Texture.Format = .bgra8_unorm,
4747

4848
/// Width of the framebuffer in texels (read-only)
49+
/// Will be updated to reflect the actual framebuffer dimensions after window creation.
4950
framebuffer_width: u32 = 1920 / 2,
5051

5152
/// Height of the framebuffer in texels (read-only)
53+
/// Will be updated to reflect the actual framebuffer dimensions after window creation.
5254
framebuffer_height: u32 = 1080 / 2,
5355

5456
/// Vertical sync mode, prevents screen tearing.

0 commit comments

Comments
 (0)