[−][src]Struct surfman::platform::unix::wayland::device::Device
A thread-local handle to a device.
Devices contain most of the relevant surface management methods.
Implementations
impl Device
[src]
pub fn create_context_descriptor(
&self,
attributes: &ContextAttributes
) -> Result<ContextDescriptor, Error>
[src]
&self,
attributes: &ContextAttributes
) -> Result<ContextDescriptor, Error>
Creates a context descriptor with the given attributes.
Context descriptors are local to this device.
pub fn create_context(
&mut self,
descriptor: &ContextDescriptor,
share_with: Option<&Context>
) -> Result<Context, Error>
[src]
&mut self,
descriptor: &ContextDescriptor,
share_with: Option<&Context>
) -> Result<Context, Error>
Creates a new OpenGL context.
The context initially has no surface attached. Until a surface is bound to it, rendering commands will fail or have no effect.
pub unsafe fn create_context_from_native_context(
&self,
native_context: NativeContext
) -> Result<Context, Error>
[src]
&self,
native_context: NativeContext
) -> Result<Context, Error>
Wraps an EGLContext
in a native context and returns it.
The context is not retained, as there is no way to do this in the EGL API. Therefore,
it is the caller's responsibility to ensure that the returned Context
object remains
alive as long as the EGLContext
is.
pub fn destroy_context(&self, context: &mut Context) -> Result<(), Error>
[src]
Destroys a context.
The context must have been created on this device.
pub fn native_context(&self, context: &Context) -> NativeContext
[src]
Given a context, returns its underlying EGL context and attached surfaces.
pub fn context_descriptor(&self, context: &Context) -> ContextDescriptor
[src]
Returns the descriptor that this context was created with.
pub fn make_context_current(&self, context: &Context) -> Result<(), Error>
[src]
Makes the context the current OpenGL context for this thread.
After calling this function, it is valid to use OpenGL rendering commands.
pub fn make_no_context_current(&self) -> Result<(), Error>
[src]
Removes the current OpenGL context from this thread.
After calling this function, OpenGL rendering commands will fail until a new context is made current.
pub fn context_descriptor_attributes(
&self,
context_descriptor: &ContextDescriptor
) -> ContextAttributes
[src]
&self,
context_descriptor: &ContextDescriptor
) -> ContextAttributes
Returns the attributes that the context descriptor was created with.
pub fn get_proc_address(&self, _: &Context, symbol_name: &str) -> *const c_void
[src]
Fetches the address of an OpenGL function associated with this context.
OpenGL functions are local to a context. You should not use OpenGL functions on one context with any other context.
This method is typically used with a function like gl::load_with()
from the gl
crate to
load OpenGL function pointers.
pub fn bind_surface_to_context(
&self,
context: &mut Context,
surface: Surface
) -> Result<(), (Error, Surface)>
[src]
&self,
context: &mut Context,
surface: Surface
) -> Result<(), (Error, Surface)>
Attaches a surface to a context for rendering.
This function takes ownership of the surface. The surface must have been created with this
context, or an IncompatibleSurface
error is returned.
If this function is called with a surface already bound, a SurfaceAlreadyBound
error is
returned. To avoid this error, first unbind the existing surface with
unbind_surface_from_context
.
If an error is returned, the surface is returned alongside it.
pub fn unbind_surface_from_context(
&self,
context: &mut Context
) -> Result<Option<Surface>, Error>
[src]
&self,
context: &mut Context
) -> Result<Option<Surface>, Error>
Removes and returns any attached surface from this context.
Any pending OpenGL commands targeting this surface will be automatically flushed, so the surface is safe to read from immediately when this function returns.
pub fn context_id(&self, context: &Context) -> ContextID
[src]
Returns a unique ID representing a context.
This ID is unique to all currently-allocated contexts. If you destroy a context and create a new one, the new context might have the same ID as the destroyed one.
pub fn context_surface_info(
&self,
context: &Context
) -> Result<Option<SurfaceInfo>, Error>
[src]
&self,
context: &Context
) -> Result<Option<SurfaceInfo>, Error>
Returns various information about the surface attached to a context.
This includes, most notably, the OpenGL framebuffer object needed to render to the surface.
impl Device
[src]
pub fn native_device(&self) -> NativeDevice
[src]
Returns the native device corresponding to this device.
This method is essentially an alias for the adapter()
method on Wayland, since there is
no explicit concept of a device on this backend.
pub fn connection(&self) -> Connection
[src]
Returns the display server connection that this device was created with.
pub fn adapter(&self) -> Adapter
[src]
Returns the adapter that this device was created with.
pub fn gl_api(&self) -> GLApi
[src]
Returns the OpenGL API flavor that this device supports (OpenGL or OpenGL ES).
impl Device
[src]
pub fn create_surface(
&mut self,
context: &Context,
_: SurfaceAccess,
surface_type: SurfaceType<NativeWidget>
) -> Result<Surface, Error>
[src]
&mut self,
context: &Context,
_: SurfaceAccess,
surface_type: SurfaceType<NativeWidget>
) -> Result<Surface, Error>
Creates either a generic or a widget surface, depending on the supplied surface type.
Only the given context may ever render to the surface, but generic surfaces can be wrapped
up in a SurfaceTexture
for reading by other contexts.
pub fn create_surface_texture(
&self,
context: &mut Context,
surface: Surface
) -> Result<SurfaceTexture, (Error, Surface)>
[src]
&self,
context: &mut Context,
surface: Surface
) -> Result<SurfaceTexture, (Error, Surface)>
Creates a surface texture from an existing generic surface for use with the given context.
The surface texture is local to the supplied context and takes ownership of the surface. Destroying the surface texture allows you to retrieve the surface again.
The supplied context does not have to be the same context that the surface is associated with. This allows you to render to a surface in one context and sample from that surface in another context.
Calling this method on a widget surface returns a WidgetAttached
error.
pub fn destroy_surface(
&self,
context: &mut Context,
surface: &mut Surface
) -> Result<(), Error>
[src]
&self,
context: &mut Context,
surface: &mut Surface
) -> Result<(), Error>
Destroys a surface.
The supplied context must be the context the surface is associated with, or this returns
an IncompatibleSurface
error.
You must explicitly call this method to dispose of a surface. Otherwise, a panic occurs in
the drop
method.
pub fn destroy_surface_texture(
&self,
context: &mut Context,
surface_texture: SurfaceTexture
) -> Result<Surface, (Error, SurfaceTexture)>
[src]
&self,
context: &mut Context,
surface_texture: SurfaceTexture
) -> Result<Surface, (Error, SurfaceTexture)>
Destroys a surface texture and returns the underlying surface.
The supplied context must be the same context the surface texture was created with, or an
IncompatibleSurfaceTexture
error is returned.
All surface textures must be explicitly destroyed with this function, or a panic will occur.
pub fn present_surface(
&self,
context: &Context,
surface: &mut Surface
) -> Result<(), Error>
[src]
&self,
context: &Context,
surface: &mut Surface
) -> Result<(), Error>
Displays the contents of a widget surface on screen.
Widget surfaces are internally double-buffered, so changes to them don't show up in their associated widgets until this method is called.
The supplied context must match the context the surface was created with, or an
IncompatibleSurface
error is returned.
pub fn resize_surface(
&self,
_context: &Context,
surface: &mut Surface,
size: Size2D<i32>
) -> Result<(), Error>
[src]
&self,
_context: &Context,
surface: &mut Surface,
size: Size2D<i32>
) -> Result<(), Error>
Resizes a widget surface.
pub fn lock_surface_data<'s>(
&self,
_: &'s mut Surface
) -> Result<SurfaceDataGuard<'s>, Error>
[src]
&self,
_: &'s mut Surface
) -> Result<SurfaceDataGuard<'s>, Error>
Returns a pointer to the underlying surface data for reading or writing by the CPU.
pub fn surface_gl_texture_target(&self) -> c_uint
[src]
Returns the OpenGL texture target needed to read from this surface texture.
This will be GL_TEXTURE_2D
or GL_TEXTURE_RECTANGLE
, depending on platform.
pub fn surface_info(&self, surface: &Surface) -> SurfaceInfo
[src]
Returns various information about the surface, including the framebuffer object needed to render to this surface.
Before rendering to a surface attached to a context, you must call glBindFramebuffer()
on the framebuffer object returned by this function. This framebuffer object may or not be
0, the default framebuffer, depending on platform.
pub fn surface_texture_object(&self, surface_texture: &SurfaceTexture) -> c_uint
[src]
Returns the OpenGL texture object containing the contents of this surface.
It is only legal to read from, not write to, this texture object.
Trait Implementations
impl Device for Device
[src]
type Connection = Connection
The connection type associated with this device.
type Context = Context
The context type associated with this device.
type ContextDescriptor = ContextDescriptor
The context descriptor type associated with this device.
type NativeContext = NativeContext
The native context type associated with this device.
type Surface = Surface
The surface type associated with this device.
type SurfaceTexture = SurfaceTexture
The surface texture type associated with this device.
fn native_device(
&self
) -> <Self::Connection as ConnectionInterface>::NativeDevice
[src]
&self
) -> <Self::Connection as ConnectionInterface>::NativeDevice
Returns the native device associated with this device.
fn connection(&self) -> Connection
[src]
fn adapter(&self) -> Adapter
[src]
fn gl_api(&self) -> GLApi
[src]
fn create_context_descriptor(
&self,
attributes: &ContextAttributes
) -> Result<Self::ContextDescriptor, Error>
[src]
&self,
attributes: &ContextAttributes
) -> Result<Self::ContextDescriptor, Error>
fn create_context(
&mut self,
descriptor: &Self::ContextDescriptor,
share_with: Option<&Self::Context>
) -> Result<Self::Context, Error>
[src]
&mut self,
descriptor: &Self::ContextDescriptor,
share_with: Option<&Self::Context>
) -> Result<Self::Context, Error>
unsafe fn create_context_from_native_context(
&self,
native_context: Self::NativeContext
) -> Result<Self::Context, Error>
[src]
&self,
native_context: Self::NativeContext
) -> Result<Self::Context, Error>
fn destroy_context(&self, context: &mut Self::Context) -> Result<(), Error>
[src]
fn context_descriptor(&self, context: &Self::Context) -> Self::ContextDescriptor
[src]
fn make_context_current(&self, context: &Self::Context) -> Result<(), Error>
[src]
fn make_no_context_current(&self) -> Result<(), Error>
[src]
fn context_descriptor_attributes(
&self,
context_descriptor: &Self::ContextDescriptor
) -> ContextAttributes
[src]
&self,
context_descriptor: &Self::ContextDescriptor
) -> ContextAttributes
fn get_proc_address(
&self,
context: &Self::Context,
symbol_name: &str
) -> *const c_void
[src]
&self,
context: &Self::Context,
symbol_name: &str
) -> *const c_void
fn bind_surface_to_context(
&self,
context: &mut Self::Context,
surface: Self::Surface
) -> Result<(), (Error, Self::Surface)>
[src]
&self,
context: &mut Self::Context,
surface: Self::Surface
) -> Result<(), (Error, Self::Surface)>
fn unbind_surface_from_context(
&self,
context: &mut Self::Context
) -> Result<Option<Self::Surface>, Error>
[src]
&self,
context: &mut Self::Context
) -> Result<Option<Self::Surface>, Error>
fn context_id(&self, context: &Self::Context) -> ContextID
[src]
fn context_surface_info(
&self,
context: &Self::Context
) -> Result<Option<SurfaceInfo>, Error>
[src]
&self,
context: &Self::Context
) -> Result<Option<SurfaceInfo>, Error>
fn native_context(&self, context: &Self::Context) -> Self::NativeContext
[src]
fn create_surface(
&mut self,
context: &Self::Context,
surface_access: SurfaceAccess,
surface_type: SurfaceType<NativeWidget>
) -> Result<Self::Surface, Error>
[src]
&mut self,
context: &Self::Context,
surface_access: SurfaceAccess,
surface_type: SurfaceType<NativeWidget>
) -> Result<Self::Surface, Error>
fn create_surface_texture(
&self,
context: &mut Self::Context,
surface: Self::Surface
) -> Result<Self::SurfaceTexture, (Error, Self::Surface)>
[src]
&self,
context: &mut Self::Context,
surface: Self::Surface
) -> Result<Self::SurfaceTexture, (Error, Self::Surface)>
fn destroy_surface(
&self,
context: &mut Self::Context,
surface: &mut Self::Surface
) -> Result<(), Error>
[src]
&self,
context: &mut Self::Context,
surface: &mut Self::Surface
) -> Result<(), Error>
fn destroy_surface_texture(
&self,
context: &mut Self::Context,
surface_texture: Self::SurfaceTexture
) -> Result<Self::Surface, (Error, Self::SurfaceTexture)>
[src]
&self,
context: &mut Self::Context,
surface_texture: Self::SurfaceTexture
) -> Result<Self::Surface, (Error, Self::SurfaceTexture)>
fn surface_gl_texture_target(&self) -> c_uint
[src]
fn present_surface(
&self,
context: &Self::Context,
surface: &mut Self::Surface
) -> Result<(), Error>
[src]
&self,
context: &Self::Context,
surface: &mut Self::Surface
) -> Result<(), Error>
fn resize_surface(
&self,
context: &Context,
surface: &mut Surface,
size: Size2D<i32>
) -> Result<(), Error>
[src]
&self,
context: &Context,
surface: &mut Surface,
size: Size2D<i32>
) -> Result<(), Error>
fn surface_info(&self, surface: &Self::Surface) -> SurfaceInfo
[src]
fn surface_texture_object(
&self,
surface_texture: &Self::SurfaceTexture
) -> c_uint
[src]
&self,
surface_texture: &Self::SurfaceTexture
) -> c_uint
Auto Trait Implementations
impl RefUnwindSafe for Device
impl !Send for Device
impl !Sync for Device
impl Unpin for Device
impl UnwindSafe for Device
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,