cgl_rs/
lib.rs

1#![allow(dead_code)]
2
3
4//! The CGL Library
5//! 
6//! CGL is a library for creating cross-platform graphical applications and mainly creative coding.
7//! 
8//! 
9//! You can find the CGL main repository at : <https://github.com/Jaysmito101/cgl>
10//! 
11//! Also You can find a huge collections of creative coding projects, simultions, games made at : <https://github.com/Jaysmito101/cgl/tree/main/examples>
12
13use std::result;
14use libc::{c_void, c_int};
15
16
17
18mod macros;
19
20pub mod utils;
21pub mod math;
22pub mod graphics;
23pub mod logger;
24pub mod noise;
25// pub use logger::*;
26pub mod window;
27pub use window::*;
28
29extern {
30    fn CGL_init() -> c_int;
31    fn CGL_shutdown() -> c_void;
32}
33
34
35/// Initializes the CGL library.
36/// 
37/// This function must be called before any other CGL functions are called.
38///
39/// # Returns
40///
41/// Returns `Ok(())` if the initialization was successful, otherwise returns `Err(())`.
42pub fn init() -> result::Result<(), ()> {
43    unsafe {
44        let result = CGL_init();
45        if result == 0 {
46            Err(())
47        } else {
48            Ok(())
49        }   
50    }
51}
52
53
54/// Shuts down the CGL library.
55///
56/// This function should be called when the CGL library is no longer needed.
57pub fn shutdown() -> () {
58    unsafe {
59        CGL_shutdown();
60    }
61}