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

add texture_scale_mode #100

Merged
merged 1 commit into from
Feb 8, 2025
Merged

Conversation

jagprog5
Copy link
Contributor

@jagprog5 jagprog5 commented Feb 8, 2025

PR got deleted once the fork was detached. Recreating it here.

Adds texture scale mode binding

@@ -818,6 +818,36 @@ fn ll_create_texture(
)
}

#[repr(i32)]
Copy link
Contributor Author

@jagprog5 jagprog5 Feb 8, 2025

Choose a reason for hiding this comment

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

I didn't include the following test, as it requires creating a texture creator and doubt this would work with the CI:

use sdl3::{pixels::PixelFormat, render::{ScaleMode, SurfaceCanvas}, surface::Surface};
use sdl3_sys::pixels::SDL_PIXELFORMAT_RGB24;

extern crate sdl3;

#[test]
fn test_scale_mode() {
    let sdl_context = sdl3::init().unwrap();
    let sdl_video_subsystem = sdl_context.video().unwrap();
    let window = sdl_video_subsystem
    .window(
        "tester",
        100,
        100,
    )
    .build()
    .unwrap();

    let canvas = window.into_canvas();
    let texture_creator = canvas.texture_creator();
    let surface = Surface::new(1, 1, PixelFormat::try_from(SDL_PIXELFORMAT_RGB24).unwrap()).unwrap();
    let mut texture = texture_creator.create_texture_from_surface(surface).unwrap();

    // checking the default scale mode
    assert_eq!(texture.scale_mode(), ScaleMode::Linear);
    // check set get
    texture.set_scale_mode(ScaleMode::Nearest);
    assert_eq!(texture.scale_mode(), ScaleMode::Nearest);
}

@revmischa revmischa merged commit 755e587 into vhspace:master Feb 8, 2025
3 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.

2 participants