-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
egui_glow: Add function to set the texture filter #1041
Conversation
This commit adds a `set_scale_filter` method to the `glow` painter so that textures can be set to scale using nearest-neighbour scaling rather than linear. This is useful for pixel art. I wasn't entirely sure what kind of API you want for this kind of change so I went with what seemed least intrusive, I don't mind doing something more holistic if this isn't what you had in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but I think TextureFilter
is a better name!
egui_glow/src/painter.rs
Outdated
@@ -35,6 +35,7 @@ pub struct Painter { | |||
is_embedded: bool, | |||
vertex_array: crate::misc_util::VAO, | |||
srgb_support: bool, | |||
scale_filter: u32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scale_filter: u32, | |
/// The filter used for subsequent textures. | |
scale_filter: ScaleFilter, |
Done, changed to |
f06845d
to
dd6dc81
Compare
egui_glow/src/painter.rs
Outdated
@@ -35,6 +35,8 @@ pub struct Painter { | |||
is_embedded: bool, | |||
vertex_array: crate::misc_util::VAO, | |||
srgb_support: bool, | |||
/// The filter used for subsequent textures. | |||
texture_filter: u32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be nicer to use TextureFilter
here and defer the call to glow_code
? It would keep the code typesafe for longer.
texture_filter: u32, | |
texture_filter: TextureFilter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, seems reasonable to me!
glow
backend
This commit adds a
set_scale_filter
method to theglow
painter so thattextures can be set to scale using nearest-neighbour scaling rather than
linear. This is useful for pixel art.
I wasn't entirely sure what kind of API you want for this kind of change so I
went with what seemed least intrusive, I don't mind doing something more
holistic if this isn't what you had in mind.
Linear:
Nearest: