Skip to content
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

Allow changing vsync on a Window #693

Closed
bitshifter opened this issue Jan 1, 2016 · 4 comments
Closed

Allow changing vsync on a Window #693

bitshifter opened this issue Jan 1, 2016 · 4 comments

Comments

@bitshifter
Copy link

Perhaps there is a good reason for not supporting this, but many APIs do allow changing the present interval on the fly and it's useful to be able to toggle vsync without recreating the Window, device context and all resources. Perhaps a return value if the operation was supported and successful would suffice.

Something like:

impl Window {
  fn set_vsync(enabled: bool) -> Result<(), SomeError> {}
  // or even 
  fn set_present_interval(interval: PresentInterval) -> Result<(), SomeError> {}

Does this make sense for glutin?

@Aceeri
Copy link
Contributor

Aceeri commented Jan 1, 2016

While we are talking about vsync, what about changing vsync from a bool to an i8? That way you can pass in a -1 for adaptive vsync, 0 for no vsync, and 1 for vsync.

As for allowing changes in runtime, it looks like that the implementations for vsync are all setting SwapInterval at initialization right now, except for egl which I can't seem to find any vsync related code in.

@ghost
Copy link

ghost commented Jan 1, 2016

That way you can pass in a -1 for adaptive vsync, 0 for no vsync, and 1 for vsync.

An enum seems more appropriate for a setting like that.

@fkaa
Copy link
Contributor

fkaa commented Jan 1, 2016

VSync doesn't sound fun at all. From GLFW's glfwSwapInterval(int interval):

Contexts that support either of theWGL_EXT_swap_control_tear andGLX_EXT_swap_control_tear extensions also accept negative swap intervals, which allow the driver to swap even if a frame arrives a little bit late.
[...]
This function is not called during context creation, leaving the swap interval set to whatever is the default on that platform. This is done because some swap interval extensions used by GLFW do not allow the swap interval to be reset to zero once it has been set to a non-zero value.

iceiix added a commit to iceiix/steven that referenced this issue Nov 30, 2018
* Add glutin dependency

* Create a glutin window

* Use the glutin window, basics work

* Store DPI factor on game object, update on Resized

* Use physical size for rendering only. Fixes UI scaled too small

Fixes #35 (comment)
See also https://github.com/iceiix/steven/issues/22

* Begin adding mouse input events

* Listen for DeviceEvents

* Call hover_at on mouse motion

* Listen for CursorMoved window event, hovering works

Glutin has separate WindowEvent::CursorMoved and
DeviceEvent::MouseMotion events, for absolute cursor and relative mouse
motion, respectively, instead of SDL's Event::MouseMotion for both.

* Use tuple pattern matching instead of nested if for MouseInput

* Implement left clicking

* Use grab_cursor() to capture the cursor

* Hide the cursor when grabbing

* Implement MouseWheel event

* Listen for keyboard input, escape key release

* Keyboard input: console toggling, glutin calls backquote 'grave'

* Implement fullscreen in glutin, updates #31

* Update settings for glutin VirtualKeyCode

* Keyboard controls (note: must clear conf.cfg to use correct bindings)

* Move DeviceEvent match arm up higher for clarity

* Remove SDL

* Pass physical dimensions to renderer tick so blit_framebuffer can use full size but the ui is still sized logically.

* Listen for DeviceEvent::Text

* Implement text input using ReceivedCharacter window event, works

#35 (comment)

* Request specific version of OpenGL, version 3.2

* Request OpenGL 3.2 but fallback to OpenGL ES 2.0 if available (not tested)

* Set core profile and depth 24-bits, stencil 0-bits

* Allow changing vsync, but require restarting (until rust-windowing/glutin#693)

* Clarify specific Rust version requirement

* Import glutin::* in handle_window_event() to avoid overly repetitive code

* Linux in VM fix: manually calculate delta in MouseMotion

For the third issue on #35 (comment)
https://github.com/tomaka/glutin/issues/1084 MouseMotion event returns absolute instead of relative values, when running Linux in a VM

* Heuristic to detect absolute/relative MouseMotion from delta:(xrel, yrel); use a higher scaling factor

* Add clipboard pasting with clipboard crate instead of sdl2

#35 (comment)
@kchibisov
Copy link
Member

kchibisov commented Sep 3, 2022

Fixed in #1435.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants