@@ -28,16 +28,18 @@ pub fn init(
28
28
core .on_tick = app_mod .id .tick ;
29
29
core .on_exit = app_mod .id .deinit ;
30
30
31
+ const main_window = core .windows .getValue (core .main_window );
32
+
31
33
// 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" ));
33
35
defer shader_module .release ();
34
36
35
37
// Blend state describes how rendered colors get blended
36
38
const blend = gpu.BlendState {};
37
39
38
40
// Color target describes e.g. the pixel format of the window we are rendering to.
39
41
const color_target = gpu.ColorTargetState {
40
- .format = core . windows . get ( core . main_window , .framebuffer_format ) .? ,
42
+ .format = main_window .framebuffer_format ,
41
43
.blend = & blend ,
42
44
};
43
45
@@ -58,7 +60,7 @@ pub fn init(
58
60
.entry_point = "vertex_main" ,
59
61
},
60
62
};
61
- const pipeline = core .device .createRenderPipeline (& pipeline_descriptor );
63
+ const pipeline = main_window .device .createRenderPipeline (& pipeline_descriptor );
62
64
63
65
// Store our render pipeline in our module's state, so we can access it later on.
64
66
app .* = .{
@@ -78,14 +80,16 @@ pub fn tick(core: *mach.Core, app: *App) !void {
78
80
}
79
81
}
80
82
83
+ const main_window = core .windows .getValue (core .main_window );
84
+
81
85
// Grab the back buffer of the swapchain
82
86
// TODO(Core)
83
- const back_buffer_view = core .swap_chain .getCurrentTextureView ().? ;
87
+ const back_buffer_view = main_window .swap_chain .getCurrentTextureView ().? ;
84
88
defer back_buffer_view .release ();
85
89
86
90
// Create a command encoder
87
91
const label = @tagName (mach_module ) ++ ".tick" ;
88
- const encoder = core .device .createCommandEncoder (&.{ .label = label });
92
+ const encoder = main_window .device .createCommandEncoder (&.{ .label = label });
89
93
defer encoder .release ();
90
94
91
95
// Begin render pass
@@ -112,7 +116,7 @@ pub fn tick(core: *mach.Core, app: *App) !void {
112
116
// Submit our commands to the queue
113
117
var command = encoder .finish (&.{ .label = label });
114
118
defer command .release ();
115
- core .queue .submit (&[_ ]* gpu.CommandBuffer {command });
119
+ main_window .queue .submit (&[_ ]* gpu.CommandBuffer {command });
116
120
117
121
// update the window title every second
118
122
if (app .title_timer .read () >= 1.0 ) {
0 commit comments