Skip to content
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## v29.0.0

- `wgpu` crate version -> 29.0.0
- `bytemuck` crate version -> 1.25.0
- `rand` crate version -> 0.10.0
- `winit` crate version -> 0.30.13
- `env_logger` crate version -> 0.11.9
- Minor example updates following the new `wgpu` version

## v28.0.1

- Fixed the `using_font_bytes_vec()` function which was incomplete
Expand Down
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "wgpu_text"
authors = ["Leon (Blatko1)"]
version = "28.0.1"
version = "29.0.0"
edition = "2024"
description = "A simple 2D text renderer for wgpu."
license = "MIT"
Expand All @@ -12,17 +12,17 @@ categories = ["graphics", "rendering"]
include = ["src/**/*", "LICENSE", "Cargo.toml", "README.md", ".gitignore"]

[dependencies]
wgpu = "28.0.0"
wgpu = "29.0.0"
glyph_brush = "0.7.12"
log = "0.4.29"
bytemuck = { version = "1.24.0", features = ["derive"] }
bytemuck = { version = "1.25.0", features = ["derive"] }

[dev-dependencies]
wgpu = { version = "28.0.0", features = ["spirv"] }
winit = "0.30.12"
wgpu = { version = "29.0.0", features = ["spirv"] }
winit = "0.30.13"
pollster = "0.4.0"
env_logger = "0.11.8"
rand = "0.9.2"
env_logger = "0.11.9"
rand = "0.10.0"
nalgebra = "0.34.1"

[[example]]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Add the following to your `Cargo.toml` file:

```toml
[dependencies]
wgpu_text = "28.0.1"
wgpu_text = "29.0.0"
```

## **Usage**
Expand Down
4 changes: 3 additions & 1 deletion examples/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ impl Ctx {
pub fn new(window: Arc<winit::window::Window>) -> Self {
let size = window.inner_size();
let backends = wgpu::Backends::from_env().unwrap_or_else(wgpu::Backends::all);
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends,
flags: wgpu::InstanceFlags::default(),
memory_budget_thresholds: Default::default(),
backend_options: wgpu::BackendOptions {
gl: wgpu::GlBackendOptions {
gles_minor_version: wgpu::Gles3MinorVersion::Automatic,
fence_behavior: wgpu::GlFenceBehavior::default(),
debug_fns: wgpu::GlDebugFns::Auto,
},
dx12: wgpu::Dx12BackendOptions::default(),
noop: wgpu::NoopBackendOptions::from_env_or_default(),
},
display: None,
});
let surface = instance.create_surface(window).unwrap();

Expand Down
25 changes: 17 additions & 8 deletions examples/custom_target/custom_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ impl ApplicationHandler for State<'_> {
},
],
}));
self.pipeline = Some(create_pipeline(device, &[&bind_group_layout], config));
self.pipeline =
Some(create_pipeline(device, &[Some(&bind_group_layout)], config));

self.section = Some(
Section::default()
Expand Down Expand Up @@ -333,12 +334,17 @@ impl ApplicationHandler for State<'_> {
};

let frame = match surface.get_current_texture() {
Ok(frame) => frame,
Err(_) => {
wgpu::CurrentSurfaceTexture::Success(frame) => frame,
wgpu::CurrentSurfaceTexture::Occluded => return,
_ => {
surface.configure(device, config);
surface
.get_current_texture()
.expect("Failed to acquire next surface texture!")
let wgpu::CurrentSurfaceTexture::Success(frame) =
surface.get_current_texture()
else {
panic!("Failed to acquire next surface texture!");
};

frame
}
};
let view = frame
Expand Down Expand Up @@ -416,11 +422,14 @@ impl ApplicationHandler for State<'_> {

fn new_events(&mut self, _event_loop: &ActiveEventLoop, _cause: StartCause) {
if self.target_framerate <= self.delta_time.elapsed() {
self.window.clone().unwrap().request_redraw();
let Some(window) = self.window.clone() else {
return;
};

window.request_redraw();
self.delta_time = Instant::now();
self.fps += 1;
if self.fps_update_time.elapsed().as_millis() > 1000 {
let window = self.window.as_mut().unwrap();
window.set_title(&format!(
"wgpu-text: 'custom_target' example, FPS: {}",
self.fps
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_target/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Vertex {

pub fn create_pipeline(
device: &wgpu::Device,
bind_group_layouts: &[&wgpu::BindGroupLayout],
bind_group_layouts: &[Option<&wgpu::BindGroupLayout>],
config: &wgpu::SurfaceConfiguration,
) -> wgpu::RenderPipeline {
let vertex_module =
Expand Down
19 changes: 12 additions & 7 deletions examples/depth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,17 @@ impl ApplicationHandler for State<'_> {
};

let frame = match surface.get_current_texture() {
Ok(frame) => frame,
Err(_) => {
wgpu::CurrentSurfaceTexture::Success(frame) => frame,
wgpu::CurrentSurfaceTexture::Occluded => return,
_ => {
surface.configure(device, config);
surface
.get_current_texture()
.expect("Failed to acquire next surface texture!")
let wgpu::CurrentSurfaceTexture::Success(frame) =
surface.get_current_texture()
else {
panic!("Failed to acquire next surface texture!");
};

frame
}
};
let view = frame
Expand Down Expand Up @@ -331,8 +336,8 @@ fn main() {
ctx: None,
depth_stencil: Some(wgpu::DepthStencilState {
format: DEPTH_FORMAT,
depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::LessEqual,
depth_write_enabled: Some(true),
depth_compare: Some(wgpu::CompareFunction::LessEqual),
stencil: wgpu::StencilState::default(),
bias: wgpu::DepthBiasState::default(),
}),
Expand Down
28 changes: 16 additions & 12 deletions examples/fonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
mod ctx;

use ctx::Ctx;
use glyph_brush::{FontId, OwnedSection};
use glyph_brush::ab_glyph::FontRef;
use glyph_brush::{FontId, OwnedSection};
use std::sync::Arc;
use std::time::{Duration, Instant};
use wgpu_text::glyph_brush::{
Expand Down Expand Up @@ -54,12 +54,11 @@ impl ApplicationHandler for State<'_> {
let device = &ctx.device;
let config = &ctx.config;

self.brush = Some(BrushBuilder::using_font_bytes_vec(vec![self.font1, self.font2]).unwrap().build(
device,
config.width,
config.height,
config.format,
));
self.brush = Some(
BrushBuilder::using_font_bytes_vec(vec![self.font1, self.font2])
.unwrap()
.build(device, config.width, config.height, config.format),
);

self.section_0 = Some(
Section::default()
Expand Down Expand Up @@ -206,12 +205,17 @@ impl ApplicationHandler for State<'_> {
};

let frame = match surface.get_current_texture() {
Ok(frame) => frame,
Err(_) => {
wgpu::CurrentSurfaceTexture::Success(frame) => frame,
wgpu::CurrentSurfaceTexture::Occluded => return,
_ => {
surface.configure(device, config);
surface
.get_current_texture()
.expect("Failed to acquire next surface texture!")
let wgpu::CurrentSurfaceTexture::Success(frame) =
surface.get_current_texture()
else {
panic!("Failed to acquire next surface texture!");
};

frame
}
};
let view = frame
Expand Down
17 changes: 11 additions & 6 deletions examples/performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod ctx;

use ctx::Ctx;
use glyph_brush::ab_glyph::FontRef;
use rand::Rng;
use rand::RngExt;
use std::sync::Arc;
use std::time::{Duration, Instant};
use wgpu_text::glyph_brush::{BuiltInLineBreaker, Layout, Section, Text};
Expand Down Expand Up @@ -163,12 +163,17 @@ impl ApplicationHandler for State<'_> {
};

let frame = match surface.get_current_texture() {
Ok(frame) => frame,
Err(_) => {
wgpu::CurrentSurfaceTexture::Success(frame) => frame,
wgpu::CurrentSurfaceTexture::Occluded => return,
_ => {
surface.configure(device, config);
surface
.get_current_texture()
.expect("Failed to acquire next surface texture!")
let wgpu::CurrentSurfaceTexture::Success(frame) =
surface.get_current_texture()
else {
panic!("Failed to acquire next surface texture!");
};

frame
}
};
let view = frame
Expand Down
15 changes: 10 additions & 5 deletions examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,17 @@ impl ApplicationHandler for State<'_> {
};

let frame = match surface.get_current_texture() {
Ok(frame) => frame,
Err(_) => {
wgpu::CurrentSurfaceTexture::Success(frame) => frame,
wgpu::CurrentSurfaceTexture::Occluded => return,
_ => {
surface.configure(device, config);
surface
.get_current_texture()
.expect("Failed to acquire next surface texture!")
let wgpu::CurrentSurfaceTexture::Success(frame) =
surface.get_current_texture()
else {
panic!("Failed to acquire next surface texture!");
};

frame
}
};
let view = frame
Expand Down
7 changes: 4 additions & 3 deletions src/brush.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,10 @@ impl BrushBuilder<()> {
pub fn using_font_bytes_vec(
data_vec: Vec<&[u8]>,
) -> Result<BrushBuilder<FontRef<'_>>, InvalidFont> {
let fonts = data_vec.iter().map(|data|
FontRef::try_from_slice(data)
).collect::<Result<Vec<FontRef>, InvalidFont>>()?;
let fonts = data_vec
.iter()
.map(|data| FontRef::try_from_slice(data))
.collect::<Result<Vec<FontRef>, InvalidFont>>()?;
Ok(BrushBuilder::using_fonts(fonts))
}

Expand Down
2 changes: 1 addition & 1 deletion src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Pipeline {
let pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("wgpu-text Render Pipeline Layout"),
bind_group_layouts: &[&cache.bind_group_layout],
bind_group_layouts: &[Some(&cache.bind_group_layout)],
immediate_size: 0,
});

Expand Down
Loading