summaryrefslogtreecommitdiffstats
path: root/src/graphics.rs
blob: ca989461d0a00694a4b10ce71deb0ce17cd2d032 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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,
			_ => {},
		}
	}
}