Skip to content

Commit e8f97cb

Browse files
committed
update eframe and fix web build
1 parent 127a6a7 commit e8f97cb

14 files changed

Lines changed: 628 additions & 409 deletions

Cargo.lock

Lines changed: 526 additions & 315 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rust_graph"
3-
version = "0.7.0"
3+
version = "0.7.1"
44
edition = "2024"
55
authors = ["Vedran Maric <valinion@gmail.com>"]
66
description = "Graphing calculator with f32 support."
@@ -34,29 +34,29 @@ inherits = "release"
3434
lto = "thin"
3535

3636
[dependencies]
37-
eframe = { version = "0.33",features=[
37+
eframe = { version = "0.34",features=[
3838
"accesskit",
3939
"default_fonts",
4040
"wayland",
4141
"web_screen_reader",
4242
"x11",
4343
"persistence", "wgpu"] }
44-
wgpu = { version = "*", features = [ "webgpu", "webgl", "vulkan", "metal", "dx12", "gles", "wgsl", ] } # profiling = {version="1.0", features=["profile-with-puffin"]}
44+
wgpu = { version = "29", features = [ "webgpu", "webgl", "vulkan", "metal", "gles", "wgsl", ] }
4545
bytemuck = "1"
4646
cfg-if = "1"
47-
egui_plot="0.34"
47+
egui_plot="0.35"
4848
send_wrapper = "0.6"
49-
egui-file-dialog ="0.12"
49+
egui-file-dialog ="0.13"
5050
# enum-map="2.7"
51-
51+
web-time = "1"
5252
# egui_extras={version = "0.33", features=["syntect"]}
5353
# syntect = { version = "5.3", default-features = false, features = ["default-fancy"]}
5454
evalexpr = { path = "evalexpr" }
5555

5656
rustc-hash = "2"
5757
serde = { version = "1" }
5858
serde_json = "1"
59-
egui_dnd="0.14"
59+
egui_dnd="0.15"
6060
bincode={version="2", features=["serde"]}
6161
base64="0.22"
6262
arrayvec = "0.7"
@@ -75,8 +75,8 @@ getrandom = { version = "0.3", features = ["wasm_js"] }
7575
# puffin_http = { path = "../../contrib/puffin/puffin_http" }
7676

7777
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
78-
puffin = { version = "0.19", optional = true }
79-
puffin_http = { version = "0.16", optional = true }
78+
puffin = { version = "0.20", optional = true }
79+
puffin_http = { version = "0.17", optional = true }
8080

8181
[target.'cfg(target_arch = "wasm32")'.dependencies]
8282
wasm-bindgen-futures = "0.4"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Rust Graph
22
Desmos-like graphing calculator with support for f32 numbers.
33

4-
54
## Use it online
65

76
[Web Demo](https://rust-graph.netlify.app/)
@@ -21,3 +20,4 @@ cargo install --git https://github.com/vdrn/rust_graph
2120

2221

2322

23+

examples/Riemann zeta function.json

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
[toolchain]
2-
# 10-02 good
3-
# 10-03 bad
42
channel = "nightly-2025-11-15"
53
components = ["rust-src", "rust-analyzer", "clippy", "rustfmt"]
64
targets = ["wasm32-unknown-unknown"]

src/custom_rendering/fan_fill_renderer.rs

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ impl FanFillRenderer {
6868
});
6969

7070
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
71-
label: Some("fan_pipeline_layout"),
72-
bind_group_layouts: &[&bind_group_layout],
73-
push_constant_ranges: &[],
71+
label: Some("fan_pipeline_layout"),
72+
bind_group_layouts: &[Some(&bind_group_layout)],
73+
immediate_size: 0,
7474
});
7575
let mut stencil_pipeline_descriptor = wgpu::RenderPipelineDescriptor {
76-
label: Some("stencil_pipeline"),
77-
layout: Some(&pipeline_layout),
78-
vertex: wgpu::VertexState {
76+
label: Some("stencil_pipeline"),
77+
layout: Some(&pipeline_layout),
78+
vertex: wgpu::VertexState {
7979
module: &shader,
8080
entry_point: Some("vs_main"),
8181
buffers: &[wgpu::VertexBufferLayout {
@@ -89,12 +89,12 @@ impl FanFillRenderer {
8989
}],
9090
compilation_options: wgpu::PipelineCompilationOptions::default(),
9191
},
92-
fragment: None, // No color output in stencil pass
93-
primitive: wgpu::PrimitiveState::default(),
94-
depth_stencil: Some(wgpu::DepthStencilState {
92+
fragment: None, // No color output in stencil pass
93+
primitive: wgpu::PrimitiveState::default(),
94+
depth_stencil: Some(wgpu::DepthStencilState {
9595
format: wgpu::TextureFormat::Stencil8,
96-
depth_write_enabled: false,
97-
depth_compare: wgpu::CompareFunction::Always,
96+
depth_write_enabled: Some(false),
97+
depth_compare: Some(wgpu::CompareFunction::Always),
9898
stencil: wgpu::StencilState {
9999
front: wgpu::StencilFaceState {
100100
compare: wgpu::CompareFunction::Always,
@@ -113,16 +113,16 @@ impl FanFillRenderer {
113113
},
114114
bias: wgpu::DepthBiasState::default(),
115115
}),
116-
multisample: wgpu::MultisampleState::default(),
117-
multiview: None,
118-
cache: None,
116+
multisample: wgpu::MultisampleState::default(),
117+
multiview_mask: None,
118+
cache: None,
119119
};
120120
let even_odd_stencil_pipeline = device.create_render_pipeline(&stencil_pipeline_descriptor);
121121

122122
stencil_pipeline_descriptor.depth_stencil = Some(wgpu::DepthStencilState {
123123
format: wgpu::TextureFormat::Stencil8,
124-
depth_write_enabled: false,
125-
depth_compare: wgpu::CompareFunction::Always,
124+
depth_write_enabled: Some(false),
125+
depth_compare: Some(wgpu::CompareFunction::Always),
126126
stencil: wgpu::StencilState {
127127
front: wgpu::StencilFaceState {
128128
compare: wgpu::CompareFunction::Always,
@@ -144,15 +144,15 @@ impl FanFillRenderer {
144144
let non_zero_stencil_pipeline = device.create_render_pipeline(&stencil_pipeline_descriptor);
145145

146146
let color_pipeline_descriptor = wgpu::RenderPipelineDescriptor {
147-
label: Some("color_pipeline"),
148-
layout: Some(&pipeline_layout),
149-
vertex: wgpu::VertexState {
147+
label: Some("color_pipeline"),
148+
layout: Some(&pipeline_layout),
149+
vertex: wgpu::VertexState {
150150
module: &shader,
151151
entry_point: Some("vs_quad"),
152152
buffers: &[],
153153
compilation_options: wgpu::PipelineCompilationOptions::default(),
154154
},
155-
fragment: Some(wgpu::FragmentState {
155+
fragment: Some(wgpu::FragmentState {
156156
module: &shader,
157157
entry_point: Some("fs_quad"),
158158
targets: &[Some(wgpu::ColorTargetState {
@@ -162,11 +162,11 @@ impl FanFillRenderer {
162162
})],
163163
compilation_options: wgpu::PipelineCompilationOptions::default(),
164164
}),
165-
primitive: wgpu::PrimitiveState::default(),
166-
depth_stencil: Some(wgpu::DepthStencilState {
165+
primitive: wgpu::PrimitiveState::default(),
166+
depth_stencil: Some(wgpu::DepthStencilState {
167167
format: wgpu::TextureFormat::Stencil8,
168-
depth_write_enabled: false,
169-
depth_compare: wgpu::CompareFunction::Always,
168+
depth_write_enabled: Some(false),
169+
depth_compare: Some(wgpu::CompareFunction::Always),
170170
stencil: wgpu::StencilState {
171171
front: wgpu::StencilFaceState {
172172
compare: wgpu::CompareFunction::NotEqual,
@@ -185,9 +185,9 @@ impl FanFillRenderer {
185185
},
186186
bias: wgpu::DepthBiasState::default(),
187187
}),
188-
multisample: wgpu::MultisampleState::default(),
189-
multiview: None,
190-
cache: None,
188+
multisample: wgpu::MultisampleState::default(),
189+
multiview_mask: None,
190+
cache: None,
191191
};
192192
let color_pipeline = device.create_render_pipeline(&color_pipeline_descriptor);
193193

@@ -399,6 +399,7 @@ impl FanFillRenderer {
399399
}),
400400
timestamp_writes: None,
401401
occlusion_query_set: None,
402+
multiview_mask: None,
402403
});
403404

404405
match fill_rule {
@@ -439,6 +440,7 @@ impl FanFillRenderer {
439440
}),
440441
timestamp_writes: None,
441442
occlusion_query_set: None,
443+
multiview_mask: None,
442444
});
443445

444446
color_pass.set_pipeline(&resources.color_pipeline);

src/custom_rendering/mesh_renderer.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,23 @@ pub fn init_mesh_renderer(cc: &eframe::CreationContext) -> Option<()> {
2424
ty: wgpu::BindingType::Buffer {
2525
ty: wgpu::BufferBindingType::Uniform,
2626
has_dynamic_offset: false,
27-
min_binding_size: NonZeroU64::new(24), // screen_size + rect(x, y, width, height)
27+
min_binding_size: NonZeroU64::new(32), /* screen_size + rect(x, y, width, height) + 8
28+
* byte padding */
2829
},
2930
count: None,
3031
}],
3132
});
3233

3334
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
34-
label: Some("mesh_renderer"),
35-
bind_group_layouts: &[&bind_group_layout],
36-
push_constant_ranges: &[],
35+
label: Some("mesh_renderer"),
36+
bind_group_layouts: &[Some(&bind_group_layout)],
37+
immediate_size: 0,
3738
});
3839

3940
let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
40-
label: Some("mesh_renderer"),
41-
layout: Some(&pipeline_layout),
42-
vertex: wgpu::VertexState {
41+
label: Some("mesh_renderer"),
42+
layout: Some(&pipeline_layout),
43+
vertex: wgpu::VertexState {
4344
module: &shader,
4445
entry_point: None,
4546
buffers: &[wgpu::VertexBufferLayout {
@@ -68,7 +69,7 @@ pub fn init_mesh_renderer(cc: &eframe::CreationContext) -> Option<()> {
6869
}],
6970
compilation_options: wgpu::PipelineCompilationOptions::default(),
7071
},
71-
fragment: Some(wgpu::FragmentState {
72+
fragment: Some(wgpu::FragmentState {
7273
module: &shader,
7374
entry_point: Some("fs_main"),
7475
targets: &[Some(wgpu::ColorTargetState {
@@ -78,19 +79,19 @@ pub fn init_mesh_renderer(cc: &eframe::CreationContext) -> Option<()> {
7879
})],
7980
compilation_options: wgpu::PipelineCompilationOptions::default(),
8081
}),
81-
primitive: wgpu::PrimitiveState {
82+
primitive: wgpu::PrimitiveState {
8283
topology: wgpu::PrimitiveTopology::TriangleList,
8384
..Default::default()
8485
},
85-
depth_stencil: None,
86-
multisample: wgpu::MultisampleState::default(),
87-
multiview: None,
88-
cache: None,
86+
depth_stencil: None,
87+
multisample: wgpu::MultisampleState::default(),
88+
multiview_mask: None,
89+
cache: None,
8990
});
9091

9192
let uniform_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
9293
label: Some("mesh_renderer_uniform"),
93-
contents: bytemuck::cast_slice(&[0.0_f32; 6]),
94+
contents: bytemuck::cast_slice(&[0.0_f32; 8]),
9495
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::UNIFORM,
9596
});
9697

@@ -165,6 +166,8 @@ impl egui_wgpu::CallbackTrait for MeshCallback {
165166
self.frame.min.y,
166167
self.frame.width(),
167168
self.frame.height(),
169+
0.0,
170+
0.0,
168171
];
169172
queue.write_buffer(&mesh_resources.uniform_buffer, 0, bytemuck::cast_slice(&uniforms));
170173
}

src/custom_rendering/mesh_shader.wgsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ struct Locals {
22
screen_size: vec2<f32>,
33
rect_min: vec2<f32>,
44
rect_size: vec2<f32>,
5+
padding: vec2<f32>,
56
}
67

78
@group(0) @binding(0)

src/entry/entry_processing.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,12 +549,12 @@ fn inline_and_fold_entry<T: EvalexprFloat>(
549549
let Some(node) = &func.node else {
550550
return Ok(());
551551
};
552-
println!("node: {identifier}: {:#?}", node);
552+
// println!("node: {identifier}: {:#?}", node);
553553
let inlined_node = evalexpr::optimize_flat_node(node, ctx).map_err(|e| e.to_string())?;
554-
println!("inlined node {identifier}: {:#?}", inlined_node);
554+
// println!("inlined node {identifier}: {:#?}", inlined_node);
555555
let expr_function = ExpressionFunction::new(inlined_node, &func.args, &mut Some(ctx))
556556
.map_err(|e| e.to_string())?;
557-
println!("expr_func node: {identifier} {:#?}", expr_function);
557+
// println!("expr_func node: {identifier} {:#?}", expr_function);
558558

559559
if identifier.to_str() != "" && func.equation_type == EquationType::None {
560560
ctx.set_expression_function(*identifier, expr_function.clone());

src/graph_ui.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ pub fn graph_ui<T: evalexpr::EvalexprFloat>(
231231

232232
if ui_state.reset_graph {
233233
force_create_elements = true;
234-
ui_state.reset_graph = false;
235234
state.graph_state.current_graph_config = state.graph_state.saved_graph_config.clone();
236235
}
237236

@@ -260,6 +259,10 @@ pub fn graph_ui<T: evalexpr::EvalexprFloat>(
260259
.clamp_grid(graph_conf.clamp_grid)
261260
.grid_spacing(graph_conf.grid_spacing.0..=graph_conf.grid_spacing.1);
262261

262+
if ui_state.reset_graph {
263+
plot = plot.reset();
264+
ui_state.reset_graph = false;
265+
}
263266
plot = plot
264267
.default_x_bounds(calcd_bounds.min()[0], calcd_bounds.max()[0])
265268
.default_y_bounds(calcd_bounds.min()[1], calcd_bounds.max()[1]);

0 commit comments

Comments
 (0)