diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2015-05-03 11:10:32 +0200 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2015-05-03 11:10:32 +0200 |
commit | e953e3d4ead7931bc32c49bcd9f4a637ef6d5fa7 (patch) | |
tree | 2e9a21dd41d06fd0a8cca4ef88e779021a213794 /src/api/emscripten/ffi.rs | |
parent | b9aa741c261b12c3edd7f17d228f0b639f203952 (diff) | |
parent | de7b1aa2ebb8fcf7a9e605bf720d6e644d2fa33a (diff) | |
download | glutin-e953e3d4ead7931bc32c49bcd9f4a637ef6d5fa7.tar.gz glutin-e953e3d4ead7931bc32c49bcd9f4a637ef6d5fa7.zip |
Merge pull request #36 from tomaka/emscripten
[WIP] Support for emscripten
Diffstat (limited to 'src/api/emscripten/ffi.rs')
-rw-r--r-- | src/api/emscripten/ffi.rs | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/api/emscripten/ffi.rs b/src/api/emscripten/ffi.rs new file mode 100644 index 0000000..34b6c17 --- /dev/null +++ b/src/api/emscripten/ffi.rs @@ -0,0 +1,82 @@ +#![allow(dead_code)] +#![allow(non_snake_case)] +#![allow(non_camel_case_types)] + +use libc; + +pub type EM_BOOL = libc::c_int; +pub type EM_UTF8 = libc::c_char; +pub type EMSCRIPTEN_WEBGL_CONTEXT_HANDLE = libc::c_int; +pub type EMSCRIPTEN_RESULT = libc::c_int; + +pub type em_webgl_context_callback = extern fn(libc::c_int, *const libc::c_void, *mut libc::c_void) + -> EM_BOOL; + +#[repr(C)] +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: libc::c_int, + pub minorVersion: libc::c_int, + pub enableExtensionsByDefault: EM_BOOL, +} + +// values for EMSCRIPTEN_RESULT +pub const EMSCRIPTEN_RESULT_SUCCESS: libc::c_int = 0; +pub const EMSCRIPTEN_RESULT_DEFERRED: libc::c_int = 1; +pub const EMSCRIPTEN_RESULT_NOT_SUPPORTED: libc::c_int = -1; +pub const EMSCRIPTEN_RESULT_FAILED_NOT_DEFERRED: libc::c_int = -2; +pub const EMSCRIPTEN_RESULT_INVALID_TARGET: libc::c_int = -3; +pub const EMSCRIPTEN_RESULT_UNKNOWN_TARGET: libc::c_int = -4; +pub const EMSCRIPTEN_RESULT_INVALID_PARAM: libc::c_int = -5; +pub const EMSCRIPTEN_RESULT_FAILED: libc::c_int = -6; +pub const EMSCRIPTEN_RESULT_NO_DATA: libc::c_int = -7; + +extern { + pub fn emscripten_webgl_init_context_attributes(attributes: *mut EmscriptenWebGLContextAttributes); + pub fn emscripten_webgl_create_context(target: *const libc::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 libc::c_char) -> EM_BOOL; + + pub fn emscripten_set_webglcontextlost_callback(target: *const libc::c_char, + userData: *mut libc::c_void, useCapture: EM_BOOL, callback: em_webgl_context_callback) + -> EMSCRIPTEN_RESULT; + pub fn emscripten_set_webglcontextrestored_callback(target: *const libc::c_char, + userData: *mut libc::c_void, useCapture: EM_BOOL, callback: em_webgl_context_callback) + -> EMSCRIPTEN_RESULT; + + pub fn emscripten_is_webgl_context_lost(target: *const libc::c_char) -> EM_BOOL; + + // note: this function is not documented but is used by the ports of glfw, SDL and EGL + pub fn emscripten_GetProcAddress(name: *const libc::c_char) -> *const libc::c_void; + + + pub fn emscripten_request_fullscreen(target: *const libc::c_char, + deferUntilInEventHandler: EM_BOOL) -> EMSCRIPTEN_RESULT; + + pub fn emscripten_exit_fullscreen() -> EMSCRIPTEN_RESULT; + + pub fn emscripten_set_element_css_size(target: *const libc::c_char, width: libc::c_double, + height: libc::c_double) -> EMSCRIPTEN_RESULT; + + pub fn emscripten_get_element_css_size(target: *const libc::c_char, width: *mut libc::c_double, + height: *mut libc::c_double) -> EMSCRIPTEN_RESULT; + + pub fn emscripten_sleep(delay: libc::c_uint); +} |