-
Notifications
You must be signed in to change notification settings - Fork 50
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
Initial Window Size #106
Comments
Idea 1 sounds good to me, since an initial window size is also required by |
This should definitely be consistent across backends, if nothing else.
I don't believe that's possible on Wayland, no. Only the code that created the surface has this information.
This was discussed somewhat in #65, and I think it was generally agreed that panicking is a better way to handle programmer error than returning an error variant. So I think panicking consistently would be reasonable. Possibly if things were restructured a bit that could be handled in top level code instead of separately in each backend. But requiring passing an initial size would statically prevent errors, so that's better if it doesn't make the library too much harder to use. Good point about Wgpu requiring that. That makes it seem more reasonable. |
Doesn't the contract of I call |
Yeah, that was the original thought. |
Hmm, what's the point of making it unnecessary? "every frame starts with a Truth be told, I'd advocate for combining |
It's an improvement, I don't see why we should have an invalid state if it's avoidable (it's not clear to me yet if it can be avoided). I'm also really really not a big fan of panics in libraries, but I'm not sure who shares that opinion.
I'm not sure why we should require passing in a size when it's not required, it's up to you if you wanna do it that way but I wouldn't want to force it on everybody else. But it's a very good alternative solution. |
what do you mean "force"? is passing the size for each frame somehow a problem or inconvenience? don't you need those anyway in order to use the buffer properly? is there any use-case that would prevent someone from being able to pass the size? is it too expensive for (I'm just confused) |
It isn't. It's why I said this is a very good alternative. But it doesn't have a benefit either unless it's an alternative to passing the size at the start. I see the point of course that we could encourage users to always resize before drawing or fetching, but that's a completely different issue then whats being discussed here. |
I'm not trying to be adversarial here. I just don't know why you would want to elide the |
All good!
I'm not particularly against it, but I'm not particularly for it either.
I don't see any particular benefit to it, which is why I'm not particularly in favor of it. |
I meant a benefit to eliding the call to |
I didn't really dispute anything you are saying here. But as I pointed out in #106 (comment), eliding the |
Oh, because the buffer size must always be non-zero, but when you first create the |
My 2¢: Passing the size every frame as part of the drawing ( |
They should probably be separate arguments rather than just an array :) |
I disagree, actually — it would be easier to write graphics API glue if everyone used some kind of 2d vector type instead of separate x and y args, and arrays are cheap whether or not you care — but that's not relevant to this issue. |
I use tuples for that case. You're right though, this API change belongs in a separate discussion |
Man, this issue is getting really off-topic. I would also prefer using a shared 2D vector type, but I don't like using an array instead. Indeed I would be more happy with a tuple. |
I apologize for bringing up an unrelated issue in my example. I intended only to suggest that the simplest API that is convenient for both parties (application and library), and free of invalid states, is one where the size is always specified at the moment the buffer is being obtained. (Though, on further thought, perhaps in some cases there could be latency improvements by resizing sooner than just before drawing? Depends on how the backends treat a resize operation.) |
This isn't really a thing because you want to draw immediately after a window resize. So there's never going to be any significant gap between resizing the buffer and drawing the next frame. |
IMHO, window resizing on every frame is superfluous if the window is not resizable, which is a common case with games. In these cases I'd prefer not having to call
(Does panic as of e10c3609) |
Currently the initial window size is always 0 in width and height, this will lead to panics when calling
buffer_mut()
if the size wasn't set withresize()
depending on the platform:present()
orfetch()
(Add a function for retrieving the window contents #104).I would prefer if we make this consistent on all platforms. My current ideas:
Surface::new()
.Currently leaning towards idea 1.
The text was updated successfully, but these errors were encountered: