GithubHelp home page GithubHelp logo

Comments (9)

notgull avatar notgull commented on September 28, 2024

I originally suggested something like this in #94, although its usefulness would be limited since it can't really be used in hardware acceleration... although maybe it could be used in softbuffer?

The question then becomes "how do we get the RustConnection to fit into a RawDisplayHandle?" The only answer I can come up with that doesn't involve raw-window-handle taking on extra dependencies would be to have the variant contain an *const dyn Any that can explicitly be downcasted to an *const RustConnection. The disadvantage of this would be that, if the program uses multiple versions of x11rb, that there could be a version mismatch between the windowing system and the rendering framework, which would cause confusing bugs.

The way I would prefer, from a softbuffer standpoint, would be to just have another constructor on the Context type that takes an x11rb::RequestConnection to circumvent this entire issue.

from raw-window-handle.

notgull avatar notgull commented on September 28, 2024

Between this and #102, it makes me wonder if there is a niche in the ecosystem for a more opinionated window handle type. Maybe an enum between the "raw" window handle defined in this crate (maybe even the WindowHandle type to make it safer) and other more well-defined types?

from raw-window-handle.

notgull avatar notgull commented on September 28, 2024

My current stance is that this library should only expose the C window handles accepted by OpenGL and Vulkan. Other handles should be passed through other methods. Closing for now.

from raw-window-handle.

madsmtm avatar madsmtm commented on September 28, 2024

Somewhat related: In #134 we're doing exactly this, exposing a pure Rust handle, without a stable ABI.

So we could probably adapt the same solution to this.

from raw-window-handle.

notgull avatar notgull commented on September 28, 2024

I would argue that #134 is an extenuating circumstance, since there are no other good ways to pass your canvas object to the underlying graphics APIs. Even the data attribute hack can only accommodate types currently registered in the DOM. So our hand is forced into exposing wasm-bindgen, even in an unstable way.

My stance on pure Rust desktop handles is the same as above. The expense of keeping pointers to them is greater than the possible benefits of letting softbuffer draw to them. Unless Mesa allows for x11rb or wayland-rs handles to be passed to EGL, it's probably a bad idea to include them.

from raw-window-handle.

madsmtm avatar madsmtm commented on September 28, 2024

#134 is an extenuating circumstance

Yeah I probably exaggerated above, but I do think they share similarities, and that the solution we choose for wasm-bindgen could be adapted for x11rb/wayland-rs as well.

our hand is forced into exposing wasm-bindgen, even in an unstable way.

Well, we're never forced, we could also take the choice you've done for this issue, and just... Not support web handles at all, until they get a stable ABI that we can use. But nobody wants that, and so we take another route ;)

from raw-window-handle.

notgull avatar notgull commented on September 28, 2024

The core issue is that raw-window-handle exists mostly as a layer between the graphics APIs (glutin, wgpu) and the windowing system (winit, SDL, glfw). Which in turn mostly deals with C pointers. Unless you happen to have a friend on the OpenGL ARB it's going to be difficult to pass a wayland-rs pure Rust implementation to glutin or wgpu. So the main use-case is really only softbuffer.

On the other hand, the graphics APIs as they are currently exposed to Rust take wasm_bindgen::JsValue or wrappers around JsValue. Hence the exposure of JsValue.

It might be nice to have some kind of other, broader crate with a more expansive window handle type, for crates that don't wrap around graphics APIs. But for a lot of existing crates that use raw-window-handle, like winit, do not want to have x11rb as a public dependency.

from raw-window-handle.

madsmtm avatar madsmtm commented on September 28, 2024

Makes sense. I'll leave this open anyhow until we figure out #134, but will probably close it after that.

from raw-window-handle.

notgull avatar notgull commented on September 28, 2024

As of rust-windowing/softbuffer#171 softbuffer can create a context and run without a C connection.

This issue was discussed in our weekly winit maintainer's meeting and it was decided that it's out of scope for raw-window-handle, especially since it's possible to work with just the window ID's. Closing this as not planned.

from raw-window-handle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.