Struct khronos_egl::Instance

source ·
pub struct Instance<T> { /* private fields */ }
Expand description

EGL API instance.

An instance wraps an interface to the EGL API and provide rust-friendly access to it.

Implementations§

source§

impl<T: EGL1_0> Instance<T>

source

pub fn matching_config_count( &self, display: Display, attrib_list: &[Int] ) -> Result<usize, Error>

Return the number of EGL frame buffer configurations that atch specified attributes.

This will call eglChooseConfig without null as configs to get the number of matching configurations.

This will return a BadParameter error if attrib_list is not a valid attributes list (if it does not terminate with NONE).

source

pub fn choose_config( &self, display: Display, attrib_list: &[Int], configs: &mut Vec<Config> ) -> Result<(), Error>

Return a list of EGL frame buffer configurations that match specified attributes.

This will write as many matching configurations in configs up to its capacity. You can use the function matching_config_count to get the exact number of configurations matching the specified attributes.

Example
// Get the number of matching configurations.
let count = egl.matching_config_count(display, &attrib_list)?;

// Get the matching configurations.
let mut configs = Vec::with_capacity(count);
egl.choose_config(display, &attrib_list, &mut configs)?;

This will return a BadParameter error if attrib_list is not a valid attributes list (if it does not terminate with NONE).

source

pub fn choose_first_config( &self, display: Display, attrib_list: &[Int] ) -> Result<Option<Config>, Error>

Return the first EGL frame buffer configuration that match specified attributes.

This is an helper function that will call choose_config with a buffer of size 1, which is equivalent to:

let mut configs = Vec::with_capacity(1);
egl.choose_config(display, &attrib_list, &mut configs)?;
configs.first();
source

pub unsafe fn copy_buffers( &self, display: Display, surface: Surface, target: NativePixmapType ) -> Result<(), Error>

Copy EGL surface color buffer to a native pixmap.

Safety

target must be a valid pointer to a native pixmap that belongs to the same platform as display and surface.

source

pub fn create_context( &self, display: Display, config: Config, share_context: Option<Context>, attrib_list: &[Int] ) -> Result<Context, Error>

Create a new EGL rendering context.

This will return a BadParameter error if attrib_list is not a valid attributes list (if it does not terminate with NONE).

source

pub fn create_pbuffer_surface( &self, display: Display, config: Config, attrib_list: &[Int] ) -> Result<Surface, Error>

Create a new EGL pixel buffer surface.

This will return a BadParameter error if attrib_list is not a valid attributes list (if it does not terminate with NONE).

source

pub unsafe fn create_pixmap_surface( &self, display: Display, config: Config, pixmap: NativePixmapType, attrib_list: &[Int] ) -> Result<Surface, Error>

Create a new EGL offscreen surface.

This will return a BadParameter error if attrib_list is not a valid attributes list (if it does not terminate with NONE).

Safety

This function may raise undefined behavior if the display and native pixmap do not belong to the same platform.

source

pub unsafe fn create_window_surface( &self, display: Display, config: Config, window: NativeWindowType, attrib_list: Option<&[Int]> ) -> Result<Surface, Error>

Create a new EGL window surface.

This will return a BadParameter error if attrib_list is not a valid attributes list (if it does not terminate with NONE).

Safety

This function may raise undefined behavior if the display and native window do not belong to the same platform.

source

pub fn destroy_context( &self, display: Display, ctx: Context ) -> Result<(), Error>

Destroy an EGL rendering context.

source

pub fn destroy_surface( &self, display: Display, surface: Surface ) -> Result<(), Error>

Destroy an EGL surface.

source

pub fn get_config_attrib( &self, display: Display, config: Config, attribute: Int ) -> Result<Int, Error>

Return information about an EGL frame buffer configuration.

source

pub fn get_config_count(&self, display: Display) -> Result<usize, Error>

Return the number of all frame buffer configurations.

You can use it to setup the correct capacity for the configurations buffer in get_configs.

Example
let mut configs = Vec::with_capacity(egl.get_config_count(display)?);
egl.get_configs(display, &mut configs);
assert!(configs.len() > 0);
source

pub fn get_configs( &self, display: Display, configs: &mut Vec<Config> ) -> Result<(), Error>

Get the list of all EGL frame buffer configurations for a display.

The configurations are added to the configs buffer, up to the buffer’s capacity. You can use get_config_count to get the total number of available frame buffer configurations, and setup the buffer’s capacity accordingly.

Example
let mut configs = Vec::with_capacity(egl.get_config_count(display)?);
egl.get_configs(display, &mut configs);
source

pub fn get_current_display(&self) -> Option<Display>

Return the display for the current EGL rendering context.

source

pub fn get_current_surface(&self, readdraw: Int) -> Option<Surface>

Return the read or draw surface for the current EGL rendering context.

source

pub unsafe fn get_display( &self, display_id: NativeDisplayType ) -> Option<Display>

Return an EGL display connection.

Safety

The native_display must be a valid pointer to the native display. Valid values for platform are defined by EGL extensions, as are requirements for native_display. For example, an extension specification that defines support for the X11 platform may require that native_display be a pointer to an X11 Display, and an extension specification that defines support for the Microsoft Windows platform may require that native_display be a pointer to a Windows Device Context.

source

pub fn get_error(&self) -> Option<Error>

Return error information.

Return the error of the last called EGL function in the current thread, or None if the error is set to SUCCESS.

Note that since a call to eglGetError sets the error to SUCCESS, and since this function is automatically called by any wrapper function returning a Result when necessary, this function may only return None from the point of view of a user.

source

pub fn get_proc_address(&self, procname: &str) -> Option<extern "system" fn()>

Return a GL or an EGL extension function.

source

pub fn initialize(&self, display: Display) -> Result<(Int, Int), Error>

Initialize an EGL display connection.

source

pub fn make_current( &self, display: Display, draw: Option<Surface>, read: Option<Surface>, ctx: Option<Context> ) -> Result<(), Error>

Attach an EGL rendering context to EGL surfaces.

source

pub fn query_context( &self, display: Display, ctx: Context, attribute: Int ) -> Result<Int, Error>

Return EGL rendering context information.

source

pub fn query_string( &self, display: Option<Display>, name: Int ) -> Result<&'static CStr, Error>

Return a string describing properties of the EGL client or of an EGL display connection.

source

pub fn query_surface( &self, display: Display, surface: Surface, attribute: Int ) -> Result<Int, Error>

Return EGL surface information.

source

pub fn swap_buffers( &self, display: Display, surface: Surface ) -> Result<(), Error>

Post EGL surface color buffer to a native window.

source

pub fn terminate(&self, display: Display) -> Result<(), Error>

Terminate an EGL display connection.

source

pub fn wait_gl(&self) -> Result<(), Error>

Complete GL execution prior to subsequent native rendering calls.

source

pub fn wait_native(&self, engine: Int) -> Result<(), Error>

Complete native execution prior to subsequent GL rendering calls.

source§

impl<T: EGL1_1> Instance<T>

source

pub fn bind_tex_image( &self, display: Display, surface: Surface, buffer: Int ) -> Result<(), Error>

Defines a two-dimensional texture image.

source

pub fn release_tex_image( &self, display: Display, surface: Surface, buffer: Int ) -> Result<(), Error>

Releases a color buffer that is being used as a texture.

source

pub fn surface_attrib( &self, display: Display, surface: Surface, attribute: Int, value: Int ) -> Result<(), Error>

Set an EGL surface attribute.

source

pub fn swap_interval( &self, display: Display, interval: Int ) -> Result<(), Error>

Specifies the minimum number of video frame periods per buffer swap for the window associated with the current context.

source§

impl<T: EGL1_2> Instance<T>

source

pub fn bind_api(&self, api: Enum) -> Result<(), Error>

Set the current rendering API.

source

pub fn query_api(&self) -> Enum

Query the current rendering API.

source

pub fn create_pbuffer_from_client_buffer( &self, display: Display, buffer_type: Enum, buffer: ClientBuffer, config: Config, attrib_list: &[Int] ) -> Result<Surface, Error>

Create a new EGL pixel buffer surface bound to an OpenVG image.

This will return a BadParameter error if attrib_list is not a valid attributes list (if it does not terminate with NONE).

source

pub fn release_thread(&self) -> Result<(), Error>

Release EGL per-thread state.

source

pub fn wait_client(&self) -> Result<(), Error>

Complete client API execution prior to subsequent native rendering calls.

source§

impl<T: EGL1_4> Instance<T>

source

pub fn get_current_context(&self) -> Option<Context>

Return the current EGL rendering context.

source§

impl<T: EGL1_5> Instance<T>

source

pub unsafe fn create_sync( &self, display: Display, ty: Enum, attrib_list: &[Attrib] ) -> Result<Sync, Error>

Create a new EGL sync object.

Note that the constant ATTRIB_NONE which has the type Attrib can be used instead of NONE to terminate the attribute list.

This will return a BadParameter error if attrib_list is not a valid attributes list (if it does not terminate with ATTRIB_NONE).

Safety

When creating an OpenCL Event Sync Object, passing an invalid event handle in attrib_list may result in undefined behavior up to and including program termination.

source

pub unsafe fn destroy_sync( &self, display: Display, sync: Sync ) -> Result<(), Error>

Destroy a sync object.

Safety

If display does not match the display passed to eglCreateSync when sync was created, the behaviour is undefined.

source

pub unsafe fn client_wait_sync( &self, display: Display, sync: Sync, flags: Int, timeout: Time ) -> Result<Int, Error>

Wait in the client for a sync object to be signalled.

Safety

If display does not match the Display passed to create_sync when sync was created, the behaviour is undefined.

source

pub unsafe fn get_sync_attrib( &self, display: Display, sync: Sync, attribute: Int ) -> Result<Attrib, Error>

Return an attribute of a sync object.

Safety

If display does not match the Display passed to create_sync when sync was created, behavior is undefined.

source

pub fn create_image( &self, display: Display, ctx: Context, target: Enum, buffer: ClientBuffer, attrib_list: &[Attrib] ) -> Result<Image, Error>

Create a new Image object.

Note that the constant ATTRIB_NONE which has the type Attrib can be used instead of NONE to terminate the attribute list.

This will return a BadParameter error if attrib_list is not a valid attributes list (if it does not terminate with ATTRIB_NONE).

source

pub fn destroy_image(&self, display: Display, image: Image) -> Result<(), Error>

Destroy an Image object.

source

pub unsafe fn get_platform_display( &self, platform: Enum, native_display: NativeDisplayType, attrib_list: &[Attrib] ) -> Result<Display, Error>

Return an EGL display connection.

Note that the constant ATTRIB_NONE which has the type Attrib can be used instead of NONE to terminate the attribute list.

This will return a BadParameter error if attrib_list is not a valid attributes list (if it does not terminate with ATTRIB_NONE).

Safety

The native_display must be a valid pointer to the native display. Valid values for platform are defined by EGL extensions, as are requirements for native_display. For example, an extension specification that defines support for the X11 platform may require that native_display be a pointer to an X11 Display, and an extension specification that defines support for the Microsoft Windows platform may require that native_display be a pointer to a Windows Device Context.

source

pub unsafe fn create_platform_window_surface( &self, display: Display, config: Config, native_window: NativeWindowType, attrib_list: &[Attrib] ) -> Result<Surface, Error>

Create a new EGL on-screen rendering surface.

Note that the constant ATTRIB_NONE which has the type Attrib can be used instead of NONE to terminate the attribute list.

This will return a BadParameter error if attrib_list is not a valid attributes list (if it does not terminate with ATTRIB_NONE).

Safety

The native_window must be a valid pointer to the native window and must belong to the same platform as display. EGL considers the returned EGLSurface as belonging to that same platform. The EGL extension that defines the platform to which display belongs also defines the requirements for the native_window parameter.

source

pub unsafe fn create_platform_pixmap_surface( &self, display: Display, config: Config, native_pixmap: NativePixmapType, attrib_list: &[Attrib] ) -> Result<Surface, Error>

Create a new EGL offscreen surface.

Note that the constant ATTRIB_NONE which has the type Attrib can be used instead of NONE to terminate the attribute list.

This will return a BadParameter error if attrib_list is not a valid attributes list (if it does not terminate with ATTRIB_NONE).

Safety

The native_pixmap must be a valid pointer to a native pixmap. and must belong to the same platform as display. EGL considers the returned EGLSurface as belonging to that same platform. The EGL extension that defines the platform to which display belongs also defines the requirements for the native_pixmap parameter.

source

pub fn wait_sync( &self, display: Display, sync: Sync, flags: Int ) -> Result<(), Error>

Wait in the server for a sync object to be signalled.

This function is unsafe: if display does not match the Display passed to create_sync when sync was created, the behavior is undefined.

source§

impl<T> Instance<T>

source

pub fn cast_into<U: From<T>>(self) -> Instance<U>

Cast the API.

source

pub fn try_cast_into<U: TryFrom<T>>( self ) -> Result<Instance<U>, Instance<U::Error>>

Try to cast the API.

source

pub fn version(&self) -> Version
where T: Api,

Returns the version of the provided EGL API.

source§

impl<T> Instance<T>

source

pub const fn new(api: T) -> Instance<T>

Trait Implementations§

source§

impl<T: Debug> Debug for Instance<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> From<T> for Instance<T>

source§

fn from(t: T) -> Instance<T>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Instance<T>
where T: RefUnwindSafe,

§

impl<T> Send for Instance<T>
where T: Send,

§

impl<T> Sync for Instance<T>
where T: Sync,

§

impl<T> Unpin for Instance<T>
where T: Unpin,

§

impl<T> UnwindSafe for Instance<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast<T> for T

source§

fn downcast(&self) -> &T

source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Upcast<T> for T

source§

fn upcast(&self) -> Option<&T>