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)).unwrap();
22 dbg!(glcore);
23
24 let start_time = glfw.get_time();
25 while !window.should_close() {
26 let cur_frame_time = glfw.get_time();
27
28 glcore.glClearColor(cur_frame_time.sin() as f32, cur_frame_time.cos() as f32, (cur_frame_time * 1.5).sin() as f32, 1.0).unwrap();
29 glcore.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT).unwrap();
30
31 window.swap_buffers();
32 glfw.poll_events();
33 for (_, event) in glfw::flush_messages(&events) {
34 match event {
35 glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => {
36 window.set_should_close(true)
37 }
38 _ => {}
39 }
40 }
41 if cur_frame_time - start_time >= 10.0 {
42 window.set_should_close(true)
43 }
44 }
45 }
46}