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

Texture2d::from_rgba8 ignores default_filter_mode #830

Closed
InnocentusLime opened this issue Sep 28, 2024 · 0 comments · Fixed by #838
Closed

Texture2d::from_rgba8 ignores default_filter_mode #830

InnocentusLime opened this issue Sep 28, 2024 · 0 comments · Fixed by #838
Labels
bug Something isn't working

Comments

@InnocentusLime
Copy link
Contributor

The problem

Texture2d::from_rgba8 and, consequently, Texture2d::from_image completely ignore the default_filter_mode setting.

Reproducible Example

The following code shows the example

#[macroquad::main("Blurry")]
async fn main() {
    set_default_filter_mode(FilterMode::Nearest);

    let t = Texture2D::from_rgba8(3, 3, &[
        255, 255, 255, 255,    0  , 0  , 0  , 0  ,  255, 255, 255, 255,
        0  , 0  , 0  , 0  ,    255, 255, 255, 255,  0  , 0  , 0  , 0  ,
        255, 255, 255, 255,    0  , 0  , 0  , 0  ,  255, 255, 255, 255,
    ]);
    /* Uncomment to get the intended result */
    // t.set_filter(FilterMode::Nearest);

    loop {
        clear_background(GRAY);

        draw_texture_ex(
            &t,
            0.0,
            0.0,
            WHITE,
            DrawTextureParams {
                dest_size: Some(vec2(400.0, 400.0)),
                ..Default::default()
            }
        );

        next_frame().await;
    }
}

The Fix

I can work on the fix if it that behaviour is unintended. I believe it's pretty simple:

  • All Texture2d creation stuff eventually boils down to calling Texture2d::from_rgba8
  • To leverage the delegation pattern, one should simply move .set_filter call from from_file_with_format to Texure2d::from_rgba8
@not-fl3 not-fl3 added the bug Something isn't working label Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants