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
65
66
/*!

Rust FFI to [Sokol] headers for [Rokol] ([API](https://docs.rs/rokol/latest/rokol/))

Last update: Dec 3, 2020 ([commit]). Sokol header declaration diffs can be seen on [GitHub][Rokol].

[Sokol]: https://github.com/floooh/sokol
[Rokol]: https://github.com/toyboot4e/rokol
[commit]: https://github.com/floooh/sokol/commit/64a6f2e2fac607ddcd4ccc5bd8bcd25946293550

# impl Default

Generated with [`bindgen`], implementing [`Default`] trait
([`Bindgen::derive_default(true)`][derive]).

NOTE: Sokol [considers] zero-initizialized structures to be in default state. It means
[`Default::default`] is ensured to make sense!

[`bindgen`]: https://docs.rs/bindgen/latest/bindgen
[derive]: https://docs.rs/bindgen/0.56.0/bindgen/struct.Builder.html#method.derive_default
[considers]: https://floooh.github.io/2017/08/06/sokol-api-update.html

*/

// TODO: Do not use `include!` so that we get goto support in Emacs
// https://docs.rs/bindgen/0.56.0/bindgen/struct.Builder.html#method.module_raw_lines

pub mod app {
    //! FFI to [`sokol_app.h`](https://github.com/floooh/sokol/blob/master/sokol_app.h)

    // suppress all warnings
    #![allow(warnings)]

    // Include generated bindings
    include!("ffi/sokol_app.rs");
}

pub mod gfx {
    //! FFI to [`sokol_gfx.h`](https://github.com/floooh/sokol/blob/master/sokol_gfx.h)

    // suppress all warnings
    #![allow(warnings)]

    include!("ffi/sokol_gfx.rs");
}

pub mod glue {
    //! FFI to [`sokol_glue.h`](https://github.com/floooh/sokol/blob/master/sokol_glue.h)

    // there's only one function so let's write it manually
    extern "C" {
        pub fn sapp_sgcontext() -> crate::gfx::sg_context_desc;
    }
}

#[cfg(test)]
mod test {
    /// Just to make sure we link to `sokol`
    fn link_test() {
        unsafe {
            let mut desc: crate::gfx::sg_desc = Default::default();
            desc.context = crate::glue::sapp_sgcontext();
            crate::gfx::sg_setup(&desc);
        }
    }
}