integer scaling
This commit is contained in:
parent
e7f6c58d0a
commit
8efff459c4
|
@ -9,9 +9,19 @@ use sdl2::render::WindowCanvas;
|
||||||
|
|
||||||
pub(crate) fn paint_frame_on_canvas(frame: &VideoFrame, canvas: &mut WindowCanvas) -> bool {
|
pub(crate) fn paint_frame_on_canvas(frame: &VideoFrame, canvas: &mut WindowCanvas) -> bool {
|
||||||
if let Some((pixel_data, pitch)) = frame.data_pitch_as_bytes() {
|
if let Some((pixel_data, pitch)) = frame.data_pitch_as_bytes() {
|
||||||
|
let (cw, ch) = canvas.output_size().unwrap();
|
||||||
let (width, height) = frame.dimensions();
|
let (width, height) = frame.dimensions();
|
||||||
let pixel_format = frame.pixel_format().map(sdl2_pixfmt);
|
let pixel_format = frame.pixel_format().map(sdl2_pixfmt);
|
||||||
|
|
||||||
|
let should_intscale = if cw >= width && ch >= height {
|
||||||
|
sdl2::sys::SDL_bool::SDL_TRUE
|
||||||
|
} else {
|
||||||
|
sdl2::sys::SDL_bool::SDL_FALSE
|
||||||
|
};
|
||||||
|
unsafe {
|
||||||
|
sdl2::sys::SDL_RenderSetIntegerScale(canvas.raw(), should_intscale);
|
||||||
|
}
|
||||||
|
|
||||||
if let Ok(mut tex) = canvas
|
if let Ok(mut tex) = canvas
|
||||||
.texture_creator()
|
.texture_creator()
|
||||||
.create_texture_static(pixel_format, width, height)
|
.create_texture_static(pixel_format, width, height)
|
||||||
|
|
Loading…
Reference in New Issue