Crate bgfx [] [src]

Rust wrapper around bgfx.

Before using this crate, ensure that you fullfill the build requirements for bgfx, as outlined in its documentation. If you are compiling for an msvc target, make sure to build this crate in a developer command prompt.

Limitations

This API is still unstable, and very likely to change.

Basic Usage

Before this crate can be used, some platform data must be initialized. See PlatformData.

bgfx::PlatformData::new()
    .context(std::ptr::null_mut())
    .display(std::ptr::null_mut())
    .window(std::ptr::null_mut())
    .apply()
    .expect("Could not set platform data");

Once the platform data has been initialized, a new thread should be spawned to act as the main thread. This thread should call bgfx::init to initialize bgfx. The object returned by that function should be used to access bgfx API calls.

std::thread::spawn(|| {
    let bgfx = bgfx::init(bgfx::RendererType::Default, None, None)
        .expect("Failed to initialize bgfx");
    // ...
});

Finally, the real main thread should act as the render thread, and repeatedly be calling bgfx::render_frame.

loop {
    // This is probably also where you will want to pump the window event queue.
    bgfx::render_frame();
}

See the examples for more in-depth usage.

Reexports

pub use flags::*;

Modules

flags

Structs

Bgfx

Acts as the library wrapper for bgfx. Any calls intended to be run on the main thread are exposed as functions on this object.

IndexBuffer

Vertex index buffer.

Memory

bgfx-managed buffer of memory.

PlatformData

Platform data initializer.

Program

Shader program.

Shader

Shader.

VertexBuffer

Vertex data buffer.

VertexDecl

Describes the structure of a vertex.

VertexDeclBuilder

Builder for VertexDecl instances.

Enums

Attrib

Vertex attribute.

AttribType

Vertex attribute type.

BgfxError

bgfx error.

RenderFrame

render_frame() results.

RendererType

Renderer backend type.

Constants

PCI_ID_AMD

AMD adapter.

PCI_ID_INTEL

Intel adapter.

PCI_ID_NONE

Autoselect adapter.

PCI_ID_NVIDIA

nVidia adapter.

PCI_ID_SOFTWARE_RASTERIZER

Software rasterizer.

Functions

init

Initializes bgfx.

render_frame

Pump the render thread.