[−][src]Struct web_glitz::runtime::Connection
Encapsulates the raw [WebGl2RenderingContext] and its current state.
Can be unpacked into the raw [WebGl2RenderingContext] and its current state, see [unpack] and [unpack_mut].
Acts as the base execution context for GpuTasks that can be submitted to
RenderingContext::submit. You may create a custom GpuTask<Connection>, which will receive
a mutable reference to the current connection by the task executed associated with the context
(see GpuTask::progress). This is WebGlitz's primary escape hatch for dropping down to a bare
[WebGl2RenderingContext] for functionality that either is not supported by WebGlitz's or comes
with unacceptable overhead for your use-case.
Implementations
impl Connection[src]
pub unsafe fn new(context_id: u64, gl: Gl, state: DynamicState) -> Self[src]
Creates a new connection from a raw [WebGl2RenderingContext] and its current state for a
context with the given context_id.
The context_id should be unique (no other RenderingContext with that ID exists).
Unsafe
The state must accurately reflect the current state of the [WebGl2RenderingContext].
pub fn context_id(&self) -> u64[src]
The unique identifier for the RenderingContext with which this Connection is associated.
pub unsafe fn unpack(&self) -> (&Gl, &DynamicState)[src]
Unpacks the connection into a reference to the raw [WebGl2RenderingContext] and its DynamicState.
Unsafe
The [WebGl2RenderingContext]'s state must remain unchanged or must be restored to its prior state before progress can be made on another GpuTask (this typically means before your GpuTask::progress implementation returns).
pub unsafe fn unpack_mut(&mut self) -> (&mut Gl, &mut DynamicState)[src]
Unpacks the connection into a mutable reference to the raw [WebGl2RenderingContext] and its DynamicState.
Unsafe
If the [WebGl2RenderingContext]'s state is changed, then the state must also be updated
to accurately reflect that changed state, before progress can be made on another GpuTask
(this typically means before your GpuTask::progress implementation returns).
It is advisable to first update the state on the DynamicState. This will return a [ContextUpdate] which can then be applied to the [WebGl2RenderingContext]:
use web_glitz::runtime::state::ContextUpdate; unsafe { let (gl, state) = connection.unpack_mut(); let context_update = state.set_clear_color([0.0, 1.0, 0.0, 1.0]); context_update.apply(gl); }
Trait Implementations
impl<T, D> GpuTask<Connection> for UploadCommand<T, D> where
D: Borrow<T>, [src]
D: Borrow<T>,
type Output = ()
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
impl<T, D> GpuTask<Connection> for UploadCommand<[T], D> where
D: Borrow<[T]>, [src]
D: Borrow<[T]>,
type Output = ()
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
impl<D, T, F> GpuTask<Connection> for LevelUploadCommand<D, T, F> where
D: Borrow<[T]>,
T: PixelUnpack<F>,
F: TextureFormat, [src]
D: Borrow<[T]>,
T: PixelUnpack<F>,
F: TextureFormat,
type Output = ()
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
impl<D, T, F> GpuTask<Connection> for LevelLayerUploadCommand<D, T, F> where
D: Borrow<[T]>,
T: PixelUnpack<F>,
F: TextureFormat, [src]
D: Borrow<[T]>,
T: PixelUnpack<F>,
F: TextureFormat,
type Output = ()
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
impl GpuTask<Connection> for GenerateMipmapCommand[src]
type Output = ()
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
impl<D, T, F> GpuTask<Connection> for UploadCommand<D, T, F> where
D: Borrow<[T]>,
T: PixelUnpack<F>,
F: TextureFormat, [src]
D: Borrow<[T]>,
T: PixelUnpack<F>,
F: TextureFormat,
type Output = ()
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
impl GpuTask<Connection> for GenerateMipmapCommand[src]
type Output = ()
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
impl<T, O> GpuTask<Connection> for RenderPass<T> where
T: GpuTask<RenderPassContext, Output = O>, [src]
T: GpuTask<RenderPassContext, Output = O>,
type Output = O
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
impl<T> GpuTask<Connection> for DownloadCommand<T>[src]
type Output = Box<T>
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
impl<T> GpuTask<Connection> for DownloadCommand<[T]>[src]
type Output = Box<[T]>
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
impl<D, T, F> GpuTask<Connection> for UploadCommand<D, T, F> where
D: Borrow<[T]>,
T: PixelUnpack<F>,
F: TextureFormat, [src]
D: Borrow<[T]>,
T: PixelUnpack<F>,
F: TextureFormat,
type Output = ()
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
impl<F, P> GpuTask<Connection> for PackToBufferCommand<F, P> where
F: TextureFormat,
P: PixelPack<F>, [src]
F: TextureFormat,
P: PixelPack<F>,
type Output = ()
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, context: &mut Connection) -> Progress<Self::Output>[src]
impl GpuTask<Connection> for GenerateMipmapCommand[src]
type Output = ()
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
impl<D, T, F> GpuTask<Connection> for LevelUploadCommand<D, T, F> where
D: Borrow<[T]>,
T: PixelUnpack<F>,
F: TextureFormat, [src]
D: Borrow<[T]>,
T: PixelUnpack<F>,
F: TextureFormat,
type Output = ()
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
impl<D, T, F> GpuTask<Connection> for LevelLayerUploadCommand<D, T, F> where
D: Borrow<[T]>,
T: PixelUnpack<F>,
F: TextureFormat, [src]
D: Borrow<[T]>,
T: PixelUnpack<F>,
F: TextureFormat,
type Output = ()
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
impl GpuTask<Connection> for GenerateMipmapCommand[src]
type Output = ()
The type of output that results from this task finishing.
fn context_id(&self) -> ContextId[src]
fn progress(&mut self, connection: &mut Connection) -> Progress<Self::Output>[src]
Auto Trait Implementations
impl RefUnwindSafe for Connection
impl !Send for Connection
impl !Sync for Connection
impl Unpin for Connection
impl UnwindSafe for Connection
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<D, T> IntoBuffer<T> for D where
D: Borrow<T> + 'static,
T: Copy + 'static, [src]
D: Borrow<T> + 'static,
T: Copy + 'static,
fn into_buffer<Rc>(Self, &Rc, BufferId, UsageHint) -> Buffer<T> where
Rc: RenderingContext + Clone + 'static, [src]
Rc: RenderingContext + Clone + 'static,
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>,