-24
src/gfx.rs
-24
src/gfx.rs
···
51
51
model: model::Model,
52
52
instances: Vec<Instance>,
53
53
instance_buffer: wgpu::Buffer,
54
-
diffuse_bind_group: wgpu::BindGroup,
55
-
diffuse_texture: texture::Texture,
56
54
}
57
55
58
56
struct LightState {
59
57
uniform: LightUniform,
60
58
buffer: wgpu::Buffer,
61
-
bind_group_layout: wgpu::BindGroupLayout,
62
59
bind_group: wgpu::BindGroup,
63
60
}
64
61
···
268
265
let depth_texture =
269
266
texture::Texture::create_depth_texture(&device, &surface_config, "depth_texture");
270
267
271
-
let diffuse_bytes = include_bytes!("../res/happy-tree.png");
272
-
let diffuse_texture =
273
-
texture::Texture::from_bytes(&device, &queue, diffuse_bytes, "happy_tree.png").unwrap();
274
-
275
268
let texture_bind_group_layout =
276
269
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
277
270
entries: &[
···
295
288
label: Some("texture_bind_group_layout"),
296
289
});
297
290
298
-
let diffuse_bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
299
-
layout: &texture_bind_group_layout,
300
-
entries: &[
301
-
wgpu::BindGroupEntry {
302
-
binding: 0,
303
-
resource: wgpu::BindingResource::TextureView(&diffuse_texture.view),
304
-
},
305
-
wgpu::BindGroupEntry {
306
-
binding: 1,
307
-
resource: wgpu::BindingResource::Sampler(&diffuse_texture.sampler),
308
-
},
309
-
],
310
-
label: Some("diffuse_bind_group"),
311
-
});
312
291
313
292
let camera = camera::Camera {
314
293
eye: vec3(0., 1., 2.),
···
516
495
model: obj_model,
517
496
instances,
518
497
instance_buffer,
519
-
diffuse_bind_group,
520
-
diffuse_texture,
521
498
},
522
499
light: LightState {
523
500
uniform: light_uniform,
524
501
buffer: light_buffer,
525
502
bind_group: light_bind_group,
526
-
bind_group_layout: light_bind_group_layout,
527
503
},
528
504
}
529
505
}