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

added ability to change default texture filter #772

Merged
merged 3 commits into from
Aug 11, 2024

Conversation

0x177
Copy link
Contributor

@0x177 0x177 commented Aug 5, 2024

resolves #762

@not-fl3
Copy link
Owner

not-fl3 commented Aug 5, 2024

LGTM, but maybe add it as a field to `conf::Conf as well?

@0x177
Copy link
Contributor Author

0x177 commented Aug 6, 2024

conf::Conf doesn't seem as accessible as Context, so i do not see how i would access/change the default filter mode if it is stored in Conf

@not-fl3
Copy link
Owner

not-fl3 commented Aug 6, 2024

Something like this:

fn window_conf() -> Conf {
    Conf {
        default_texture_filter: Filter,
        ..Default::default()
    }
}

#[macroquad::main(window_conf)]
async fn main() {
    loop {
        clear_background(WHITE);
        next_frame().await
    }
}

@0x177
Copy link
Contributor Author

0x177 commented Aug 7, 2024

this would require some minor changes to miniquad. i have made a pr for them

@0x177
Copy link
Contributor Author

0x177 commented Aug 11, 2024

my recent commit has implemented it. here is an example of how the api may be used:

use macroquad::prelude::*;

fn window_conf() -> macroquad::conf::Conf {
    macroquad::conf::Conf {
	miniquad_conf: Conf {
            ..Default::default()
	},
	default_filter_mode: FilterMode::Nearest,
	update_on: None,
    }
}

#[macroquad::main(window_conf)]
async fn main() {
    let texture: Texture2D = load_texture("pixel.png").await.unwrap();
    
    loop {
        clear_background(LIGHTGRAY);
        draw_texture_ex(&texture, 0., 0., WHITE,DrawTextureParams {
	    dest_size: Some(Vec2::new(screen_width(),screen_height())),
	    ..Default::default()
	});
        next_frame().await
    }
}

@not-fl3
Copy link
Owner

not-fl3 commented Aug 11, 2024

Thanks for PR!

@not-fl3 not-fl3 merged commit f77e656 into not-fl3:master Aug 11, 2024
5 of 6 checks passed
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.

Default filter mode for loaded textures
2 participants