1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 13:50:04 -04:00

egui_glow: Add function to set the texture filter (#1041)

* Allow setting the scale filter for `glow` backend

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.

* Rename scale_filter -> texture_filter

* Store the TextureFilter directly

* PR link in changelog

* Use inter-doc links

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
Justin Jaffray
2022-01-06 08:09:53 -08:00
committed by GitHub
parent b0ea4dc0b5
commit 4fe5fa6c59
3 changed files with 38 additions and 3 deletions

View File

@@ -2,10 +2,13 @@
use glow::HasContext;
use std::option::Option::Some;
use crate::painter::TextureFilter;
pub(crate) fn srgbtexture2d(
gl: &glow::Context,
is_webgl_1: bool,
srgb_support: bool,
texture_filter: TextureFilter,
data: &[u8],
w: usize,
h: usize,
@@ -20,12 +23,12 @@ pub(crate) fn srgbtexture2d(
gl.tex_parameter_i32(
glow::TEXTURE_2D,
glow::TEXTURE_MAG_FILTER,
glow::LINEAR as i32,
texture_filter.glow_code() as i32,
);
gl.tex_parameter_i32(
glow::TEXTURE_2D,
glow::TEXTURE_MIN_FILTER,
glow::LINEAR as i32,
texture_filter.glow_code() as i32,
);
gl.tex_parameter_i32(
glow::TEXTURE_2D,