diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/graphics.rs | 61 | ||||
-rw-r--r-- | src/main.rs | 7 |
2 files changed, 66 insertions, 2 deletions
diff --git a/src/graphics.rs b/src/graphics.rs index c3917af..ca98946 100644 --- a/src/graphics.rs +++ b/src/graphics.rs @@ -1,5 +1,64 @@ +extern crate sfml; + + +use sfml::window::{ + ContextSettings, + Event, + Style, +}; + +use sfml::graphics::{ + RenderWindow, + RenderTarget, + Color, +}; + + +struct State { + running: bool +} pub fn start() { - + let default_window_size = (1280, 720); + let default_framerate = 80; + + let mut state = State { + running: true + }; + + let context_settings = ContextSettings { + antialiasing_level: 0, + ..Default::default() + }; + + let mut window = RenderWindow::new( + default_window_size, + "Subconscious", + Style::CLOSE, + &context_settings + ); + + window.set_framerate_limit(default_framerate); + window.set_vertical_sync_enabled(true); + + + while state.running { + render(&mut window); + update(&mut window, &mut state); + } +} + +fn render(window: &mut RenderWindow) { + window.clear(&Color::BLACK); + window.display(); +} + +fn update(window: &mut RenderWindow, state: &mut State) { + while let Some(ev) = window.poll_event() { + match ev { + Event::Closed => state.running = false, + _ => {}, + } + } }
\ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 8de52c0..2679ac4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,5 +4,10 @@ mod graphics; fn main() { game::start(); - graphics::start(); + + let graphics_thread = std::thread::spawn(move || { + graphics::start(); + }); + + graphics_thread.join().unwrap(); } |