pub trait GlSurface<T: SurfaceTypeTrait>: Sealed {
type SurfaceType: SurfaceTypeTrait;
type Context: PossiblyCurrentGlContext;
// Required methods
fn buffer_age(&self) -> u32;
fn width(&self) -> Option<u32>;
fn height(&self) -> Option<u32>;
fn is_single_buffered(&self) -> bool;
fn swap_buffers(&self, context: &Self::Context) -> Result<()>;
fn is_current(&self, context: &Self::Context) -> bool;
fn is_current_draw(&self, context: &Self::Context) -> bool;
fn is_current_read(&self, context: &Self::Context) -> bool;
fn set_swap_interval(
&self,
context: &Self::Context,
interval: SwapInterval,
) -> Result<()>;
fn resize(
&self,
context: &Self::Context,
width: NonZeroU32,
height: NonZeroU32,
)
where Self::SurfaceType: ResizeableSurface;
}
Expand description
A trait to group common operations on the surface.
Required Associated Types§
Sourcetype SurfaceType: SurfaceTypeTrait
type SurfaceType: SurfaceTypeTrait
The type of the surface.
Sourcetype Context: PossiblyCurrentGlContext
type Context: PossiblyCurrentGlContext
The context to access surface data.
Required Methods§
Sourcefn buffer_age(&self) -> u32
fn buffer_age(&self) -> u32
The age of the back buffer of that surface. The 0
indicates that the
buffer is either a new one or we failed to get the information about
its age. In both cases you must redraw the entire buffer.
§Platform-specific
- Wayland: this call will latch the underlying back buffer, meaning
that all resize operations will apply after the next
GlSurface::swap_buffers
.
Sourcefn height(&self) -> Option<u32>
fn height(&self) -> Option<u32>
The physical height of the underlying surface.
§Platform specific
- macOS: this will block if your main thread is blocked.
Sourcefn is_single_buffered(&self) -> bool
fn is_single_buffered(&self) -> bool
Check whether the surface is single buffered.
§Platform specific
- macOS: this will block if your main thread is blocked.
Sourcefn swap_buffers(&self, context: &Self::Context) -> Result<()>
fn swap_buffers(&self, context: &Self::Context) -> Result<()>
Swaps the underlying back buffers when the surface is not single buffered.
Sourcefn is_current(&self, context: &Self::Context) -> bool
fn is_current(&self, context: &Self::Context) -> bool
Check whether the surface is current on to the current thread.
Sourcefn is_current_draw(&self, context: &Self::Context) -> bool
fn is_current_draw(&self, context: &Self::Context) -> bool
Check whether the surface is the current draw surface to the current thread.
Sourcefn is_current_read(&self, context: &Self::Context) -> bool
fn is_current_read(&self, context: &Self::Context) -> bool
Check whether the surface is the current read surface to the current thread.
Sourcefn set_swap_interval(
&self,
context: &Self::Context,
interval: SwapInterval,
) -> Result<()>
fn set_swap_interval( &self, context: &Self::Context, interval: SwapInterval, ) -> Result<()>
Set swap interval for the surface.
See crate::surface::SwapInterval
for details.
Sourcefn resize(&self, context: &Self::Context, width: NonZeroU32, height: NonZeroU32)where
Self::SurfaceType: ResizeableSurface,
fn resize(&self, context: &Self::Context, width: NonZeroU32, height: NonZeroU32)where
Self::SurfaceType: ResizeableSurface,
Resize the surface to a new size.
This call is for compatibility reasons, on most platforms it’s a no-op.
It’s recommended to call this function before doing any rendering and
performing PossiblyCurrentGlContext::make_current
, and
GlSurface::buffer_age
.
§Platform specific
- Wayland: resizes the surface;
- macOS: this will block if your main thread is blocked;
- Other: no op.