Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI breakages #161

Merged
merged 2 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/dynamic_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn setup_system(mut commands: Commands) {
..shapes::RegularPolygon::default()
};

commands.spawn_bundle(OrthographicCameraBundle::new_2d());
commands.spawn_bundle(Camera2dBundle::default());
commands
.spawn_bundle(GeometryBuilder::build_as(
&shape,
Expand Down
2 changes: 1 addition & 1 deletion examples/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn setup_system(mut commands: Commands) {
path_builder.line_to(100.0 * Vec2::ONE);
let line = path_builder.build();

commands.spawn_bundle(OrthographicCameraBundle::new_2d());
commands.spawn_bundle(Camera2dBundle::default());
commands.spawn_bundle(GeometryBuilder::build_as(
&line,
DrawMode::Stroke(StrokeMode::new(Color::BLACK, 10.0)),
Expand Down
2 changes: 1 addition & 1 deletion examples/readme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn setup_system(mut commands: Commands) {
..shapes::RegularPolygon::default()
};

commands.spawn_bundle(OrthographicCameraBundle::new_2d());
commands.spawn_bundle(Camera2dBundle::default());
commands.spawn_bundle(GeometryBuilder::build_as(
&shape,
DrawMode::Outlined {
Expand Down
2 changes: 1 addition & 1 deletion examples/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct BuildingBundle {
global_transform: GlobalTransform,
}
fn setup_system(mut commands: Commands) {
commands.spawn_bundle(OrthographicCameraBundle::new_2d());
commands.spawn_bundle(Camera2dBundle::default());

commands.spawn_bundle(BuildingBundle {
name: Name("Blacksmith".to_owned()),
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn build_mesh(buffers: &VertexBuffers) -> Mesh {
.vertices
.iter()
.map(|v| v.color)
.collect::<Vec<u32>>(),
.collect::<Vec<[f32; 4]>>(),
);

mesh
Expand Down
4 changes: 2 additions & 2 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use bevy::{
app::{App, Plugin},
asset::{Assets, HandleUntyped},
core_pipeline::Transparent2d,
core_pipeline::core_2d::Transparent2d,
ecs::{
component::Component,
entity::Entity,
Expand Down Expand Up @@ -64,7 +64,7 @@ impl SpecializedRenderPipeline for ShapePipeline {
// Position
VertexFormat::Float32x3,
// Color
VertexFormat::Uint32,
VertexFormat::Float32x4,
];

let vertex_layout =
Expand Down
12 changes: 6 additions & 6 deletions src/render/shape.wgsl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Import the standard 2d mesh uniforms and set their bind groups
#import bevy_sprite::mesh2d_view_bind_group
[[group(0), binding(0)]]
var<uniform> view: View;
#import bevy_sprite::mesh2d_struct
#import bevy_sprite::mesh2d_view_bindings
//[[group(0), binding(0)]]
//var<uniform> view: View;
#import bevy_sprite::mesh2d_types
[[group(1), binding(0)]]
var<uniform> mesh: Mesh2d;
// The structure of the vertex buffer is as specified in `specialize()`
struct Vertex {
[[location(0)]] position: vec3<f32>;
[[location(1)]] color: u32;
[[location(1)]] color: vec4<f32>;
};
struct VertexOutput {
// The vertex shader must set the on-screen position of the vertex
Expand All @@ -22,7 +22,7 @@ fn vertex(vertex: Vertex) -> VertexOutput {
var out: VertexOutput;
// Project the world position of the mesh into screen position
out.clip_position = view.view_proj * mesh.model * vec4<f32>(vertex.position, 1.0);
out.color = vec4<f32>((vec4<u32>(vertex.color) >> vec4<u32>(0u, 8u, 16u, 24u)) & vec4<u32>(255u)) / 255.0;
out.color = vertex.color;
return out;
}
// The input of the fragment shader must correspond to the output of the vertex shader for all `location`s
Expand Down
6 changes: 3 additions & 3 deletions src/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub type VertexBuffers = tess::VertexBuffers<Vertex, IndexType>;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Vertex {
pub position: [f32; 2],
pub color: u32,
pub color: [f32; 4],
}

/// Zero-sized type used to implement various vertex construction traits from
Expand All @@ -27,7 +27,7 @@ impl FillVertexConstructor<Vertex> for VertexConstructor {
fn new_vertex(&mut self, vertex: FillVertex) -> Vertex {
Vertex {
position: [vertex.position().x, vertex.position().y],
color: self.color.as_linear_rgba_u32(),
color: self.color.as_linear_rgba_f32(),
}
}
}
Expand All @@ -37,7 +37,7 @@ impl StrokeVertexConstructor<Vertex> for VertexConstructor {
fn new_vertex(&mut self, vertex: StrokeVertex) -> Vertex {
Vertex {
position: [vertex.position().x, vertex.position().y],
color: self.color.as_linear_rgba_u32(),
color: self.color.as_linear_rgba_f32(),
}
}
}