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
Update glutin to 0.30 #2036
Update glutin to 0.30 #2036
Conversation
Sadly no. You have to allocate by creating a
Not 100% sure, for that I have to see the error that happens if you remove it...
Yeah if possible, getting the width/height on the surface should be cross platform. |
Ah alright, too bad
I get the following error without the static lifetime: error[E0310]: the parameter type `T` may not live long enough
--> src/backend/glutin/mod.rs:172:32
|
172 | let context = unsafe { context::Context::new(glutin_backend, checked, debug) }?;
| ^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
help: consider adding an explicit lifetime bound...
|
111 | impl<T: SurfaceTypeTrait + ResizeableSurface + 'static> Display<T> {
| +++++++++
I've already opened a PR which implements the missing functionality on Windows/Mac: rust-windowing/glutin#1551 So hopefully this won't be an issue for long. |
Yeah that's because
Very cool :). |
I've released Be aware that on macOS context/width/height/resize calls will block off the main thread if the main thread is blocked, though I doubt many folks use thread per context anyway, given that before macOS was SIGILL-ing. |
@est31 |
@Melchizedek6809 I need to give this a closer look on the weekend. Do you have ideas what to do about the examples? I don't know yet which direction they should go so for now I'm only looking for ideas, not neccessarily having the migration implemented. |
@est31 Since from what I can gather on first glance, most examples don't seem to differ in the way they create the Context or deal with the event loop, which might also lead to the specific examples not directly depending on glutin/winit anymore. It might however make some of the smaller examples more verbose due to the state struct. |
Sorry for coming back only now, my weekend was very busy. In general examples should be self-contained and small so that you know how to use the API from looking only at few lines of code. On the other hand, being able to focus only on the parts that matter is also very useful. I think for the very introductory examples it would be best to not use util modules but one could use it for more involved examples. It's a bit of an effort to port all of them. |
@est31 Yeah, I though it might make some examples clearer if the whole context creation boilerplate gets moved somewhere else, since it barely changes, though as you metion it's probably bad for the tutorials and associated examples. What do you think about using the same/similar structure but including it directly in the examples / tutorials so that it's not hidden away? Yeah it's probably quite a bit of work to update all the examples and especially the tutorials, if you're satisfied with the overall structure/architecture of the update I could look into updating some of them, then we might get a better picture at how much work it actually ends up being. |
It might be the best to work on the glutin upgrade on a separate branch, as it might be quite involved to port all the examples and the book. I have created a new |
Alright, I changed the base branch of this PR. What do you think about leaving the tutorial examples self contained? |
…uniforms-program-change Fixed subroutine uniforms not being updated on program change
I'm okay with that but if it becomes too much copy-paste then it would be better to make them use a support module. This is good both from a reading point of view, you know you can skip those parts because they are the same in all examples and there are no slight example specific modifications, and also good from a maintenance point of view. The readers have top priority here. |
Alright I'll keep that in mind
I respect that very much, I'll try my best. |
@est31 Finally got around to looking at the examples, added a generic container that handles the event_loop and a trait to be implemented by the examples, the support module is currently at 173 lines, I hope that is alright. Regarding the self-contained examples: there are a couple of examples that don't fit the usual schema (for example: gpgpu, info, screenshot, manual-creation, multiple_windows), do you think it's sufficient to have these be the self-contained ones? |
df05af9
to
23274f7
Compare
Ideally, the triangle example would also be self-contained so that users can familiarize themselves with the entire structure. But maybe one should only do this for the book, so I guess it's fine to keep it here in the normal examples. |
@est31 Alright, I've finally managed to port all the examples, most use the support crate except for tutorial1/2 as well as the SPIR-V example (it requires a higher OpenGL version than the rest). Those 3 also take some shortcuts to make things slightly less verbose. I still have to check the book, I'm thinking about inserting a chapter in between 2 and 3 just dealing with context creation, since this probably requires an entire chapter to explain properly. Apart from that I've fixed the tests so that they compile, they still fail as they do on the master branch, I suppose fixing them should probably go in another PR. Also, I think we can remove the headless feature, since users can just initialize glutin without a window on Mac/Linux, so it doesn't seem to be required anymore, although I might be missing something, what do you think? I'll also do some more testing on various machines to make sure that things work reliably since I've only really tested on Linux so far where things seem quite stable. |
This would lead to other errors down the line, also fixed the fxaa example, since when minimizing/resizing on Windows the framebuffer could become 0 on one dimension.
…_zero_size Validate that a framebuffer isn't 0 on any dimension
6f98028
to
9590fe6
Compare
Moved glutin-winit,winit and raw-window-handle to dev-dependencies since they are only necessary for the examples/tests. Also set default-features = false for glutin so that users can specify the feature set that they want.
Mainly a new resize method has been added to the Backend trait, this way we can direcly resize the Display, instead of having to borrow the underlying context_surface_pair first.
The headless backend isn't necessary anymore since glutin can now be initialized without a window on some platforms. Since the test_headless feature only switched the tests to use a headless backend I've removed it as well. Should also make things cleaner since it's not something users are likely to change.
Mainly making sure that it works with glutin 0.30, but I've also fixed a couple of typos, rewrote sentences so they are easier to understand and changed chapter 5 to have the color be specified in as an additional vertex attribute, and changed chapter 6 to draw a textured square instead of a textured triangle, since the OpenGL logo looks nicer that way.
0fa6243
to
4832c56
Compare
Okay thanks I somehow missed that this was ready for review. I am a bit busy with work and other projects atm but I will give it a review in the coming days, hopefully. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review, it looks really good already! Thanks for putting in all the work.
// 2. Parameters for building the Window. | ||
let wb = glium::glutin::window::WindowBuilder::new() | ||
.with_inner_size(glium::glutin::dpi::LogicalSize::new(1024.0, 768.0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this example still accurate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, I've rewritten it using simple_winit_window
, I hope that's alright, since otherwise it'd get pretty long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add back the function calls here on the SimpleWindowBuilder
?
@Melchizedek6809 sorry for the ping. Are you still interested in taking this past the finish line? Looks like there's a few small comments from the last review. If you need some assistance I can help out fixing these up. |
Since it's not necessary anymore I've removed the old simple_winit_window function, since it's not really simpler than using the builder.
@dcvz No problem and thanks for the offer and reminding me, I might take you up on that if there's much to do in the next round. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this monumental effort. This has been one of the biggest changes in glium
in the last 5 years I think.
// 2. Parameters for building the Window. | ||
let wb = glium::glutin::window::WindowBuilder::new() | ||
.with_inner_size(glium::glutin::dpi::LogicalSize::new(1024.0, 768.0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add back the function calls here on the SimpleWindowBuilder
?
Hey there,
I've been working on updating glium to work with glutin 0.30 and things are looking quite well, I've added a new example
triangle-new
because glutin needs to be initialized quite differently. I also restructured the overall example so that everything gets setup on receiving aResume
Event and dropped when aSuspend
Event arrives, this apparently should only happen on Android, but I thought that examples should probably promote the most reliable/safe way of handling things.Apart from that I tried to keep changes to the API as little as possible, which is why I've added the
ContextSurfacePair
type. I've also experimented on another branch with just keeping the Context around, but that meant breaking the API since we can't make a Context current without a Surface, and we can't determine the size of the Framebuffer without a Surface.Two other things where someone with more Rust experience may know of a better Solution:
&str
into a&CStr
? I'm currently doing the following:'static
lifetime for theDisplay
struct insrc/backend/glutin/mod.rs:82
, I have a gut feeling that this is wrong, but I'm too new to Rust to know for certain.Oh and it currently only works on *nix Platforms, due to
glutin
not implementingSurface::{width,height}
for CGL/WGL contexts which this implementation depends on, I'm looking into implementing that for glutin but wanted to create a draft request already since this might take some time.