Add support for texture filters in WGPU backend
This commit is contained in:
parent
5d15e3d367
commit
a29154233b
10 changed files with 17 additions and 12 deletions
|
@ -416,10 +416,14 @@ impl RenderPass {
|
|||
format: wgpu::TextureFormat::Rgba8UnormSrgb,
|
||||
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
|
||||
});
|
||||
let filter = match image_delta.filter {
|
||||
egui::TextureFilter::Nearest => wgpu::FilterMode::Nearest,
|
||||
egui::TextureFilter::Linear => wgpu::FilterMode::Linear,
|
||||
};
|
||||
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
||||
label: None,
|
||||
mag_filter: wgpu::FilterMode::Linear,
|
||||
min_filter: wgpu::FilterMode::Linear,
|
||||
mag_filter: filter,
|
||||
min_filter: filter,
|
||||
..Default::default()
|
||||
});
|
||||
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||
|
@ -488,11 +492,12 @@ impl RenderPass {
|
|||
/// The `Texture` must have the format `TextureFormat::Rgba8UnormSrgb` and usage
|
||||
/// `TextureUsage::SAMPLED`. Any compare function supplied in the `SamplerDescriptor` will be
|
||||
/// ignored.
|
||||
#[allow(clippy::needless_pass_by_value)] // false positive
|
||||
pub fn register_native_texture_with_sampler_options(
|
||||
&mut self,
|
||||
device: &wgpu::Device,
|
||||
texture: &wgpu::TextureView,
|
||||
sampler_descriptor: wgpu::SamplerDescriptor,
|
||||
sampler_descriptor: wgpu::SamplerDescriptor<'_>,
|
||||
) -> egui::TextureId {
|
||||
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
||||
compare: None,
|
||||
|
|
|
@ -697,7 +697,7 @@ impl Context {
|
|||
/// ui.ctx().load_texture(
|
||||
/// "my-image",
|
||||
/// egui::ColorImage::example(),
|
||||
/// egui::epaint::textures::TextureFilter::Linear
|
||||
/// egui::TextureFilter::Linear
|
||||
/// )
|
||||
/// });
|
||||
///
|
||||
|
|
|
@ -327,7 +327,7 @@ pub use epaint::hex_color;
|
|||
pub use epaint::{
|
||||
color, mutex,
|
||||
text::{FontData, FontDefinitions, FontFamily, FontId, FontTweak},
|
||||
textures::TexturesDelta,
|
||||
textures::{TextureFilter, TexturesDelta},
|
||||
ClippedPrimitive, Color32, ColorImage, FontImage, ImageData, Mesh, PaintCallback,
|
||||
PaintCallbackInfo, Rgba, Rounding, Shape, Stroke, TextureHandle, TextureId,
|
||||
};
|
||||
|
|
|
@ -1529,7 +1529,7 @@ impl Ui {
|
|||
/// ui.ctx().load_texture(
|
||||
/// "my-image",
|
||||
/// egui::ColorImage::example(),
|
||||
/// egui::epaint::textures::TextureFilter::Linear
|
||||
/// egui::TextureFilter::Linear
|
||||
/// )
|
||||
/// });
|
||||
///
|
||||
|
|
|
@ -18,7 +18,7 @@ use emath::Rot2;
|
|||
/// ui.ctx().load_texture(
|
||||
/// "my-image",
|
||||
/// egui::ColorImage::example(),
|
||||
/// egui::epaint::textures::TextureFilter::Linear
|
||||
/// egui::TextureFilter::Linear
|
||||
/// )
|
||||
/// });
|
||||
///
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use egui::{color::*, epaint::textures::TextureFilter, widgets::color_picker::show_color, *};
|
||||
use egui::{color::*, widgets::color_picker::show_color, TextureFilter, *};
|
||||
use std::collections::HashMap;
|
||||
|
||||
const GRADIENT_SIZE: Vec2 = vec2(256.0, 24.0);
|
||||
|
|
|
@ -552,7 +552,7 @@ impl ItemsDemo {
|
|||
ui.ctx().load_texture(
|
||||
"plot_demo",
|
||||
egui::ColorImage::example(),
|
||||
egui::epaint::textures::TextureFilter::Linear,
|
||||
egui::TextureFilter::Linear,
|
||||
)
|
||||
});
|
||||
let image = PlotImage::new(
|
||||
|
|
|
@ -118,7 +118,7 @@ impl WidgetGallery {
|
|||
ui.ctx().load_texture(
|
||||
"example",
|
||||
egui::ColorImage::example(),
|
||||
egui::epaint::textures::TextureFilter::Linear,
|
||||
egui::TextureFilter::Linear,
|
||||
)
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use egui::epaint::textures::TextureFilter;
|
||||
use egui::mutex::Mutex;
|
||||
use egui::TextureFilter;
|
||||
|
||||
/// An image to be shown in egui.
|
||||
///
|
||||
|
|
|
@ -20,7 +20,7 @@ pub use glow::Context;
|
|||
const VERT_SRC: &str = include_str!("shader/vertex.glsl");
|
||||
const FRAG_SRC: &str = include_str!("shader/fragment.glsl");
|
||||
|
||||
pub type TextureFilter = egui::epaint::textures::TextureFilter;
|
||||
pub type TextureFilter = egui::TextureFilter;
|
||||
|
||||
trait TextureFilterExt {
|
||||
fn glow_code(&self) -> u32;
|
||||
|
|
Loading…
Reference in a new issue