Make RawInput.max_texture_side an Option
This commit is contained in:
parent
76f564428b
commit
745f209c61
5 changed files with 21 additions and 9 deletions
|
@ -144,7 +144,7 @@ impl State {
|
|||
start_time: instant::Instant::now(),
|
||||
egui_input: egui::RawInput {
|
||||
pixels_per_point: Some(pixels_per_point),
|
||||
max_texture_side,
|
||||
max_texture_side: Some(max_texture_side),
|
||||
..Default::default()
|
||||
},
|
||||
pointer_pos_in_points: None,
|
||||
|
|
|
@ -79,7 +79,7 @@ impl ContextImpl {
|
|||
/// Load fonts unless already loaded.
|
||||
fn update_fonts_mut(&mut self) {
|
||||
let pixels_per_point = self.input.pixels_per_point();
|
||||
let max_texture_side = self.input.raw.max_texture_side;
|
||||
let max_texture_side = self.input.max_texture_side;
|
||||
|
||||
if let Some(font_definitions) = self.memory.new_font_definitions.take() {
|
||||
let fonts = Fonts::new(pixels_per_point, max_texture_side, font_definitions);
|
||||
|
|
|
@ -33,7 +33,7 @@ pub struct RawInput {
|
|||
/// Ask your graphics drivers about this. This corresponds to `GL_MAX_TEXTURE_SIZE`.
|
||||
///
|
||||
/// The default is a very small (but very portable) 2048.
|
||||
pub max_texture_side: usize,
|
||||
pub max_texture_side: Option<usize>,
|
||||
|
||||
/// Monotonically increasing time, in seconds. Relative to whatever. Used for animations.
|
||||
/// If `None` is provided, egui will assume a time delta of `predicted_dt` (default 1/60 seconds).
|
||||
|
@ -69,7 +69,7 @@ impl Default for RawInput {
|
|||
Self {
|
||||
screen_rect: None,
|
||||
pixels_per_point: None,
|
||||
max_texture_side: 2048,
|
||||
max_texture_side: None,
|
||||
time: None,
|
||||
predicted_dt: 1.0 / 60.0,
|
||||
modifiers: Modifiers::default(),
|
||||
|
@ -89,7 +89,7 @@ impl RawInput {
|
|||
RawInput {
|
||||
screen_rect: self.screen_rect.take(),
|
||||
pixels_per_point: self.pixels_per_point.take(),
|
||||
max_texture_side: self.max_texture_side,
|
||||
max_texture_side: self.max_texture_side.take(),
|
||||
time: self.time.take(),
|
||||
predicted_dt: self.predicted_dt,
|
||||
modifiers: self.modifiers,
|
||||
|
@ -115,7 +115,7 @@ impl RawInput {
|
|||
|
||||
self.screen_rect = screen_rect.or(self.screen_rect);
|
||||
self.pixels_per_point = pixels_per_point.or(self.pixels_per_point);
|
||||
self.max_texture_side = max_texture_side; // use latest
|
||||
self.max_texture_side = max_texture_side.or(self.max_texture_side);
|
||||
self.time = time; // use latest time
|
||||
self.predicted_dt = predicted_dt; // use latest dt
|
||||
self.modifiers = modifiers; // use latest
|
||||
|
@ -509,7 +509,7 @@ impl RawInput {
|
|||
.on_hover_text(
|
||||
"Also called HDPI factor.\nNumber of physical pixels per each logical pixel.",
|
||||
);
|
||||
ui.label(format!("max_texture_side: {}", max_texture_side));
|
||||
ui.label(format!("max_texture_side: {:?}", max_texture_side));
|
||||
if let Some(time) = time {
|
||||
ui.label(format!("time: {:.3} s", time));
|
||||
} else {
|
||||
|
|
|
@ -49,6 +49,11 @@ pub struct InputState {
|
|||
/// Also known as device pixel ratio, > 1 for high resolution screens.
|
||||
pub pixels_per_point: f32,
|
||||
|
||||
/// Maximum size of one side of a texture.
|
||||
///
|
||||
/// This depends on the backend.
|
||||
pub max_texture_side: usize,
|
||||
|
||||
/// Time in seconds. Relative to whatever. Used for animation.
|
||||
pub time: f64,
|
||||
|
||||
|
@ -82,6 +87,7 @@ impl Default for InputState {
|
|||
zoom_factor_delta: 1.0,
|
||||
screen_rect: Rect::from_min_size(Default::default(), vec2(10_000.0, 10_000.0)),
|
||||
pixels_per_point: 1.0,
|
||||
max_texture_side: 2048,
|
||||
time: 0.0,
|
||||
unstable_dt: 1.0 / 6.0,
|
||||
predicted_dt: 1.0 / 6.0,
|
||||
|
@ -134,6 +140,7 @@ impl InputState {
|
|||
zoom_factor_delta,
|
||||
screen_rect,
|
||||
pixels_per_point: new.pixels_per_point.unwrap_or(self.pixels_per_point),
|
||||
max_texture_side: new.max_texture_side.unwrap_or(self.max_texture_side),
|
||||
time,
|
||||
unstable_dt,
|
||||
predicted_dt: new.predicted_dt,
|
||||
|
@ -714,6 +721,7 @@ impl InputState {
|
|||
zoom_factor_delta,
|
||||
screen_rect,
|
||||
pixels_per_point,
|
||||
max_texture_side,
|
||||
time,
|
||||
unstable_dt,
|
||||
predicted_dt,
|
||||
|
@ -746,9 +754,13 @@ impl InputState {
|
|||
ui.label(format!("zoom_factor_delta: {:4.2}x", zoom_factor_delta));
|
||||
ui.label(format!("screen_rect: {:?} points", screen_rect));
|
||||
ui.label(format!(
|
||||
"{:?} physical pixels for each logical point",
|
||||
"{} physical pixels for each logical point",
|
||||
pixels_per_point
|
||||
));
|
||||
ui.label(format!(
|
||||
"max texture size (on each side): {}",
|
||||
max_texture_side
|
||||
));
|
||||
ui.label(format!("time: {:.3} s", time));
|
||||
ui.label(format!(
|
||||
"time since previous frame: {:.1} ms",
|
||||
|
|
|
@ -214,7 +214,7 @@ impl AppRunner {
|
|||
textures_delta: Default::default(),
|
||||
};
|
||||
|
||||
runner.input.raw.max_texture_side = runner.painter.max_texture_side();
|
||||
runner.input.raw.max_texture_side = Some(runner.painter.max_texture_side());
|
||||
|
||||
{
|
||||
runner
|
||||
|
|
Loading…
Reference in a new issue