tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

swgl_bindings.rs (2373B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 use gleam::gl::Gl;
      6 
      7 use std::os::raw::c_void;
      8 
      9 #[no_mangle]
     10 pub extern "C" fn wr_swgl_create_context() -> *mut c_void {
     11    swgl::Context::create().into()
     12 }
     13 
     14 #[no_mangle]
     15 pub extern "C" fn wr_swgl_reference_context(ctx: *mut c_void) {
     16    swgl::Context::from(ctx).reference();
     17 }
     18 
     19 #[no_mangle]
     20 pub extern "C" fn wr_swgl_destroy_context(ctx: *mut c_void) {
     21    swgl::Context::from(ctx).destroy();
     22 }
     23 
     24 #[no_mangle]
     25 pub extern "C" fn wr_swgl_make_current(ctx: *mut c_void) {
     26    swgl::Context::from(ctx).make_current();
     27 }
     28 
     29 #[no_mangle]
     30 pub extern "C" fn wr_swgl_init_default_framebuffer(
     31    ctx: *mut c_void,
     32    x: i32,
     33    y: i32,
     34    width: i32,
     35    height: i32,
     36    stride: i32,
     37    buf: *mut c_void,
     38 ) {
     39    swgl::Context::from(ctx).init_default_framebuffer(x, y, width, height, stride, buf);
     40 }
     41 
     42 #[no_mangle]
     43 pub extern "C" fn wr_swgl_resolve_framebuffer(ctx: *mut c_void, fbo: u32) {
     44    swgl::Context::from(ctx).resolve_framebuffer(fbo);
     45 }
     46 
     47 #[no_mangle]
     48 pub extern "C" fn wr_swgl_gen_texture(ctx: *mut c_void) -> u32 {
     49    swgl::Context::from(ctx).gen_textures(1)[0]
     50 }
     51 
     52 #[no_mangle]
     53 pub extern "C" fn wr_swgl_delete_texture(ctx: *mut c_void, tex: u32) {
     54    swgl::Context::from(ctx).delete_textures(&[tex]);
     55 }
     56 
     57 #[no_mangle]
     58 pub extern "C" fn wr_swgl_set_texture_parameter(ctx: *mut c_void, tex: u32, pname: u32, param: i32) {
     59    swgl::Context::from(ctx).set_texture_parameter(tex, pname, param);
     60 }
     61 
     62 #[no_mangle]
     63 pub extern "C" fn wr_swgl_set_texture_buffer(
     64    ctx: *mut c_void,
     65    tex: u32,
     66    internal_format: u32,
     67    width: i32,
     68    height: i32,
     69    stride: i32,
     70    buf: *mut c_void,
     71    min_width: i32,
     72    min_height: i32,
     73 ) {
     74    swgl::Context::from(ctx).set_texture_buffer(
     75        tex,
     76        internal_format,
     77        width,
     78        height,
     79        stride,
     80        buf,
     81        min_width,
     82        min_height,
     83    );
     84 }
     85 
     86 #[no_mangle]
     87 #[allow(clippy::many_single_char_names)]
     88 pub extern "C" fn wr_swgl_clear_color_rect(
     89    ctx: *mut c_void,
     90    fbo: u32,
     91    x: i32,
     92    y: i32,
     93    width: i32,
     94    height: i32,
     95    r: f32,
     96    g: f32,
     97    b: f32,
     98    a: f32,
     99 ) {
    100    swgl::Context::from(ctx).clear_color_rect(fbo, x, y, width, height, r, g, b, a);
    101 }