Rust bindings to bgfx, a cross-platform, graphics API agnostic

Related tags

Graphics bgfx-rs
Overview

bgfx-rs

Rust bindings to bgfx, a cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.

Why another wrapper?

While this wrapper for Rust exists, the code here takes a different approach and generate high-level bindings from the BGFX API def instead which will allow easier updating of the bindings once the API changes with much reduced work. In some cases there will be manual implementation where it makes sense to provide more ergonomic Rust code where auto-generation is difficult.

Status

Currently being developed and the API is changing. The goal of this library is to cover the majority of the BGFX functionality while providing some Rust style convenience on top of the C API.

Usage

# Cargo.toml
[dependencies]
bgfx-rs = "0.4"

The library doesn't include any window handling and that has to be provided by the user. See examples an how to use GLFW

License

Licensed under BSD 2-Clause to keep the license the same the BGFX code.

Comments
  • Segmentation fault if destroy_shaders is true when calling create_program()

    Segmentation fault if destroy_shaders is true when calling create_program()

    If the last parameter (destroy_shaders) to bgfx::create_program(&vsh, &fsh, false) is set to true, I'm running into a segmentation fault; When set to false it is working correctly, but as far as I'm aware the shader objects are not needed anynore after the program is created.

    On Windows: "(exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)" On Linux: "Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)"

    The debugger seems to indicate the problem happens in GL_CHECK(glUniform1iv(loc, num, data) ); on line 4427 in renderer_gl.cpp which is called from bgfx_rs::static_lib::frame().

    Sample repository: https://github.com/const-volatile/bgfx-imgui-glfw-rs-example Toolchain: rustc 1.62.0-nightly (52ca603da 2022-04-12) If changing line 60 here: https://github.com/const-volatile/bgfx-imgui-glfw-rs-example/blob/main/src/imgui_bgfx_renderer/mod.rs the segmentation fault can be observed.

    Could this be an issue with bgfx-rs?

    opened by const-volatile 7
  • Unable to compile. MSVC error 1120

    Unable to compile. MSVC error 1120

    I'm using the most recent stable build of Rust, with the MSVC compiler. When I try to compile my own project or one of the examples, it fails with error code 1120, and complains about several unresolved external symbols. Is there a special setup step I haven't noticed? This error occurs with all 3 examples, though 2 of them have a typo in the code that has to be fixed first.

    opened by Syntaxxor 6
  • Wrong VertexLayoutBuilder semantics

    Wrong VertexLayoutBuilder semantics

    I encountered some crashes/invalid rendering when using multiple VertexLayoutBuilder. I narrowed this down to VertexLayoutBuilder.end() not being called by me, but in doing so I found numerous issues with VertexLayoutBuilder:

    • begin, add and end mutate the builder but don't take a mutable reference
    • VertexLayoutBuilder is able to be passed to various APIs without end being called. A new type safely encapsulating this requirement would be preferred.
    • begin and add both return &Self, meaning you can't assign their result to a variable. AFAIK Self is idiomatic.

    I'm working on a PR for this.

    opened by BenjaminSchaaf 5
  • Segmentation Fault in bgfx::shutdown()

    Segmentation Fault in bgfx::shutdown()

    First of all, Thank you very much for maintaining these rust bindings to bgfx - It's a great addition to the evolving rust ecosystem. However, I'm facing one problem whenever I call bgfx:shutdown() from my application there is an Segmentation fault happening. I was able to debug the root-cause up as following:

    BX_ALIGNED_DELETE(g_allocator, ctx, Context::kAlignment); in bgfx.cpp::shutdown() is invoking the destructor of the Context class (bgfx_p.h). The Context class contains a list of TextureRefs m_textureHandle in which the destructor for each element is invoked explicitly. Each TextureRef has an bx::String m_name for which the destructor is invoked explicitly. This destructor will call the clear()method in bx::StringT, which will call to BX_FREE(*AllocatorT, const_cast<char*>(m_ptr) );. This will call to bx::free and from there to bgfx::AllocatorStub::realloc. From there free is called from the clib (bgfx.cpp, Line 192, ::free(_ptr);).

    Now here I do encounter the segmentation fault; even at this time my only texture is already released (automatically once its owner left the scope). There is still an fair chance, that the issue is due to an mistake in my application code - I double-checked multiple times and was not able to spot what could be the reason.

    Below is a Minimal, Reproducible Example (the shaders are embedded, but there needs to be an file "test.png" in the working directory):

    use bgfx::*;
    use bgfx_rs::bgfx;
    use glfw::{Action, Key, Window, WindowMode};
    use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
    
    const WIDTH: usize = 1280;
    const HEIGHT: usize = 720;
    
    fn load_image (filepath : &str) -> bgfx::Texture {
        let mut file = std::fs::File::open(filepath).unwrap();
        let img = stb::image::stbi_load_from_reader(&mut file, stb::image::Channels::RgbAlpha).unwrap();
        return bgfx::create_texture_2d(img.0.width as u16, img.0.height as u16, false, 1, bgfx::TextureFormat::RGBA8, 0, &Memory::copy(&img.1.as_slice()));
    }
    
    fn load_shader() -> bgfx::Program {
        let vsh_bytes: [u8;341] =  [
            0x56, 0x53, 0x48, 0x06, 0x00, 0x00, 0x00, 0x00, 0x6f, 0x1e, 0x3e, 0x3c, 0x01, 0x00, 0x0f, 0x75, // VSH.....o.><...u
            0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, // _modelViewProj..
            0x00, 0x00, 0x01, 0x00, 0x2c, 0x01, 0x00, 0x00, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, // ....,...attribut
            0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x61, 0x5f, 0x70, // e highp vec3 a_p
            0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, // osition;.attribu
            0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x61, 0x5f, // te highp vec2 a_
            0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, // texcoord0;.varyi
            0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, // ng highp vec2 v_
            0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, // texcoord0;.unifo
            0x72, 0x6d, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x6d, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, // rm highp mat4 u_
            0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x76, // modelViewProj;.v
            0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, // oid main ().{.
            0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // highp vec4 tmpva
            0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, // r_1;.  tmpvar_1.
            0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // w = 1.0;.  tmpva
            0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, // r_1.xyz = a_posi
            0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, // tion;.  gl_Posit
            0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x28, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, // ion = (u_modelVi
            0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // ewProj * tmpvar_
            0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, // 1);.  v_texcoord
            0x30, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, // 0 = a_texcoord0;
            0x0a, 0x7d, 0x0a, 0x0a, 0x00,                                                                   // .}...
        ];
        let fsh_bytes: [u8;215] = [
            0x46, 0x53, 0x48, 0x06, 0x6f, 0x1e, 0x3e, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x73, // FSH.o.><.......s
            0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0xb3, // _texColor.......
            0x00, 0x00, 0x00, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, // ...varying highp
            0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, //  vec2 v_texcoord
            0x30, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, // 0;.uniform sampl
            0x65, 0x72, 0x32, 0x44, 0x20, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, // er2D s_texColor;
            0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, // .void main ().{.
            0x20, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, //   lowp vec4 tmpv
            0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, // ar_1;.  tmpvar_1
            0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x20, 0x28, 0x73, 0x5f, //  = texture2D (s_
            0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, // texColor, v_texc
            0x6f, 0x6f, 0x72, 0x64, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, // oord0);.  gl_Fra
            0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // gColor = tmpvar_
            0x31, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00,                                                       // 1;.}...
        ];
    
        let vsh = bgfx::create_shader(&Memory::copy(&vsh_bytes));
        let fsh = bgfx::create_shader(&Memory::copy(&fsh_bytes));
    
        bgfx::create_program(&vsh, &fsh, true)
    }
    
    fn draw_image(shader : &bgfx::Program, texture: &bgfx::Texture){
        let id : bgfx::ViewId = 0x00;
        let builder = bgfx::VertexLayoutBuilder::new();
        builder.begin(get_render_type());
        builder.add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float, AddArgs::default());
        builder.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float, AddArgs::default());
        builder.end();
    
        let mut tvb = bgfx::TransientVertexBuffer::new();
        if bgfx::get_avail_transient_vertex_buffer(4, &builder) == 4 {
            bgfx::alloc_transient_vertex_buffer(&mut tvb, 4, &builder);
            let vertices : [f32; 16] = [
                0.0f32, 0.0f32, 0.0f32, 0.0f32,
                1024.0f32, 0.0f32, 1024.0f32, 0.0f32,
                0.0f32, 1024.0f32, 0.0f32, 1024.0f32,
                1024.0f32, 1024.0f32, 1024.0f32, 1024.0f32,
            ];
            unsafe {
                std::ptr::copy_nonoverlapping(vertices.as_ptr() as *const u8, tvb.data as *mut u8, std::mem::size_of::<[f32; 16]>()); //this line causes SIGSEGV
            }
            bgfx::set_transient_vertex_buffer(0, &tvb, 0, 4);
            bgfx::set_state(StatePtFlags::TRISTRIP.bits() | StateWriteFlags::RGB.bits() | StateDepthTestFlags::LESS.bits() | StateBlendFlags::SRC_ALPHA.bits() | StateFlags::MSAA.bits(), 0);
            let mvp = [
                0.0f32, 0.0f32, 0.0f32, 0.0f32,
                0.0f32, 0.0f32, 0.0f32, 0.0f32,
                0.0f32, 0.0f32, 0.0f32, 0.0f32,
                0.0f32, 0.0f32, 0.0f32, 0.0f32,
            ];
            bgfx::set_uniform(&bgfx::Uniform::create("modelViewProj", bgfx::UniformType::Mat4, 1), &mvp.as_slice(), 1);
            bgfx::set_texture(0, &bgfx::Uniform::create("texColor", bgfx::UniformType::Sampler, 1), &texture, u32::MAX);
            bgfx::submit(id, &shader, bgfx_rs::static_lib::SubmitArgs{ depth: 1, flags: DiscardFlags::NONE.bits() });
        }
    }
    
    #[cfg(target_os = "linux")]
    fn update_platform_handle(pd: &mut PlatformData, window: &Window) {
        match window.raw_window_handle() {
            RawWindowHandle::Xlib(x_data) => {
                pd.ndt = x_data.display;
                pd.nwh = x_data.window as *mut core::ffi::c_void;
            }
            _ => panic!("Unsupported window type"),
        }
    }
    
    #[cfg(target_os = "windows")]
    fn update_platform_handle(pd: &mut PlatformData, window: &Window) {
        match window.raw_window_handle() {
            RawWindowHandle::Windows(data) => {
                pd.nwh = data.hwnd as *mut core::ffi::c_void;
            }
            _ => panic!("Unsupported window type"),
        }
    }
    
    #[cfg(target_os = "linux")]
    fn get_render_type() -> RendererType {
        RendererType::OpenGL
    }
    
    #[cfg(not(target_os = "linux"))]
    fn get_render_type() -> RendererType {
        RendererType::Count
    }
    
    fn main() {
        let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
        glfw.window_hint(glfw::WindowHint::ClientApi(glfw::ClientApiHint::NoApi));
        let (mut window, events) = glfw
            .create_window(
                WIDTH as _,
                HEIGHT as _,
                "App - ESC to close",
                glfw::WindowMode::Windowed,
            )
            .expect("Failed to create GLFW window.");
        window.set_key_polling(true);
    
        let mut pd = bgfx::PlatformData::new();
        update_platform_handle(&mut pd, &window);
        bgfx::set_platform_data(&pd);
        let mut init = Init::new();
        init.type_r = get_render_type();
        init.resolution.width = WIDTH as u32;
        init.resolution.height = HEIGHT as u32;
        init.resolution.reset = ResetFlags::VSYNC.bits();
        init.platform_data = pd;
    
        if !bgfx::init(&init) {
            panic!("failed to init bgfx");
        }
    
        bgfx::set_debug(DebugFlags::TEXT.bits());
        let mut old_size = (0, 0);
        {
            let shader = load_shader();
            let texture = load_image("test.png");
            while !window.should_close() {
                glfw.poll_events();
                for (_, event) in glfw::flush_messages(&events) {
    
                    if let glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) = event {
                        window.set_should_close(true)
                    }
                }
    
                let size = window.get_framebuffer_size();
    
                if old_size != size {
                    bgfx::reset(size.0 as _, size.1 as _, ResetArgs::default());
                    old_size = size;
                }
    
                bgfx::set_view_rect(0, 0, 0, size.0 as _, size.1 as _);
                bgfx::set_view_clear(
                    0,
                    ClearFlags::COLOR.bits() | ClearFlags::DEPTH.bits(),
                    SetViewClearArgs {
                        rgba: 0x103030ff,
                        ..Default::default()
                    },
                );
                bgfx::touch(0);
    
                draw_image(&shader, &texture);
    
                bgfx::frame(false);
            }
        }
        bgfx::shutdown();
    }
    

    The dependencies are:

    [dependencies]
    bgfx-rs = "0.8"
    glfw = "0.41"
    raw-window-handle = "0.3"
    stb = "0.3.2"
    

    Either closing the window by clicking the X or pressing ESC will result in the Segmentation Fault. Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

    Is there any problem in my code or could there be an problem with the bgfx rust bindings itself?

    opened by const-volatile 5
  • Adding casts to allow c_char being u8

    Adding casts to allow c_char being u8

    On certain platforms std::os::raw::c_charwill equal to u8 instead of i8 leading to compilation errors in bgfx-rs/src/static_lib.rs. i.e. compiling for

    • aarch64
    • arm
    • powerpc
    • powerpc64

    https://github.com/rust-lang/rust/blob/3af60f831f75ae2632bbfd4c1aa66049ec2d486a/src/libstd/os/raw.rs#L15-L28

    Compilation output before the proposed changes:

       Compiling bgfx-rs v0.9.0
    error[E0308]: mismatched types
        --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/bgfx-rs-0.9.0/src/static_lib.rs:2230:61
         |
    2230 |             bgfx_sys::bgfx_request_screen_shot(self.handle, file_path);
         |                                                             ^^^^^^^^^ expected `u8`, found `i8`
         |
         = note: expected raw pointer `*const u8`
                      found reference `&i8`
    
    error[E0308]: mismatched types
        --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/bgfx-rs-0.9.0/src/static_lib.rs:3187:54
         |
    3187 |             bgfx_sys::bgfx_encoder_set_marker(_self, marker);
         |                                                      ^^^^^^ expected `u8`, found `i8`
         |
         = note: expected raw pointer `*const u8`
                      found reference `&i8`
    
    error[E0308]: mismatched types
        --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/bgfx-rs-0.9.0/src/static_lib.rs:5088:59
         |
    5088 |         bgfx_sys::bgfx_request_screen_shot(handle.handle, file_path);
         |                                                           ^^^^^^^^^ expected `u8`, found `i8`
         |
         = note: expected raw pointer `*const u8`
                      found reference `&i8`
    
    error[E0308]: mismatched types
        --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/bgfx-rs-0.9.0/src/static_lib.rs:5117:35
         |
    5117 |         bgfx_sys::bgfx_set_marker(marker);
         |                                   ^^^^^^ expected `u8`, found `i8`
         |
         = note: expected raw pointer `*const u8`
                      found reference `&i8`
    
    

    After these changes compilation is successful (tested using armv7-linux-androideabi, aarch64-linux-android, i686-linux-android, x86_64-linux-android).

    opened by const-volatile 4
  • Linking with 'link.exe' failed: exit code: 1120 (Windows, both MSVC and GNU)

    Linking with 'link.exe' failed: exit code: 1120 (Windows, both MSVC and GNU)

    I am getting this error compiling on Windows in debug:

    libbgfx_sys-3a085ea111dd24ba.rlib(image.o) : error LNK2019: unresolved external symbol "bool __cdecl astc_codec::ASTCDecompressToRGBA(unsigned char const *,unsigned __int64,unsigned __int64,unsigned __int64,enum astc_codec::FootprintType,unsigned char *,unsigned __int64,unsigned __int64)" (?ASTCDecompressToRGBA@astc_codec@@YA_NPEBE_K11W4FootprintType@1@PEAE11@Z) referenced in function "void __cdecl bimg::imageDecodeToRgba8(struct bx::AllocatorI *,void *,void const *,unsigned int,unsigned int,unsigned int,enum bimg::TextureFormat::Enum)" (?imageDecodeToRgba8@bimg@@YAXPEAUAllocatorI@bx@@PEAXPEBXIIIW4Enum@TextureFormat@1@@Z)

    I am able to compile and run in with --release. I am using CLion, but the error also occurs when I try and build directly with Cargo. Steps I've taken to try and fix it:

    • Switching to the GNU toolchain, but it looks like the issue is in linking bimg and not in the Rust part of the program.
    • Updating my VC 2019 toolchain (MSVC 14.29.30133).
    • Updating to the VC 2022 toolchain (MSVC 14.24.31933).
    opened by dillionnason 3
  • Unable to compile on MacOS 12.0.1 M1 Max

    Unable to compile on MacOS 12.0.1 M1 Max

    Hi, I'm unable to build this crate on my MacOS setup. I attached the logs below but I believe it has to do with this issue: bx/include/bx/bx.h:34:2: error: unknown type name 'constexpr'. It seems like on MacOS you may need to specify support for c++11 -std=c++11.

    warning:                                                              ^
    warning: bgfx/include/bgfx/bgfx.h:20:29: note: expanded from macro 'BGFX_INVALID_HANDLE'
    warning: #define BGFX_INVALID_HANDLE { bgfx::kInvalidHandle }
    warning:                             ^
    warning: bgfx/include/bgfx/bgfx.h:1329:41: error: expected expression
    warning:                         , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE
    warning:                                                              ^
    warning: bgfx/include/bgfx/bgfx.h:20:29: note: expanded from macro 'BGFX_INVALID_HANDLE'
    warning: #define BGFX_INVALID_HANDLE { bgfx::kInvalidHandle }
    warning:                             ^
    warning: bgfx/include/bgfx/bgfx.h:1969:32: error: expected expression
    warning:         bool init(const Init& _init = {});
    warning:                                       ^
    warning: 3 warnings and 20 errors generated.
    warning: bgfx/include/bgfx/bgfx.h:3718:40: error: expected expression
    warning:                 , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE
    warning:                                                      ^
    warning: bgfx/include/bgfx/bgfx.h:20:29: note: expanded from macro 'BGFX_INVALID_HANDLE'
    warning: #define BGFX_INVALID_HANDLE { bgfx::kInvalidHandle }
    warning:                             ^
    warning: bgfx/include/bgfx/bgfx.h:3749:40: error: expected expression
    warning:                 , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE
    warning:                                                      ^
    warning: bgfx/include/bgfx/bgfx.h:20:29: note: expanded from macro 'BGFX_INVALID_HANDLE'
    warning: #define BGFX_INVALID_HANDLE { bgfx::kInvalidHandle }
    warning:                             ^
    warning: bgfx/include/bgfx/bgfx.h:3780:40: error: expected expression
    warning:                 , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE
    warning:                                                      ^
    warning: bgfx/include/bgfx/bgfx.h:20:29: note: expanded from macro 'BGFX_INVALID_HANDLE'
    warning: #define BGFX_INVALID_HANDLE { bgfx::kInvalidHandle }
    warning:                             ^
    warning: In file included from bgfx/src/shader.cpp:6:
    warning: In file included from bgfx/src/bgfx_p.h:23:
    warning: In file included from bgfx/src/config.h:9:
    warning: bx/include/bx/bx.h:34:2: error: unknown type name 'constexpr'
    warning:         constexpr int32_t kExitSuccess = 0;
    warning:         ^
    warning: bx/include/bx/bx.h:34:19: error: expected ';' after top level declarator
    warning:         constexpr int32_t kExitSuccess = 0;
    warning:                          ^
    warning:                          ;
    warning: bx/include/bx/bx.h:35:2: error: unknown type name 'constexpr'
    warning:         constexpr int32_t kExitFailure = 1;
    warning:         ^
    warning: bx/include/bx/bx.h:35:19: error: expected ';' after top level declarator
    warning:         constexpr int32_t kExitFailure = 1;
    warning:                          ^
    warning:                          ;
    warning: bx/include/bx/bx.h:39:2: error: unknown type name 'constexpr'
    warning:         constexpr bool isTriviallyCopyable();
    warning:         ^
    warning: bx/include/bx/bx.h:54:2: error: unknown type name 'constexpr'
    warning:         constexpr Ty min(const Ty& _a, const Ty& _b);
    warning:         ^
    warning: bx/include/bx/bx.h:54:12: warning: variable templates are a C++14 extension [-Wc++14-extensions]
    warning:         constexpr Ty min(const Ty& _a, const Ty& _b);
    warning:                   ^
    warning: bx/include/bx/bx.h:54:14: error: expected ';' at end of declaration
    warning:         constexpr Ty min(const Ty& _a, const Ty& _b);
    warning:                     ^
    warning:                     ;
    warning: bx/include/bx/bx.h:54:25: error: unknown type name 'Ty'
    warning:         constexpr Ty min(const Ty& _a, const Ty& _b);
    warning:                                ^
    warning: bx/include/bx/bx.h:54:39: error: unknown type name 'Ty'
    warning:         constexpr Ty min(const Ty& _a, const Ty& _b);
    warning:                                              ^
    warning: bx/include/bx/bx.h:54:15: error: C++ requires a type specifier for all declarations
    warning:         constexpr Ty min(const Ty& _a, const Ty& _b);
    warning:                      ^
    warning: bx/include/bx/bx.h:58:2: error: unknown type name 'constexpr'
    warning:         constexpr Ty max(const Ty& _a, const Ty& _b);
    warning:         ^
    warning: bx/include/bx/bx.h:58:12: warning: variable templates are a C++14 extension [-Wc++14-extensions]
    warning:         constexpr Ty max(const Ty& _a, const Ty& _b);
    warning:                   ^
    warning: fatal error: too many errors emitted, stopping now [-ferror-limit=]
    warning: 3 warnings and 20 errors generated.
    warning: 3 warnings and 20 errors generated.
    warning: 3 warnings and 20 errors generated.
    warning: 3 warnings and 20 errors generated.
    
    error: failed to run custom build command for `bgfx-sys v0.4.0`
    
    Caused by:
      process didn't exit successfully: `/Users/tino/Workspace/game/target/release/build/bgfx-sys-d765467cb1cd2222/build-script-build` (exit status: 1)
      --- stdout
      TARGET = Some("aarch64-apple-darwin")
      OPT_LEVEL = Some("3")
      HOST = Some("aarch64-apple-darwin")
      CC_aarch64-apple-darwin = None
      CC_aarch64_apple_darwin = None
      HOST_CC = None
      CC = None
      CFLAGS_aarch64-apple-darwin = None
      CFLAGS_aarch64_apple_darwin = None
      HOST_CFLAGS = None
      CFLAGS = None
      CRATE_CC_NO_DEFAULTS = None
      DEBUG = Some("false")
      CARGO_CFG_TARGET_FEATURE = None
      running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-I" "bx/include/compat/osx" "-I" "bgfx/3rdparty/khronos" "-I" "bgfx/3rdparty" "-I" "bgfx/include" "-I" "bx/include" "-I" "bx/3rdparty" "-I" "bimg/include" "-I" "bimg/3rdparty" "-I" "bimg/3rdparty/iqa/include" "-I" "bimg/3rdparty/astc-codec/include" "-I" "bimg/3rdparty/tinyexr/deps/miniz" "-Wall" "-Wextra" "-DBGFX_CONFIG_RENDERER_WEBGPU=0" "-DBGFX_CONFIG_RENDERER_GNM=0" "-DBIMG_DECODE_ASTC=0" "-DBGFX_CONFIG_RENDERER_VULKAN=0" "-DBGFX_CONFIG_RENDERER_METAL=1" "-o" "/Users/tino/Workspace/game/target/release/build/bgfx-sys-675d35d16d980e93/out/bx/src/amalgamated.o" "-c" "bx/src/amalgamated.cpp"
      running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-I" "bx/include/compat/osx" "-I" "bgfx/3rdparty/khronos" "-I" "bgfx/3rdparty" "-I" "bgfx/include" "-I" "bx/include" "-I" "bx/3rdparty" "-I" "bimg/include" "-I" "bimg/3rdparty" "-I" "bimg/3rdparty/iqa/include" "-I" "bimg/3rdparty/astc-codec/include" "-I" "bimg/3rdparty/tinyexr/deps/miniz" "-Wall" "-Wextra" "-DBGFX_CONFIG_RENDERER_WEBGPU=0" "-DBGFX_CONFIG_RENDERER_GNM=0" "-DBIMG_DECODE_ASTC=0" "-DBGFX_CONFIG_RENDERER_VULKAN=0" "-DBGFX_CONFIG_RENDERER_METAL=1" "-o" "/Users/tino/Workspace/game/target/release/build/bgfx-sys-675d35d16d980e93/out/bgfx/src/topology.o" "-c" "bgfx/src/topology.cpp"
      running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-I" "bx/include/compat/osx" "-I" "bgfx/3rdparty/khronos" "-I" "bgfx/3rdparty" "-I" "bgfx/include" "-I" "bx/include" "-I" "bx/3rdparty" "-I" "bimg/include" "-I" "bimg/3rdparty" "-I" "bimg/3rdparty/iqa/include" "-I" "bimg/3rdparty/astc-codec/include" "-I" "bimg/3rdparty/tinyexr/deps/miniz" "-Wall" "-Wextra" "-DBGFX_CONFIG_RENDERER_WEBGPU=0" "-DBGFX_CONFIG_RENDERER_GNM=0" "-DBIMG_DECODE_ASTC=0" "-DBGFX_CONFIG_RENDERER_VULKAN=0" "-DBGFX_CONFIG_RENDERER_METAL=1" "-o" "/Users/tino/Workspace/game/target/release/build/bgfx-sys-675d35d16d980e93/out/bgfx/src/bgfx.o" "-c" "bgfx/src/bgfx.cpp"
      running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-I" "bx/include/compat/osx" "-I" "bgfx/3rdparty/khronos" "-I" "bgfx/3rdparty" "-I" "bgfx/include" "-I" "bx/include" "-I" "bx/3rdparty" "-I" "bimg/include" "-I" "bimg/3rdparty" "-I" "bimg/3rdparty/iqa/include" "-I" "bimg/3rdparty/astc-codec/include" "-I" "bimg/3rdparty/tinyexr/deps/miniz" "-Wall" "-Wextra" "-DBGFX_CONFIG_RENDERER_WEBGPU=0" "-DBGFX_CONFIG_RENDERER_GNM=0" "-DBIMG_DECODE_ASTC=0" "-DBGFX_CONFIG_RENDERER_VULKAN=0" "-DBGFX_CONFIG_RENDERER_METAL=1" "-o" "/Users/tino/Workspace/game/target/release/build/bgfx-sys-675d35d16d980e93/out/bimg/src/image_decode.o" "-c" "bimg/src/image_decode.cpp"
      running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-I" "bx/include/compat/osx" "-I" "bgfx/3rdparty/khronos" "-I" "bgfx/3rdparty" "-I" "bgfx/include" "-I" "bx/include" "-I" "bx/3rdparty" "-I" "bimg/include" "-I" "bimg/3rdparty" "-I" "bimg/3rdparty/iqa/include" "-I" "bimg/3rdparty/astc-codec/include" "-I" "bimg/3rdparty/tinyexr/deps/miniz" "-Wall" "-Wextra" "-DBGFX_CONFIG_RENDERER_WEBGPU=0" "-DBGFX_CONFIG_RENDERER_GNM=0" "-DBIMG_DECODE_ASTC=0" "-DBGFX_CONFIG_RENDERER_VULKAN=0" "-DBGFX_CONFIG_RENDERER_METAL=1" "-o" "/Users/tino/Workspace/game/target/release/build/bgfx-sys-675d35d16d980e93/out/bimg/src/image_gnf.o" "-c" "bimg/src/image_gnf.cpp"
      running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-I" "bx/include/compat/osx" "-I" "bgfx/3rdparty/khronos" "-I" "bgfx/3rdparty" "-I" "bgfx/include" "-I" "bx/include" "-I" "bx/3rdparty" "-I" "bimg/include" "-I" "bimg/3rdparty" "-I" "bimg/3rdparty/iqa/include" "-I" "bimg/3rdparty/astc-codec/include" "-I" "bimg/3rdparty/tinyexr/deps/miniz" "-Wall" "-Wextra" "-DBGFX_CONFIG_RENDERER_WEBGPU=0" "-DBGFX_CONFIG_RENDERER_GNM=0" "-DBIMG_DECODE_ASTC=0" "-DBGFX_CONFIG_RENDERER_VULKAN=0" "-DBGFX_CONFIG_RENDERER_METAL=1" "-o" "/Users/tino/Workspace/game/target/release/build/bgfx-sys-675d35d16d980e93/out/bgfx/src/debug_renderdoc.o" "-c" "bgfx/src/debug_renderdoc.cpp"
      running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-I" "bx/include/compat/osx" "-I" "bgfx/3rdparty/khronos" "-I" "bgfx/3rdparty" "-I" "bgfx/include" "-I" "bx/include" "-I" "bx/3rdparty" "-I" "bimg/include" "-I" "bimg/3rdparty" "-I" "bimg/3rdparty/iqa/include" "-I" "bimg/3rdparty/astc-codec/include" "-I" "bimg/3rdparty/tinyexr/deps/miniz" "-Wall" "-Wextra" "-DBGFX_CONFIG_RENDERER_WEBGPU=0" "-DBGFX_CONFIG_RENDERER_GNM=0" "-DBIMG_DECODE_ASTC=0" "-DBGFX_CONFIG_RENDERER_VULKAN=0" "-DBGFX_CONFIG_RENDERER_METAL=1" "-o" "/Users/tino/Workspace/game/target/release/build/bgfx-sys-675d35d16d980e93/out/bimg/src/image_cubemap_filter.o" "-c" "bimg/src/image_cubemap_filter.cpp"
      running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-I" "bx/include/compat/osx" "-I" "bgfx/3rdparty/khronos" "-I" "bgfx/3rdparty" "-I" "bgfx/include" "-I" "bx/include" "-I" "bx/3rdparty" "-I" "bimg/include" "-I" "bimg/3rdparty" "-I" "bimg/3rdparty/iqa/include" "-I" "bimg/3rdparty/astc-codec/include" "-I" "bimg/3rdparty/tinyexr/deps/miniz" "-Wall" "-Wextra" "-DBGFX_CONFIG_RENDERER_WEBGPU=0" "-DBGFX_CONFIG_RENDERER_GNM=0" "-DBIMG_DECODE_ASTC=0" "-DBGFX_CONFIG_RENDERER_VULKAN=0" "-DBGFX_CONFIG_RENDERER_METAL=1" "-o" "/Users/tino/Workspace/game/target/release/build/bgfx-sys-675d35d16d980e93/out/bimg/src/image.o" "-c" "bimg/src/image.cpp"
      running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-I" "bx/include/compat/osx" "-I" "bgfx/3rdparty/khronos" "-I" "bgfx/3rdparty" "-I" "bgfx/include" "-I" "bx/include" "-I" "bx/3rdparty" "-I" "bimg/include" "-I" "bimg/3rdparty" "-I" "bimg/3rdparty/iqa/include" "-I" "bimg/3rdparty/astc-codec/include" "-I" "bimg/3rdparty/tinyexr/deps/miniz" "-Wall" "-Wextra" "-DBGFX_CONFIG_RENDERER_WEBGPU=0" "-DBGFX_CONFIG_RENDERER_GNM=0" "-DBIMG_DECODE_ASTC=0" "-DBGFX_CONFIG_RENDERER_VULKAN=0" "-DBGFX_CONFIG_RENDERER_METAL=1" "-o" "/Users/tino/Workspace/game/target/release/build/bgfx-sys-675d35d16d980e93/out/bgfx/src/vertexlayout.o" "-c" "bgfx/src/vertexlayout.cpp"
     
      --- stderr
    
      error occurred: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-I" "bx/include/compat/osx" "-I" "bgfx/3rdparty/khronos" "-I" "bgfx/3rdparty" "-I" "bgfx/include" "-I" "bx/include" "-I" "bx/3rdparty" "-I" "bimg/include" "-I" "bimg/3rdparty" "-I" "bimg/3rdparty/iqa/include" "-I" "bimg/3rdparty/astc-codec/include" "-I" "bimg/3rdparty/tinyexr/deps/miniz" "-Wall" "-Wextra" "-DBGFX_CONFIG_RENDERER_WEBGPU=0" "-DBGFX_CONFIG_RENDERER_GNM=0" "-DBIMG_DECODE_ASTC=0" "-DBGFX_CONFIG_RENDERER_VULKAN=0" "-DBGFX_CONFIG_RENDERER_METAL=1" "-o" "/Users/tino/Workspace/game/target/release/build/bgfx-sys-675d35d16d980e93/out/bx/src/amalgamated.o" "-c" "bx/src/amalgamated.cpp" with args "cc" did not execute successfully (status code exit status: 1).
    
    opened by tcaer 3
  • Missing macros

    Missing macros

    It seems like macros like BGFX_STATE_BLEND_FUNC are missing in both bgfx_sys and bgfx_rs while being mentioned in the documentation at StateBlendFlags e.g.

    bgfx-rs = "0.13"
    bgfx-sys = "0.9.0"
    
    opened by NoFr1ends 2
  • Caps::limits should be CapsLimits, but is currently Limits

    Caps::limits should be CapsLimits, but is currently Limits

    bgfx documentation for the Limits structure does not match the definition in https://github.com/emoon/bgfx-rs/blob/49f8ea182bfec453393c8fa0658c49a158ecb297/src/static_lib.rs#L1640-L1649 Which is referenced in this struct returned from bgfx::get_caps() https://github.com/emoon/bgfx-rs/blob/49f8ea182bfec453393c8fa0658c49a158ecb297/src/static_lib.rs#L1552-L1596

    I think Caps::limits should be changed from Limits to CapsLimits, as the CapsLimits struct reflects what the documentation says bgfx::get_caps() should return.

    opened by nice-sprite 1
Owner
Daniel Collin
Demoscener in TBL. Does Rust at home and work at Unity Technologies.
Daniel Collin
A little cross-platform graphics engine written in rust.

Bismuth This is a version of my C++ graphics engine named Bismuth re-written with Rust. My goal is to learn more about the Rust language and make my g

Admiral サイタマ 1 Nov 1, 2021
A vector graphics renderer using OpenGL with a Rust & C API.

bufro A vector graphics renderer using OpenGL with a Rust & C API. A Rust example can be found in examples/quickstart.rs (using glutin). A C example c

Aspect 9 Dec 15, 2022
Kiss3d - Keep it simple, stupid 3d graphics engine for Rust.

Kiss3d - Keep it simple, stupid 3d graphics engine for Rust.

Sébastien Crozet 1.2k Dec 26, 2022
Generic framebuffer implementation in Rust for use with embedded-graphics library

Fraramebuffer implementation for Rust's Embedded-graphics Framebuffer approach helps to deal with display flickering when you update multiple parts of

Bernard Kobos 9 Nov 29, 2022
A 2D vector graphics library optimized for GUIs, written in Rust and wgpu

RootVG A 2D vector graphics library optimized for GUIs, written in Rust and wgpu How it Works Unlike other 2D vector graphics libraries which have a s

Meadowlark 14 Jul 10, 2024
wgpugd: A WebGPU Graphics Device for R

wgpugd: A WebGPU Graphics Device for R Overview What is WebGPU? WebGPU is an API that exposes the capabilities of GPU hardware. What is wgpu? As the n

Hiroaki Yutani 42 Dec 11, 2022
Graphite is a digital content creation software package for 2D graphics

Powerful 2D vector and raster editing. Procedural and nondestructive. Graphite is a digital content creation software package for 2D graphics, merging

Graphite 2.1k Jan 9, 2023
Cross Platform Rust (crust)

This repository is the code to support my crust series of blog posts on my main Github page which is all about getting an OpenGL renderer up and running using cross platform Rust code.

Marcel Braghetto 4 Aug 21, 2022
GLFW3 bindings and idiomatic wrapper for Rust.

glfw-rs GLFW bindings and wrapper for The Rust Programming Language. Example extern crate glfw; use glfw::{Action, Context, Key}; fn main() { le

PistonDevelopers 546 Jan 3, 2023
It is useful to put a 2D buffer/image on a window in a platform-independent way

Overview As the popularity of the library minifb shows, it is useful to put a 2D buffer/image on a window in a platform-independent way. Minifb's appr

David Johnson 81 Jan 5, 2023
A low-overhead Vulkan-like GPU API for Rust.

Getting Started | Documentation | Blog gfx-rs gfx-rs is a low-level, cross-platform graphics and compute abstraction library in Rust. It consists of t

Rust Graphics Mages 5.2k Jan 8, 2023
Safe and rich Rust wrapper around the Vulkan API

Vulkano See also vulkano.rs. Vulkano is a Rust wrapper around the Vulkan graphics API. It follows the Rust philosophy, which is that as long as you do

null 3.6k Jan 3, 2023
Graph API client writen in Rust

graph-rs Now available on stable Rust at crates.io graph-rs-sdk = "0.1.0" 0.1.0 and above use stable Rust. Anything before 0.1.0 uses nightly Rust. M

Sean Reeise 56 Jan 3, 2023
A toy ray tracer in Rust

tray_rust - A Toy Ray Tracer in Rust tray_rust is a toy physically based ray tracer built off of the techniques discussed in Physically Based Renderin

Will Usher 492 Dec 19, 2022
A complete harfbuzz's shaping algorithm port to Rust

rustybuzz rustybuzz is a complete harfbuzz's shaping algorithm port to Rust. Matches harfbuzz v2.7.0 Why? Because you can add rustybuzz = "*" to your

Evgeniy Reizner 310 Dec 22, 2022
An OpenGL function pointer loader for Rust

gl-rs Overview This repository contains the necessary building blocks for OpenGL wrapper libraries. For more information on each crate, see their resp

Brendan Zabarauskas 621 Dec 17, 2022
Safe OpenGL wrapper for the Rust language.

glium Note to current and future Glium users: Glium is no longer actively developed by its original author. That said, PRs are still welcome and maint

null 3.1k Jan 1, 2023
Graph data structure library for Rust.

petgraph Graph data structure library. Supports Rust 1.41 and later. Please read the API documentation here Crate feature flags: graphmap (default) en

null 2k Jan 9, 2023
A graph library for Rust.

Gamma A graph library for Rust. Gamma provides primitives and traversals for working with graphs. It is based on ideas presented in A Minimal Graph AP

Metamolecular, LLC 122 Dec 29, 2022