1mod glcore;
2
3pub use glcore::*;
4
5#[cfg(test)]
6mod tests {
7 use glfw::{Action, Context, Key, SwapInterval};
8 use crate::glcore::*;
9
10 #[test]
11 fn test() {
12 let mut glfw = glfw::init(glfw::fail_on_errors).unwrap();
13
14 let (mut window, events) = glfw.create_window(300, 300, "Hello this is window", glfw::WindowMode::Windowed)
15 .expect("Failed to create GLFW window.");
16
17 window.set_key_polling(true);
18 window.make_current();
19 glfw.set_swap_interval(SwapInterval::Adaptive);
20
21 let glcore = GLCore::new(|proc_name|window.get_proc_address(proc_name));
22
23 dbg!(glcore);
24
25 while !window.should_close() {
26 glfw.poll_events();
27 for (_, event) in glfw::flush_messages(&events) {
28 handle_window_event(&mut window, event);
29 }
30 let cur_frame_time = glfw.get_time();
31
32 glcore.glClearColor(cur_frame_time.sin() as f32, cur_frame_time.cos() as f32, (cur_frame_time * 1.5).sin() as f32, 1.0);
33 glcore.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
34
35 window.swap_buffers();
36 }
37 }
38
39 #[allow(dead_code)]
40 fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
41 match event {
42 glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => {
43 window.set_should_close(true)
44 }
45 _ => {}
46 }
47 }
48}