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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#![cfg(target_os = "emscripten")]
#![allow(dead_code, non_snake_case, non_camel_case_types)]
use std::os::raw;
pub type EM_BOOL = raw::c_int;
pub type EM_UTF8 = raw::c_char;
pub type EMSCRIPTEN_WEBGL_CONTEXT_HANDLE = raw::c_int;
pub type EMSCRIPTEN_RESULT = raw::c_int;
pub type em_webgl_context_callback =
extern "C" fn(raw::c_int, *const raw::c_void, *mut raw::c_void) -> EM_BOOL;
pub type em_callback_func = unsafe extern "C" fn();
#[repr(C)]
#[derive(Debug)]
pub struct EmscriptenWebGLContextAttributes {
pub alpha: EM_BOOL,
pub depth: EM_BOOL,
pub stencil: EM_BOOL,
pub antialias: EM_BOOL,
pub premultipliedAlpha: EM_BOOL,
pub preserveDrawingBuffer: EM_BOOL,
pub preferLowPowerToHighPerformance: EM_BOOL,
pub failIfMajorPerformanceCaveat: EM_BOOL,
pub majorVersion: raw::c_int,
pub minorVersion: raw::c_int,
pub enableExtensionsByDefault: EM_BOOL,
pub explicitSwapControl: EM_BOOL,
}
pub const EMSCRIPTEN_RESULT_SUCCESS: raw::c_int = 0;
pub const EMSCRIPTEN_RESULT_DEFERRED: raw::c_int = 1;
pub const EMSCRIPTEN_RESULT_NOT_SUPPORTED: raw::c_int = -1;
pub const EMSCRIPTEN_RESULT_FAILED_NOT_DEFERRED: raw::c_int = -2;
pub const EMSCRIPTEN_RESULT_INVALID_TARGET: raw::c_int = -3;
pub const EMSCRIPTEN_RESULT_UNKNOWN_TARGET: raw::c_int = -4;
pub const EMSCRIPTEN_RESULT_INVALID_PARAM: raw::c_int = -5;
pub const EMSCRIPTEN_RESULT_FAILED: raw::c_int = -6;
pub const EMSCRIPTEN_RESULT_NO_DATA: raw::c_int = -7;
extern "C" {
pub fn emscripten_webgl_init_context_attributes(
attributes: *mut EmscriptenWebGLContextAttributes,
);
pub fn emscripten_webgl_create_context(
target: *const raw::c_char,
attributes: *const EmscriptenWebGLContextAttributes,
) -> EMSCRIPTEN_WEBGL_CONTEXT_HANDLE;
pub fn emscripten_webgl_make_context_current(
context: EMSCRIPTEN_WEBGL_CONTEXT_HANDLE,
) -> EMSCRIPTEN_RESULT;
pub fn emscripten_webgl_get_current_context(
) -> EMSCRIPTEN_WEBGL_CONTEXT_HANDLE;
pub fn emscripten_webgl_destroy_context(
context: EMSCRIPTEN_WEBGL_CONTEXT_HANDLE,
) -> EMSCRIPTEN_RESULT;
pub fn emscripten_webgl_enable_extension(
context: EMSCRIPTEN_WEBGL_CONTEXT_HANDLE,
extension: *const raw::c_char,
) -> EM_BOOL;
pub fn emscripten_set_webglcontextlost_callback(
target: *const raw::c_char,
userData: *mut raw::c_void,
useCapture: EM_BOOL,
callback: em_webgl_context_callback,
) -> EMSCRIPTEN_RESULT;
pub fn emscripten_set_webglcontextrestored_callback(
target: *const raw::c_char,
userData: *mut raw::c_void,
useCapture: EM_BOOL,
callback: em_webgl_context_callback,
) -> EMSCRIPTEN_RESULT;
pub fn emscripten_is_webgl_context_lost(
target: *const raw::c_char,
) -> EM_BOOL;
pub fn emscripten_GetProcAddress(
name: *const raw::c_char,
) -> *const raw::c_void;
pub fn emscripten_request_fullscreen(
target: *const raw::c_char,
deferUntilInEventHandler: EM_BOOL,
) -> EMSCRIPTEN_RESULT;
pub fn emscripten_exit_fullscreen() -> EMSCRIPTEN_RESULT;
pub fn emscripten_set_element_css_size(
target: *const raw::c_char,
width: raw::c_double,
height: raw::c_double,
) -> EMSCRIPTEN_RESULT;
pub fn emscripten_get_element_css_size(
target: *const raw::c_char,
width: *mut raw::c_double,
height: *mut raw::c_double,
) -> EMSCRIPTEN_RESULT;
pub fn emscripten_sleep(delay: raw::c_uint);
pub fn emscripten_set_main_loop(
func: em_callback_func,
fps: raw::c_int,
simulate_infinite_loop: raw::c_int,
);
}