Skip to content

Conversation

@ColonelThirtyTwo
Copy link
Contributor

This is a constructor of GlutinSurface that allows the EventLoop, WindowBuilder, and ContextBuilder to be passed in and thus configured by the user (In particular, the existing constructors do not allow passing in an EventLoop).

@hadronized
Copy link
Owner

So your new function doesn’t set the actual context? It relies on the client setting it, right? That’s not super sound, it’s super easy to mess up and forget which context to use.

) -> Result<Self, GlutinError> {
let windowed_ctx = context_builder.build_windowed(window_builder, &event_loop)?;

let ctx = unsafe { windowed_ctx.make_current().map_err(|(_, e)| e)? };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new function sets the context here. Not sure what you mean in your comment.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, the OpenGL 3.3 context. Here if the cliente doesn’t call the right function .with_gl etc.), it will not work as intended.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if you'd like, you can override the code's choice by calling .with_gl(GlRequest::Specific(Api::OpenGl, (3, 3))).with_gl_profile(GlProfile::Core) on the passed-in builder, but as it stands, it's impossible to set other useful options on the context, like vsync or srgb, or use an event loop with a generic type, because luminance needlessly takes control over those parts of the code.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that should be done (and documented). There is a similar function in the luminance-glfw crate, here; even though you can access to the context, you can see that the crate still setup the context correctly here

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So an example of creating a GLFW window, people don’t have to think about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the PR to set the context version and profile explicitly, and rebased to master.

@ColonelThirtyTwo ColonelThirtyTwo force-pushed the glutin-with-event-loop branch from ce6ff87 to 82abd96 Compare June 10, 2022 01:57
@ColonelThirtyTwo ColonelThirtyTwo force-pushed the glutin-with-event-loop branch 2 times, most recently from 8c51f5e to 99a3615 Compare December 2, 2022 19:23
This is a constructor of `GlutinSurface` that allows the `EventLoop`, `WindowBuilder`, and `ContextBuilder`
to be passed in and thus configured by the user (In particular, the existing constructors do not allow passing
in an `EventLoop`).

To ensure the context matches what luminance needs, the context is forced to OpenGL version 3.3 core profile.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants