mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Move files to their corresponding directory
This commit is contained in:
parent
a7bc21ab70
commit
2de2203ded
3
.gitignore
vendored
3
.gitignore
vendored
@ -13,5 +13,4 @@ Cargo.lock
|
|||||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||||
*.pdb
|
*.pdb
|
||||||
|
|
||||||
|
**/test-data
|
||||||
libs/mvt
|
|
||||||
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
12
.idea/mapr.iml
generated
Normal file
12
.idea/mapr.iml
generated
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="CPP_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/examples" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/mapr.iml" filepath="$PROJECT_DIR$/.idea/mapr.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
18
.idea/runConfigurations/Run_downloader.xml
generated
Normal file
18
.idea/runConfigurations/Run_downloader.xml
generated
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="Run downloader" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
||||||
|
<option name="command" value="run --bin download_tiles" />
|
||||||
|
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||||
|
<option name="channel" value="DEFAULT" />
|
||||||
|
<option name="requiredFeatures" value="true" />
|
||||||
|
<option name="allFeatures" value="false" />
|
||||||
|
<option name="emulateTerminal" value="false" />
|
||||||
|
<option name="withSudo" value="false" />
|
||||||
|
<option name="backtrace" value="SHORT" />
|
||||||
|
<envs />
|
||||||
|
<option name="isRedirectInput" value="false" />
|
||||||
|
<option name="redirectInputPath" value="" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
18
.idea/runConfigurations/Run_mapr.xml
generated
Normal file
18
.idea/runConfigurations/Run_mapr.xml
generated
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="Run mapr" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
||||||
|
<option name="command" value="run --bin mapr" />
|
||||||
|
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||||
|
<option name="channel" value="DEFAULT" />
|
||||||
|
<option name="requiredFeatures" value="true" />
|
||||||
|
<option name="allFeatures" value="false" />
|
||||||
|
<option name="emulateTerminal" value="false" />
|
||||||
|
<option name="withSudo" value="false" />
|
||||||
|
<option name="backtrace" value="SHORT" />
|
||||||
|
<envs />
|
||||||
|
<option name="isRedirectInput" value="false" />
|
||||||
|
<option name="redirectInputPath" value="" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
7
.idea/vcs.xml
generated
Normal file
7
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/libs/vector_tile/spec" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
23
Cargo.lock
generated
23
Cargo.lock
generated
@ -1525,7 +1525,6 @@ dependencies = [
|
|||||||
"lyon",
|
"lyon",
|
||||||
"lyon_path",
|
"lyon_path",
|
||||||
"mbutiles",
|
"mbutiles",
|
||||||
"mvt",
|
|
||||||
"pollster",
|
"pollster",
|
||||||
"proj",
|
"proj",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
@ -1673,17 +1672,6 @@ dependencies = [
|
|||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "mvt"
|
|
||||||
version = "0.7.0"
|
|
||||||
dependencies = [
|
|
||||||
"log 0.4.14",
|
|
||||||
"num-traits",
|
|
||||||
"pointy",
|
|
||||||
"protobuf",
|
|
||||||
"thiserror",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "naga"
|
name = "naga"
|
||||||
version = "0.7.1"
|
version = "0.7.1"
|
||||||
@ -2012,15 +2000,6 @@ dependencies = [
|
|||||||
"plotters-backend",
|
"plotters-backend",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pointy"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "139bf0e592367a743213257b5d7d2b4b899ebdd7377441e8901d38e9c6994901"
|
|
||||||
dependencies = [
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pollster"
|
name = "pollster"
|
||||||
version = "0.2.4"
|
version = "0.2.4"
|
||||||
@ -2980,8 +2959,6 @@ name = "vector-tile"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
"num-traits",
|
|
||||||
"pointy",
|
|
||||||
"protobuf",
|
"protobuf",
|
||||||
"protobuf-codegen-pure",
|
"protobuf-codegen-pure",
|
||||||
"tile-grid",
|
"tile-grid",
|
||||||
|
|||||||
@ -18,7 +18,6 @@ pollster = "0.2"
|
|||||||
|
|
||||||
|
|
||||||
# Vector riles
|
# Vector riles
|
||||||
mvt = { path = "libs/mvt" }
|
|
||||||
vector-tile = { path = "libs/vector_tile" }
|
vector-tile = { path = "libs/vector_tile" }
|
||||||
geo = "0.18.0"
|
geo = "0.18.0"
|
||||||
geo-types = "0.7"
|
geo-types = "0.7"
|
||||||
@ -53,16 +52,10 @@ criterion = "0.3"
|
|||||||
test-env-log = "0.2"
|
test-env-log = "0.2"
|
||||||
env_logger = "0.8" # Used for test-env-log
|
env_logger = "0.8" # Used for test-env-log
|
||||||
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "mapr"
|
name = "mapr"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "lyon_test"
|
|
||||||
path = "src/lyon_test/main.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "download_tiles"
|
name = "download_tiles"
|
||||||
path = "src/lyon_test/tile_downloader.rs"
|
path = "src/tile_downloader.rs"
|
||||||
|
|||||||
@ -1,80 +0,0 @@
|
|||||||
use winit::event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent};
|
|
||||||
use winit::event_loop::{ControlFlow, EventLoop};
|
|
||||||
use winit::window::Window;
|
|
||||||
|
|
||||||
use crate::state::State;
|
|
||||||
|
|
||||||
mod fps_meter;
|
|
||||||
mod multisampling;
|
|
||||||
mod piplines;
|
|
||||||
mod shader;
|
|
||||||
mod shader_ffi;
|
|
||||||
mod state;
|
|
||||||
mod tesselation;
|
|
||||||
mod tile_downloader;
|
|
||||||
mod texture;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
env_logger::init();
|
|
||||||
println!("== wgpu example ==");
|
|
||||||
println!("Controls:");
|
|
||||||
println!(" Arrow keys: scrolling");
|
|
||||||
println!(" PgUp/PgDown: zoom in/out");
|
|
||||||
println!(" a/z: increase/decrease the stroke width");
|
|
||||||
|
|
||||||
let event_loop = EventLoop::new();
|
|
||||||
let window = Window::new(&event_loop).unwrap();
|
|
||||||
let mut state = pollster::block_on(State::new(&window));
|
|
||||||
|
|
||||||
window.request_redraw();
|
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| {
|
|
||||||
match event {
|
|
||||||
Event::WindowEvent {
|
|
||||||
ref event,
|
|
||||||
window_id,
|
|
||||||
} if window_id == window.id() => {
|
|
||||||
if !state.input(event) {
|
|
||||||
match event {
|
|
||||||
WindowEvent::CloseRequested
|
|
||||||
| WindowEvent::KeyboardInput {
|
|
||||||
input:
|
|
||||||
KeyboardInput {
|
|
||||||
state: ElementState::Pressed,
|
|
||||||
virtual_keycode: Some(VirtualKeyCode::Escape),
|
|
||||||
..
|
|
||||||
},
|
|
||||||
..
|
|
||||||
} => *control_flow = ControlFlow::Exit,
|
|
||||||
WindowEvent::Resized(physical_size) => {
|
|
||||||
state.resize(*physical_size);
|
|
||||||
}
|
|
||||||
WindowEvent::ScaleFactorChanged { new_inner_size, .. } => {
|
|
||||||
// new_inner_size is &mut so w have to dereference it twice
|
|
||||||
state.resize(**new_inner_size);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Event::RedrawRequested(_) => {
|
|
||||||
state.update();
|
|
||||||
match state.render() {
|
|
||||||
Ok(_) => {}
|
|
||||||
// Reconfigure the surface if lost
|
|
||||||
Err(wgpu::SurfaceError::Lost) => state.resize(state.size),
|
|
||||||
// The system is out of memory, we should probably quit
|
|
||||||
Err(wgpu::SurfaceError::OutOfMemory) => *control_flow = ControlFlow::Exit,
|
|
||||||
// All other errors (Outdated, Timeout) should be resolved by the next frame
|
|
||||||
Err(e) => eprintln!("{:?}", e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Event::MainEventsCleared => {
|
|
||||||
// RedrawRequested will only trigger once, unless we manually
|
|
||||||
// request it.
|
|
||||||
window.request_redraw();
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
210
src/main.rs
210
src/main.rs
@ -1,189 +1,33 @@
|
|||||||
use std::iter;
|
use winit::event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent};
|
||||||
|
use winit::event_loop::{ControlFlow, EventLoop};
|
||||||
|
use winit::window::Window;
|
||||||
|
|
||||||
use winit::{
|
use crate::state::State;
|
||||||
event::*,
|
|
||||||
event_loop::{ControlFlow, EventLoop},
|
|
||||||
window::{Window, WindowBuilder},
|
|
||||||
};
|
|
||||||
|
|
||||||
struct State {
|
mod fps_meter;
|
||||||
surface: wgpu::Surface,
|
mod multisampling;
|
||||||
device: wgpu::Device,
|
mod piplines;
|
||||||
queue: wgpu::Queue,
|
mod shader;
|
||||||
config: wgpu::SurfaceConfiguration,
|
mod shader_ffi;
|
||||||
size: winit::dpi::PhysicalSize<u32>,
|
mod state;
|
||||||
// NEW!
|
mod tesselation;
|
||||||
render_pipeline: wgpu::RenderPipeline,
|
mod tile_downloader;
|
||||||
}
|
mod texture;
|
||||||
|
|
||||||
impl State {
|
|
||||||
async fn new(window: &Window) -> Self {
|
|
||||||
let size = window.inner_size();
|
|
||||||
|
|
||||||
// The instance is a handle to our GPU
|
|
||||||
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
|
|
||||||
let instance = wgpu::Instance::new(wgpu::Backends::all());
|
|
||||||
let surface = unsafe { instance.create_surface(window) };
|
|
||||||
let adapter = instance
|
|
||||||
.request_adapter(&wgpu::RequestAdapterOptions {
|
|
||||||
power_preference: wgpu::PowerPreference::default(),
|
|
||||||
compatible_surface: Some(&surface),
|
|
||||||
force_fallback_adapter: false,
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let (device, queue) = adapter
|
|
||||||
.request_device(
|
|
||||||
&wgpu::DeviceDescriptor {
|
|
||||||
label: None,
|
|
||||||
features: wgpu::Features::empty(),
|
|
||||||
limits: wgpu::Limits::default(),
|
|
||||||
},
|
|
||||||
None, // Trace path
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let config = wgpu::SurfaceConfiguration {
|
|
||||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
|
||||||
format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
|
||||||
width: size.width,
|
|
||||||
height: size.height,
|
|
||||||
present_mode: wgpu::PresentMode::Fifo,
|
|
||||||
};
|
|
||||||
surface.configure(&device, &config);
|
|
||||||
|
|
||||||
println!("{:?}", surface.get_preferred_format(&adapter).unwrap());
|
|
||||||
|
|
||||||
let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor {
|
|
||||||
label: Some("Shader"),
|
|
||||||
source: wgpu::ShaderSource::Wgsl(include_str!("shader.wgsl").into()),
|
|
||||||
});
|
|
||||||
|
|
||||||
let render_pipeline_layout =
|
|
||||||
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
|
||||||
label: Some("Render Pipeline Layout"),
|
|
||||||
bind_group_layouts: &[],
|
|
||||||
push_constant_ranges: &[],
|
|
||||||
});
|
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
|
||||||
label: Some("Render Pipeline"),
|
|
||||||
layout: Some(&render_pipeline_layout),
|
|
||||||
vertex: wgpu::VertexState {
|
|
||||||
module: &shader,
|
|
||||||
entry_point: "vs_main",
|
|
||||||
buffers: &[],
|
|
||||||
},
|
|
||||||
fragment: Some(wgpu::FragmentState {
|
|
||||||
module: &shader,
|
|
||||||
entry_point: "fs_main",
|
|
||||||
targets: &[wgpu::ColorTargetState {
|
|
||||||
format: config.format,
|
|
||||||
blend: Some(wgpu::BlendState {
|
|
||||||
color: wgpu::BlendComponent::REPLACE,
|
|
||||||
alpha: wgpu::BlendComponent::REPLACE,
|
|
||||||
}),
|
|
||||||
write_mask: wgpu::ColorWrites::ALL,
|
|
||||||
}],
|
|
||||||
}),
|
|
||||||
primitive: wgpu::PrimitiveState {
|
|
||||||
topology: wgpu::PrimitiveTopology::TriangleList,
|
|
||||||
strip_index_format: None,
|
|
||||||
front_face: wgpu::FrontFace::Ccw,
|
|
||||||
cull_mode: Some(wgpu::Face::Back),
|
|
||||||
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
|
|
||||||
polygon_mode: wgpu::PolygonMode::Fill,
|
|
||||||
// Requires Features::DEPTH_CLAMPING
|
|
||||||
clamp_depth: false,
|
|
||||||
// Requires Features::CONSERVATIVE_RASTERIZATION
|
|
||||||
conservative: false,
|
|
||||||
},
|
|
||||||
depth_stencil: None,
|
|
||||||
multisample: wgpu::MultisampleState {
|
|
||||||
count: 1,
|
|
||||||
mask: !0,
|
|
||||||
alpha_to_coverage_enabled: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Self {
|
|
||||||
surface,
|
|
||||||
device,
|
|
||||||
queue,
|
|
||||||
size,
|
|
||||||
config,
|
|
||||||
render_pipeline,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>) {
|
|
||||||
if new_size.width > 0 && new_size.height > 0 {
|
|
||||||
self.size = new_size;
|
|
||||||
self.config.width = new_size.width;
|
|
||||||
self.config.height = new_size.height;
|
|
||||||
self.surface.configure(&self.device, &self.config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
|
||||||
fn input(&mut self, event: &WindowEvent) -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
fn update(&mut self) {}
|
|
||||||
|
|
||||||
fn render(&mut self) -> Result<(), wgpu::SurfaceError> {
|
|
||||||
let output = self.surface.get_current_texture()?;
|
|
||||||
let view = output
|
|
||||||
.texture
|
|
||||||
.create_view(&wgpu::TextureViewDescriptor::default());
|
|
||||||
|
|
||||||
let mut encoder = self
|
|
||||||
.device
|
|
||||||
.create_command_encoder(&wgpu::CommandEncoderDescriptor {
|
|
||||||
label: Some("Render Encoder"),
|
|
||||||
});
|
|
||||||
|
|
||||||
{
|
|
||||||
let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
|
||||||
label: Some("Render Pass"),
|
|
||||||
color_attachments: &[wgpu::RenderPassColorAttachment {
|
|
||||||
view: &view,
|
|
||||||
resolve_target: None,
|
|
||||||
ops: wgpu::Operations {
|
|
||||||
load: wgpu::LoadOp::Clear(wgpu::Color {
|
|
||||||
r: 0.1,
|
|
||||||
g: 0.2,
|
|
||||||
b: 0.3,
|
|
||||||
a: 1.0,
|
|
||||||
}),
|
|
||||||
store: true,
|
|
||||||
},
|
|
||||||
}],
|
|
||||||
depth_stencil_attachment: None,
|
|
||||||
});
|
|
||||||
|
|
||||||
render_pass.set_pipeline(&self.render_pipeline);
|
|
||||||
render_pass.draw(0..3, 0..1);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.queue.submit(iter::once(encoder.finish()));
|
|
||||||
output.present();
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
let event_loop = EventLoop::new();
|
println!("== wgpu example ==");
|
||||||
let window = WindowBuilder::new().build(&event_loop).unwrap();
|
println!("Controls:");
|
||||||
|
println!(" Arrow keys: scrolling");
|
||||||
|
println!(" PgUp/PgDown: zoom in/out");
|
||||||
|
println!(" a/z: increase/decrease the stroke width");
|
||||||
|
|
||||||
// State::new uses async code, so we're going to wait for it to finish
|
let event_loop = EventLoop::new();
|
||||||
|
let window = Window::new(&event_loop).unwrap();
|
||||||
let mut state = pollster::block_on(State::new(&window));
|
let mut state = pollster::block_on(State::new(&window));
|
||||||
|
|
||||||
|
window.request_redraw();
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| {
|
event_loop.run(move |event, _, control_flow| {
|
||||||
match event {
|
match event {
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
@ -195,11 +39,11 @@ fn main() {
|
|||||||
WindowEvent::CloseRequested
|
WindowEvent::CloseRequested
|
||||||
| WindowEvent::KeyboardInput {
|
| WindowEvent::KeyboardInput {
|
||||||
input:
|
input:
|
||||||
KeyboardInput {
|
KeyboardInput {
|
||||||
state: ElementState::Pressed,
|
state: ElementState::Pressed,
|
||||||
virtual_keycode: Some(VirtualKeyCode::Escape),
|
virtual_keycode: Some(VirtualKeyCode::Escape),
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
..
|
..
|
||||||
} => *control_flow = ControlFlow::Exit,
|
} => *control_flow = ControlFlow::Exit,
|
||||||
WindowEvent::Resized(physical_size) => {
|
WindowEvent::Resized(physical_size) => {
|
||||||
|
|||||||
@ -1,30 +0,0 @@
|
|||||||
// Vertex shader
|
|
||||||
|
|
||||||
struct VertexOutput {
|
|
||||||
[[builtin(position)]] clip_position: vec4<f32>;
|
|
||||||
[[location(0)]] position: vec2<f32>;
|
|
||||||
};
|
|
||||||
|
|
||||||
[[stage(vertex)]]
|
|
||||||
fn vs_main(
|
|
||||||
[[builtin(vertex_index)]] in_vertex_index: u32,
|
|
||||||
) -> VertexOutput {
|
|
||||||
var out: VertexOutput;
|
|
||||||
let x = f32(1 - i32(in_vertex_index)) * 0.2;
|
|
||||||
let y = f32(i32(in_vertex_index & 1u) * 2 - 1) * 0.5;
|
|
||||||
out.position = vec2<f32>(x, y);
|
|
||||||
out.clip_position = vec4<f32>(x, y, 0.0, 1.0);
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Fragment shader
|
|
||||||
|
|
||||||
[[stage(fragment)]]
|
|
||||||
fn fs_main(in: VertexOutput) -> [[location(0)]] vec4<f32> {
|
|
||||||
//return vec4<f32>(vec2<f32>(in.clip_position.x, in.clip_position.y), 0.5, 1.0);
|
|
||||||
return vec4<f32>(vec2<f32>(in.position.x, in.position.y), 0.5, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user