⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Is Context needed for anything other than performance? #306

@madsmtm

Description

@madsmtm

I've read #37 and #64, and from my understanding, the split between Context and Surface is purely for performance, to allow sharing resources that are expensive to create.

Is that correct?

If so, then I feel it might make sense to add a convenience wrapper like:

impl<W: HasDisplayHandle + HasWindowHandle> Surface<W, W> {
    pub fn new_single_window_bikeshed(window: W) -> Result<Self, CreationError> {
        // Conceptual implementation, needs to be done differently in reality
        // since the window needs to only be stored in the surface.
        let context = Context::new(window);
        Self::new(&context, window)
    }
}

And perhaps change Surface to be something like struct Surface<D, W = D> (make the two type parameters default to be the same type).

This would simplify the common use-case of having a single window to be:

struct App {
    surface: softbuffer::Surface<winit::Window>,
    // + possibly an `Option` if you want to support Android too.
}

While still allowing the more complex multi-window case:

struct App {
    context: softbuffer::Context<winit::OwnedDisplayHandle>,
    surfaces: Vec<softbuffer::Surface<winit::OwnedDisplayHandle, winit::Window>>,
}

See relatedly #298.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions