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>
impl<T: EGL1_0> Instance<T>
sourcepub fn matching_config_count(
&self,
display: Display,
attrib_list: &[Int]
) -> Result<usize, Error>
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
).
sourcepub fn choose_config(
&self,
display: Display,
attrib_list: &[Int],
configs: &mut Vec<Config>
) -> Result<(), Error>
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
).
sourcepub fn choose_first_config(
&self,
display: Display,
attrib_list: &[Int]
) -> Result<Option<Config>, Error>
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();
sourcepub unsafe fn copy_buffers(
&self,
display: Display,
surface: Surface,
target: NativePixmapType
) -> Result<(), Error>
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
.
sourcepub fn create_context(
&self,
display: Display,
config: Config,
share_context: Option<Context>,
attrib_list: &[Int]
) -> Result<Context, Error>
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
).
sourcepub fn create_pbuffer_surface(
&self,
display: Display,
config: Config,
attrib_list: &[Int]
) -> Result<Surface, Error>
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
).
sourcepub unsafe fn create_pixmap_surface(
&self,
display: Display,
config: Config,
pixmap: NativePixmapType,
attrib_list: &[Int]
) -> Result<Surface, Error>
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.
sourcepub unsafe fn create_window_surface(
&self,
display: Display,
config: Config,
window: NativeWindowType,
attrib_list: Option<&[Int]>
) -> Result<Surface, Error>
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.
sourcepub fn destroy_context(
&self,
display: Display,
ctx: Context
) -> Result<(), Error>
pub fn destroy_context( &self, display: Display, ctx: Context ) -> Result<(), Error>
Destroy an EGL rendering context.
sourcepub fn destroy_surface(
&self,
display: Display,
surface: Surface
) -> Result<(), Error>
pub fn destroy_surface( &self, display: Display, surface: Surface ) -> Result<(), Error>
Destroy an EGL surface.
sourcepub fn get_config_attrib(
&self,
display: Display,
config: Config,
attribute: Int
) -> Result<Int, Error>
pub fn get_config_attrib( &self, display: Display, config: Config, attribute: Int ) -> Result<Int, Error>
Return information about an EGL frame buffer configuration.
sourcepub fn get_config_count(&self, display: Display) -> Result<usize, Error>
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);
sourcepub fn get_configs(
&self,
display: Display,
configs: &mut Vec<Config>
) -> Result<(), Error>
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);
sourcepub fn get_current_display(&self) -> Option<Display>
pub fn get_current_display(&self) -> Option<Display>
Return the display for the current EGL rendering context.
sourcepub fn get_current_surface(&self, readdraw: Int) -> Option<Surface>
pub fn get_current_surface(&self, readdraw: Int) -> Option<Surface>
Return the read or draw surface for the current EGL rendering context.
sourcepub unsafe fn get_display(
&self,
display_id: NativeDisplayType
) -> Option<Display>
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.
sourcepub fn get_error(&self) -> Option<Error>
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.
sourcepub fn get_proc_address(&self, procname: &str) -> Option<extern "system" fn()>
pub fn get_proc_address(&self, procname: &str) -> Option<extern "system" fn()>
Return a GL or an EGL extension function.
sourcepub fn initialize(&self, display: Display) -> Result<(Int, Int), Error>
pub fn initialize(&self, display: Display) -> Result<(Int, Int), Error>
Initialize an EGL display connection.
sourcepub fn make_current(
&self,
display: Display,
draw: Option<Surface>,
read: Option<Surface>,
ctx: Option<Context>
) -> Result<(), Error>
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.
sourcepub fn query_context(
&self,
display: Display,
ctx: Context,
attribute: Int
) -> Result<Int, Error>
pub fn query_context( &self, display: Display, ctx: Context, attribute: Int ) -> Result<Int, Error>
Return EGL rendering context information.
sourcepub fn query_string(
&self,
display: Option<Display>,
name: Int
) -> Result<&'static CStr, Error>
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.
sourcepub fn query_surface(
&self,
display: Display,
surface: Surface,
attribute: Int
) -> Result<Int, Error>
pub fn query_surface( &self, display: Display, surface: Surface, attribute: Int ) -> Result<Int, Error>
Return EGL surface information.
sourcepub fn swap_buffers(
&self,
display: Display,
surface: Surface
) -> Result<(), Error>
pub fn swap_buffers( &self, display: Display, surface: Surface ) -> Result<(), Error>
Post EGL surface color buffer to a native window.
sourcepub fn terminate(&self, display: Display) -> Result<(), Error>
pub fn terminate(&self, display: Display) -> Result<(), Error>
Terminate an EGL display connection.
source§impl<T: EGL1_1> Instance<T>
impl<T: EGL1_1> Instance<T>
sourcepub fn bind_tex_image(
&self,
display: Display,
surface: Surface,
buffer: Int
) -> Result<(), Error>
pub fn bind_tex_image( &self, display: Display, surface: Surface, buffer: Int ) -> Result<(), Error>
Defines a two-dimensional texture image.
sourcepub fn release_tex_image(
&self,
display: Display,
surface: Surface,
buffer: Int
) -> Result<(), Error>
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§impl<T: EGL1_2> Instance<T>
impl<T: EGL1_2> Instance<T>
sourcepub fn create_pbuffer_from_client_buffer(
&self,
display: Display,
buffer_type: Enum,
buffer: ClientBuffer,
config: Config,
attrib_list: &[Int]
) -> Result<Surface, Error>
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
).
sourcepub fn release_thread(&self) -> Result<(), Error>
pub fn release_thread(&self) -> Result<(), Error>
Release EGL per-thread state.
sourcepub fn wait_client(&self) -> Result<(), Error>
pub fn wait_client(&self) -> Result<(), Error>
Complete client API execution prior to subsequent native rendering calls.
source§impl<T: EGL1_4> Instance<T>
impl<T: EGL1_4> Instance<T>
sourcepub fn get_current_context(&self) -> Option<Context>
pub fn get_current_context(&self) -> Option<Context>
Return the current EGL rendering context.
source§impl<T: EGL1_5> Instance<T>
impl<T: EGL1_5> Instance<T>
sourcepub unsafe fn create_sync(
&self,
display: Display,
ty: Enum,
attrib_list: &[Attrib]
) -> Result<Sync, Error>
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.
sourcepub unsafe fn destroy_sync(
&self,
display: Display,
sync: Sync
) -> Result<(), Error>
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.
sourcepub unsafe fn client_wait_sync(
&self,
display: Display,
sync: Sync,
flags: Int,
timeout: Time
) -> Result<Int, Error>
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.
sourcepub unsafe fn get_sync_attrib(
&self,
display: Display,
sync: Sync,
attribute: Int
) -> Result<Attrib, Error>
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.
sourcepub fn create_image(
&self,
display: Display,
ctx: Context,
target: Enum,
buffer: ClientBuffer,
attrib_list: &[Attrib]
) -> Result<Image, Error>
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
).
sourcepub fn destroy_image(&self, display: Display, image: Image) -> Result<(), Error>
pub fn destroy_image(&self, display: Display, image: Image) -> Result<(), Error>
Destroy an Image object.
sourcepub unsafe fn get_platform_display(
&self,
platform: Enum,
native_display: NativeDisplayType,
attrib_list: &[Attrib]
) -> Result<Display, Error>
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.
sourcepub unsafe fn create_platform_window_surface(
&self,
display: Display,
config: Config,
native_window: NativeWindowType,
attrib_list: &[Attrib]
) -> Result<Surface, Error>
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.
sourcepub unsafe fn create_platform_pixmap_surface(
&self,
display: Display,
config: Config,
native_pixmap: NativePixmapType,
attrib_list: &[Attrib]
) -> Result<Surface, Error>
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.