summaryrefslogtreecommitdiffstats
path: root/src/graphics.rs
blob: 003f182436c7ccbaddad08aec9525076d8b8595c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
extern crate sfml;

use sfml::window::{
	ContextSettings,
	Event,
	Style,
};

use sfml::graphics::{
	RenderWindow,
	RenderTarget,
	Color,
};

pub fn start() -> RenderWindow {
	let default_window_size = (1280, 720);
	let default_framerate = 80;

	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);

	return window;
}

pub fn render(window: &mut RenderWindow) {
	window.clear(&Color::BLACK);
	window.display();
}

pub fn update(window: &mut RenderWindow) {
	while let Some(ev) = window.poll_event() {
		match ev {
			Event::Closed => window.close(),
			_ => {},
		}
	}
}