-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How should users interface with graphics libraries on macOS/iOS? #14
Comments
cc @mtak-. You've got experience with iOS - what's your take on this? |
There are two paths that hal uses on iOS for the
I strongly recommend the first option, and I personally think hal should panic if the layer isn't a |
I think it makes sense for iOS and macOS to have a pointer to the |
Could we rename the topic towards sth like: Current interfaces: pub struct MacOSHandle {
pub ns_window: *mut c_void,
pub ns_view: *mut c_void,
}
pub struct IOSHandle {
pub ui_window: *mut c_void,
pub ui_view: *mut c_void,
pub ui_view_controller: *mut c_void,
} The graphics APIs (Metal and Vulkan Portability) expect a At the end of the day I guess it boils down which side (window <-> graphics api) has to do potential conversion steps. |
So when trying to implement this for beryllium yesterday (SDL2 based lib) I was able to get an NS_Window from SDL2 but it doesn't give an NS_View. Is this field required? Seems like no, because the mac folks told me you can always get a view from the window pointer. Should we change the Mac handle to be an Option<NonNull<c_void>> with the None version more clearly meaning "get the default yourself" and the Some version being "use this specific sub-view here". |
@Lokathor There are some fields on other platforms with similar-ish semantics (e.g. /// It is entirely valid behavior for fields within each platform-specific `RawWindowHandle` variant
/// to be `null` or `0`, and appropriate checking should be done before the handle is used. However,
/// users can safely assume that non-`null`/`0` fields are valid handles, and it is up to the
/// implementor of this trait to ensure that condition is upheld.
///
+/// Still, implementors should make a best-effort attempt to fill in all available fields. If an
+/// implementation doesn't, and a downstream user needs the field, it should try to derive the
+/// field from other fields the implementor *does* provide via whatever methods the platform
+/// provides.
+///
/// The exact handle returned by `raw_window_handle` must not change during the lifetime of this
/// trait's implementor.
pub unsafe trait HasRawWindowHandle {
fn raw_window_handle(&self) -> RawWindowHandle;
} |
If I'm understanding this right, this will be fixed by #129 |
#129 is merged so this issue should now be fixed. |
Say I create the iOS struct, pass in pointers to
UIView
alone, without the rest - because technically they would be unnecessary and unused.How would
gfx-hal
know wether or not they need to setup things for Metal vs theUView
containing aCAMetalLayer
and etc?To clarify, there is no indication mentioned whether or not the related graphics stuff has been setup before hand (e.g using SDL2 to set everything up) vs expecting
gfx-hal
to create the necessary contexts andCAMetalLayer
?The text was updated successfully, but these errors were encountered: