[][src]Struct web_glitz::runtime::Connection

pub struct Connection { /* fields omitted */ }

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]

type Output = ()

The type of output that results from this task finishing.

impl<T, D> GpuTask<Connection> for UploadCommand<[T], D> where
    D: Borrow<[T]>, 
[src]

type Output = ()

The type of output that results from this task finishing.

impl<D, T, F> GpuTask<Connection> for LevelUploadCommand<D, T, F> where
    D: Borrow<[T]>,
    T: PixelUnpack<F>,
    F: TextureFormat
[src]

type Output = ()

The type of output that results from this task finishing.

impl<D, T, F> GpuTask<Connection> for LevelLayerUploadCommand<D, T, F> where
    D: Borrow<[T]>,
    T: PixelUnpack<F>,
    F: TextureFormat
[src]

type Output = ()

The type of output that results from this task finishing.

impl GpuTask<Connection> for GenerateMipmapCommand[src]

type Output = ()

The type of output that results from this task finishing.

impl<D, T, F> GpuTask<Connection> for UploadCommand<D, T, F> where
    D: Borrow<[T]>,
    T: PixelUnpack<F>,
    F: TextureFormat
[src]

type Output = ()

The type of output that results from this task finishing.

impl GpuTask<Connection> for GenerateMipmapCommand[src]

type Output = ()

The type of output that results from this task finishing.

impl<T, O> GpuTask<Connection> for RenderPass<T> where
    T: GpuTask<RenderPassContext, Output = O>, 
[src]

type Output = O

The type of output that results from this task finishing.

impl<T> GpuTask<Connection> for DownloadCommand<T>[src]

type Output = Box<T>

The type of output that results from this task finishing.

impl<T> GpuTask<Connection> for DownloadCommand<[T]>[src]

type Output = Box<[T]>

The type of output that results from this task finishing.

impl<D, T, F> GpuTask<Connection> for UploadCommand<D, T, F> where
    D: Borrow<[T]>,
    T: PixelUnpack<F>,
    F: TextureFormat
[src]

type Output = ()

The type of output that results from this task finishing.

impl<F, P> GpuTask<Connection> for PackToBufferCommand<F, P> where
    F: TextureFormat,
    P: PixelPack<F>, 
[src]

type Output = ()

The type of output that results from this task finishing.

impl GpuTask<Connection> for GenerateMipmapCommand[src]

type Output = ()

The type of output that results from this task finishing.

impl<D, T, F> GpuTask<Connection> for LevelUploadCommand<D, T, F> where
    D: Borrow<[T]>,
    T: PixelUnpack<F>,
    F: TextureFormat
[src]

type Output = ()

The type of output that results from this task finishing.

impl<D, T, F> GpuTask<Connection> for LevelLayerUploadCommand<D, T, F> where
    D: Borrow<[T]>,
    T: PixelUnpack<F>,
    F: TextureFormat
[src]

type Output = ()

The type of output that results from this task finishing.

impl GpuTask<Connection> for GenerateMipmapCommand[src]

type Output = ()

The type of output that results from this task finishing.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<D, T> IntoBuffer<T> for D where
    D: Borrow<T> + 'static,
    T: Copy + 'static, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.