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

Bump winit to 0.25 #28

Closed
wants to merge 5 commits into from
Closed
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
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ manage_clipboard = ["clipboard", "thread_local"]
open_url = ["webbrowser"]

[dependencies]
bevy = { version = "0.5", default-features = false, features = ["render", "bevy_winit"] }
egui = "0.11.0"
bevy = { git = "https://github.com/bevyengine/bevy", branch = "main", default-features = false, features = ["render", "bevy_winit"] }
egui = "0.12.0"
webbrowser = { version = "0.5.5", optional = true }
winit = { version = "0.24.0", features = ["x11"], default-features = false }
winit = { version = "0.25.0", features = ["x11"], default-features = false }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
clipboard = { version = "0.5.0", optional = true }
Expand All @@ -33,4 +33,4 @@ thread_local = { version = "1.1.0", optional = true }
version-sync = "0.9.2"

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
bevy = { version = "0.5", default-features = false, features = ["bevy_wgpu", "x11", "png"] }
bevy = { git = "https://github.com/bevyengine/bevy", branch = "main", default-features = false, features = ["bevy_wgpu", "x11", "png"] }
8 changes: 4 additions & 4 deletions examples/two_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ fn setup_pipeline(

// add a new render pass for our new window / camera
let mut second_window_pass = PassNode::<&MainPass>::new(PassDescriptor {
color_attachments: vec![msaa.color_attachment_descriptor(
color_attachments: vec![msaa.color_attachment(
TextureAttachment::Input("color_attachment".to_string()),
TextureAttachment::Input("color_resolve_target".to_string()),
Operations {
load: LoadOp::Clear(Color::rgb(0.5, 0.5, 0.8)),
store: true,
},
)],
depth_stencil_attachment: Some(RenderPassDepthStencilAttachmentDescriptor {
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
attachment: TextureAttachment::Input("depth".to_string()),
depth_ops: Some(Operations {
load: LoadOp::Clear(1.0),
Expand Down Expand Up @@ -174,7 +174,7 @@ fn setup_pipeline(
window_id,
TextureDescriptor {
size: Extent3d {
depth: 1,
depth_or_array_layers: 1,
width: 1,
height: 1,
},
Expand Down Expand Up @@ -241,7 +241,7 @@ fn setup(
..Default::default()
});
// light
commands.spawn_bundle(LightBundle {
commands.spawn_bundle(PointLightBundle {
transform: Transform::from_xyz(4.0, 5.0, 4.0),
..Default::default()
});
Expand Down
34 changes: 17 additions & 17 deletions src/egui_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use crate::{
use bevy::{
app::{Events, ManualEventReader},
asset::{AssetEvent, Assets, Handle},
core::AsBytes,
core::{bytes_of, cast_slice},
ecs::world::World,
log,
render::{
pass::{
ClearColor, LoadOp, Operations, PassDescriptor,
RenderPassDepthStencilAttachmentDescriptor, TextureAttachment,
ClearColor, LoadOp, Operations, PassDescriptor, RenderPassDepthStencilAttachment,
TextureAttachment,
},
pipeline::{
BindGroupDescriptor, IndexFormat, InputStepMode, PipelineCompiler, PipelineDescriptor,
Expand Down Expand Up @@ -69,15 +69,15 @@ pub struct TextureResource {

impl EguiNode {
pub fn new(msaa: &Msaa, window: WindowId) -> Self {
let color_attachments = vec![msaa.color_attachment_descriptor(
let color_attachments = vec![msaa.color_attachment(
TextureAttachment::Input("color_attachment".to_string()),
TextureAttachment::Input("color_resolve_target".to_string()),
Operations {
load: LoadOp::Load,
store: true,
},
)];
let depth_stencil_attachment = RenderPassDepthStencilAttachmentDescriptor {
let depth_stencil_attachment = RenderPassDepthStencilAttachment {
attachment: TextureAttachment::Input("depth".to_string()),
depth_ops: Some(Operations {
load: LoadOp::Clear(1.0),
Expand Down Expand Up @@ -246,24 +246,24 @@ impl Node for EguiNode {
.cloned();

for vertex in &triangles.vertices {
vertex_buffer.extend_from_slice([vertex.pos.x, vertex.pos.y].as_bytes());
vertex_buffer.extend_from_slice([vertex.uv.x, vertex.uv.y].as_bytes());
vertex_buffer.extend_from_slice(
vertex_buffer.extend_from_slice(bytes_of(&[vertex.pos.x, vertex.pos.y]));
vertex_buffer.extend_from_slice(bytes_of(&[vertex.uv.x, vertex.uv.y]));
vertex_buffer.extend_from_slice(cast_slice(
vertex
.color
.to_array()
.iter()
.map(|c| *c as f32)
.collect::<Vec<_>>()
.as_bytes(),
);
.as_slice(),
));
}
let indices_with_offset = triangles
.indices
.iter()
.map(|i| i + index_offset)
.collect::<Vec<_>>();
index_buffer.extend_from_slice(indices_with_offset.as_slice().as_bytes());
index_buffer.extend_from_slice(cast_slice(indices_with_offset.as_slice()));
index_offset += triangles.vertices.len() as u32;

let x_viewport_clamp = (x + w).saturating_sub(window_size.physical_width as u32);
Expand Down Expand Up @@ -399,19 +399,19 @@ impl EguiNode {
VertexAttribute {
name: Cow::from("Vertex_Position"),
offset: 0,
format: VertexFormat::Float2,
format: VertexFormat::Float32x2,
shader_location: 0,
},
VertexAttribute {
name: Cow::from("Vertex_Uv"),
offset: VertexFormat::Float2.get_size(),
format: VertexFormat::Float2,
offset: VertexFormat::Float32x2.get_size(),
format: VertexFormat::Float32x2,
shader_location: 1,
},
VertexAttribute {
name: Cow::from("Vertex_Color"),
offset: VertexFormat::Float2.get_size() + VertexFormat::Float2.get_size(),
format: VertexFormat::Float4,
offset: VertexFormat::Float32x2.get_size() + VertexFormat::Float32x2.get_size(),
format: VertexFormat::Float32x4,
shader_location: 2,
},
];
Expand Down Expand Up @@ -685,7 +685,7 @@ impl EguiNode {
format_size
* aligned_width
* texture.size.height as usize
* texture.size.depth as usize
* texture.size.depth_or_array_layers as usize
];
texture
.data
Expand Down
29 changes: 15 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ use bevy::{
reflect::TypeUuid,
render::{
pipeline::{
BlendFactor, BlendOperation, BlendState, ColorTargetState, ColorWrite, CompareFunction,
CullMode, DepthBiasState, DepthStencilState, FrontFace, MultisampleState,
BlendComponent, BlendFactor, BlendOperation, BlendState, ColorTargetState, ColorWrite,
CompareFunction, DepthBiasState, DepthStencilState, FrontFace, MultisampleState,
PipelineDescriptor, PrimitiveState, StencilFaceState, StencilState,
},
render_graph::{base, base::Msaa, RenderGraph, WindowSwapChainNode, WindowTextureNode},
Expand Down Expand Up @@ -485,7 +485,7 @@ fn build_egui_pipeline(shaders: &mut Assets<Shader>, sample_count: u32) -> Pipel
PipelineDescriptor {
primitive: PrimitiveState {
front_face: FrontFace::Cw,
cull_mode: CullMode::None,
cull_mode: None,
..Default::default()
},
depth_stencil: Some(DepthStencilState {
Expand All @@ -503,20 +503,21 @@ fn build_egui_pipeline(shaders: &mut Assets<Shader>, sample_count: u32) -> Pipel
slope_scale: 0.0,
clamp: 0.0,
},
clamp_depth: false,
}),
color_target_states: vec![ColorTargetState {
format: TextureFormat::default(),
color_blend: BlendState {
src_factor: BlendFactor::One,
dst_factor: BlendFactor::OneMinusSrcAlpha,
operation: BlendOperation::Add,
},
alpha_blend: BlendState {
src_factor: BlendFactor::One,
dst_factor: BlendFactor::OneMinusSrcAlpha,
operation: BlendOperation::Add,
},
blend: Some(BlendState {
color: BlendComponent {
src_factor: BlendFactor::One,
dst_factor: BlendFactor::OneMinusSrcAlpha,
operation: BlendOperation::Add,
},
alpha: BlendComponent {
src_factor: BlendFactor::One,
dst_factor: BlendFactor::OneMinusSrcAlpha,
operation: BlendOperation::Add,
},
}),
write_mask: ColorWrite::ALL,
}],
multisample: MultisampleState {
Expand Down
4 changes: 2 additions & 2 deletions src/transform_node.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{EguiSettings, WindowSize, EGUI_TRANSFORM_RESOURCE_BINDING_NAME};
use bevy::{
core::AsBytes,
core::bytes_of,
ecs::{
system::{IntoSystem, Local, Res, ResMut, System},
world::World,
Expand Down Expand Up @@ -130,7 +130,7 @@ fn transform_node_system(
staging_buffer,
0..transform_data_size as u64,
&mut |data, _renderer| {
data[0..transform_data_size].copy_from_slice(transform_data.as_bytes());
data[0..transform_data_size].copy_from_slice(bytes_of(&transform_data));
},
);
render_resource_context.unmap_buffer(staging_buffer);
Expand Down