make toggleable fullscreen
This commit is contained in:
parent
c10bb02abd
commit
0bcedbbf19
1 changed files with 10 additions and 2 deletions
|
@ -7,10 +7,12 @@ use num::complex::{Complex, Complex32, ComplexFloat};
|
||||||
|
|
||||||
use sdl2::event::Event;
|
use sdl2::event::Event;
|
||||||
use sdl2::keyboard::Keycode;
|
use sdl2::keyboard::Keycode;
|
||||||
|
use sdl2::libc::KERN_PTY;
|
||||||
use sdl2::pixels::{self, Color};
|
use sdl2::pixels::{self, Color};
|
||||||
|
|
||||||
use sdl2::gfx::primitives::DrawRenderer;
|
use sdl2::gfx::primitives::DrawRenderer;
|
||||||
use sdl2::render::WindowCanvas;
|
use sdl2::render::WindowCanvas;
|
||||||
|
use sdl2::video::FullscreenType;
|
||||||
|
|
||||||
fn bound(n: f32, min: f32, max: f32) -> f32 {
|
fn bound(n: f32, min: f32, max: f32) -> f32 {
|
||||||
let mut vals = [min, n, max];
|
let mut vals = [min, n, max];
|
||||||
|
@ -131,7 +133,7 @@ impl Mandelbrot {
|
||||||
fn main() -> Result<(), String> {
|
fn main() -> Result<(), String> {
|
||||||
let sdl_context = sdl2::init()?;
|
let sdl_context = sdl2::init()?;
|
||||||
let video_subsys = sdl_context.video()?;
|
let video_subsys = sdl_context.video()?;
|
||||||
let window = video_subsys
|
let mut window = video_subsys
|
||||||
.window(
|
.window(
|
||||||
"Mandelbrot set",
|
"Mandelbrot set",
|
||||||
(SCREEN_WIDTH as u16).into(),
|
(SCREEN_WIDTH as u16).into(),
|
||||||
|
@ -142,7 +144,7 @@ fn main() -> Result<(), String> {
|
||||||
.build()
|
.build()
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
let mut canvas = window.into_canvas().build().map_err(|e| e.to_string())?;
|
let mut canvas = window.clone().into_canvas().build().map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
canvas.set_draw_color(pixels::Color::RGB(0, 0, 0));
|
canvas.set_draw_color(pixels::Color::RGB(0, 0, 0));
|
||||||
canvas.clear();
|
canvas.clear();
|
||||||
|
@ -179,6 +181,12 @@ fn main() -> Result<(), String> {
|
||||||
mandelbrot.iter();
|
mandelbrot.iter();
|
||||||
} else if keycode == Keycode::BACKSPACE {
|
} else if keycode == Keycode::BACKSPACE {
|
||||||
mandelbrot.show_projections(&mut canvas);
|
mandelbrot.show_projections(&mut canvas);
|
||||||
|
} else if keycode == Keycode::F11 {
|
||||||
|
if window.fullscreen_state() == FullscreenType::Off {
|
||||||
|
let _ = window.set_fullscreen(FullscreenType::True);
|
||||||
|
} else {
|
||||||
|
let _ = window.set_fullscreen(FullscreenType::Off);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue