Skip to content
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

Merged
merged 5 commits into from
Jan 6, 2022

Conversation

justinj
Copy link
Contributor

@justinj justinj commented Jan 5, 2022

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.

Linear:
image

Nearest:
image

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.
Copy link
Owner

@emilk emilk left a 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!

@@ -35,6 +35,7 @@ pub struct Painter {
is_embedded: bool,
vertex_array: crate::misc_util::VAO,
srgb_support: bool,
scale_filter: u32,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
scale_filter: u32,
/// The filter used for subsequent textures.
scale_filter: ScaleFilter,

@justinj
Copy link
Contributor Author

justinj commented Jan 5, 2022

Done, changed to TextureFilter.

@@ -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,
Copy link
Owner

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.

Suggested change
texture_filter: u32,
texture_filter: TextureFilter,

Copy link
Contributor Author

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!

egui_glow/CHANGELOG.md Outdated Show resolved Hide resolved
egui_glow/src/painter.rs Outdated Show resolved Hide resolved
@emilk emilk changed the title Allow setting the scale filter for glow backend egui_glow: Add function to set the texture filter Jan 6, 2022
@emilk emilk merged commit 4fe5fa6 into emilk:master Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants