ke
khronos-egl
cargo install khronos-egl
ke

khronos-egl

Rust bindings for the Khronos EGL API

by Timothée Haudebourg

2.2.0 (see all)License:MIT/Apache-2.0
cargo install khronos-egl
Readme

Rust bindings for EGL

Documentation

Crate informations

Repository

This crate provides a binding for the Khronos EGL 1.5 API. It was originally a clone of the egl crate, which is left unmaintained.

Usage

Here is a simple example showing how to use this library to create an EGL context.

extern crate khronos_egl as egl;

fn create_context(display: egl::Display) -> Result<egl::Context, egl::Error> {
    let attributes = [
        egl::RED_SIZE, 8,
        egl::GREEN_SIZE, 8,
        egl::BLUE_SIZE, 8,
        egl::NONE
    ];

    let config = egl::choose_first_config(display, &attributes)?.expect("unable to find an appropriate ELG configuration");

    let context_attributes = [
        egl::CONTEXT_MAJOR_VERSION, 4,
        egl::CONTEXT_MINOR_VERSION, 0,
        egl::CONTEXT_OPENGL_PROFILE_MASK, egl::CONTEXT_OPENGL_CORE_PROFILE_BIT,
        egl::NONE
    ];

    egl::create_context(display, config, None, &context_attributes)
}

The creation of a Display instance is not detailed here since it depends on your display server. It is created using the get_display function with a pointer to the display server connection handle. For instance, if you are using the wayland-client crate, you can get this pointer using the Display::get_display_ptr method.

NixOS

A shell.nix file is present for nix users to build the crate easily. Just enter a new nix shell using the given configuration file, and cargo build should work. If you want to run the tests and examples you will need to use shell-wayland.nix instead that will also load wayland since most of them depend on it.

Troubleshooting

Linking with OpenGL ES

When using OpenGL ES with rust-egl, it is necessary to place a dummy extern at the top of your application which links libEGL first, then GLESv1/2. This is because libEGL provides symbols required by GLESv1/2. Here's how to work around this:

#[link(name = "EGL")]
#[link(name = "GLESv2)]
extern {}

License

Licensed under either of

at your option.

If the original egl crate was licensed only under the Apache 2.0 license, I believe I have made enough breaking changes so that no relevant code from the original code remains and the rest can be relicensed.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

GitHub Stars

10

LAST COMMIT

1yr ago

MAINTAINERS

1

CONTRIBUTORS

10

OPEN ISSUES

1

OPEN PRs

0
VersionTagPublished
2.2.0
2yrs ago
2.1.1
2yrs ago
2.1.0
2yrs ago
2.0.0
2yrs ago
No alternatives found
No tutorials found
Add a tutorial