Replace main.rs with lib.rs

pull/373/head
OisinA 2 years ago
parent b6c0b4fd2b
commit b987573e93

@ -27,7 +27,7 @@ Ray/path tracing is often too computationally expensive for most real-time appli
Before we can get into that though, we need to add a light to our scene. Before we can get into that though, we need to add a light to our scene.
```rust ```rust
// main.rs // lib.rs
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] #[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
struct LightUniform { struct LightUniform {
@ -307,7 +307,7 @@ where
With that done we can create another render pipeline for our light. With that done we can create another render pipeline for our light.
```rust ```rust
// main.rs // lib.rs
let light_render_pipeline = { let light_render_pipeline = {
let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Light Pipeline Layout"), label: Some("Light Pipeline Layout"),

@ -594,7 +594,7 @@ where
I found a cobblestone texture with a matching normal map and created a `debug_material` for that. I found a cobblestone texture with a matching normal map and created a `debug_material` for that.
```rust ```rust
// main.rs // lib.rs
impl State { impl State {
async fn new(window: &Window) -> Result<Self> { async fn new(window: &Window) -> Result<Self> {
// ... // ...

@ -10,7 +10,7 @@ Once 0.13 comes out I'll port the WGSL code to the new syntax and this example s
I've been putting this off for a while. Implementing a camera isn't specifically related to using WGPU properly, but it's been bugging me so let's do it. I've been putting this off for a while. Implementing a camera isn't specifically related to using WGPU properly, but it's been bugging me so let's do it.
`main.rs` is getting a little crowded, so let's create a `camera.rs` file to put our camera code. The first things we're going to put in it are some imports and our `OPENGL_TO_WGPU_MATRIX`. `lib.rs` is getting a little crowded, so let's create a `camera.rs` file to put our camera code. The first things we're going to put in it are some imports and our `OPENGL_TO_WGPU_MATRIX`.
```rust ```rust
use cgmath::*; use cgmath::*;
@ -254,9 +254,9 @@ impl CameraController {
} }
``` ```
## Cleaning up `main.rs` ## Cleaning up `lib.rs`
First things first we need to delete `Camera` and `CameraController` as well as the extra `OPENGL_TO_WGPU_MATRIX` from `main.rs`. Once you've done that import `camera.rs`. First things first we need to delete `Camera` and `CameraController` as well as the extra `OPENGL_TO_WGPU_MATRIX` from `lib.rs`. Once you've done that import `camera.rs`.
```rust ```rust
mod model; mod model;

Loading…
Cancel
Save