Add wxGLCanvasX11::GLXSetSwapInterval() (PR #25449)

39 views
Skip to first unread message

VZ

unread,
May 25, 2025, 2:25:29 PMMay 25
to wx-...@googlegroups.com, Subscribed

Allow setting the swap interval value or not setting it at all instead of always forcing it to 0.

The changes of 3dde6bd (Disable swap interval in GLX wxGLCanvas implementation too, 2023-12-25) are not always desirable, so allow to customize the behaviour.

See #24163, #24165.


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/25449

Commit Summary

  • 42331e2 Add wxGLCanvasX11::GLXSetSwapInterval()

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25449@github.com>

VZ

unread,
Nov 22, 2025, 12:12:37 PMNov 22
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25449)

I've completely forgot about this one because it was marked as "Draft" and by now I don't remember why any more.

@dsa-t I think this was requested by you, would this still be useful?

In any case, we need to either merge or close it.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25449/c3566897774@github.com>

dsa-t

unread,
Nov 22, 2025, 12:19:06 PMNov 22
to wx-...@googlegroups.com, Subscribed
dsa-t left a comment (wxWidgets/wxWidgets#25449)

I think SetSwapInterval needs to be implemented in each GL backend, not just wxGLCanvasX11::GLXSetSwapInterval.

And I don't think the interval should be changed inside SwapBuffers.

For Wayland, I think a solution similar to SDL can be implemented (see #24977 (comment))


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25449/c3566902114@github.com>

dsa-t

unread,
Nov 22, 2025, 12:36:54 PMNov 22
to wx-...@googlegroups.com, Subscribed
dsa-t left a comment (wxWidgets/wxWidgets#25449)

Also I'm not sure if wxGLSetSwapInterval checks for the extension correctly.

glXSwapIntervalEXT function may exist in the client library, but GLX_EXT_swap_control/GLX_EXT_swap_control_tear extensions may not supported by the driver.

See how it's implemented in KiCad: https://gitlab.com/kicad/code/kicad/-/blob/c5a2b86379d3583a47e0e4ee5ef64dc898d68e75/include/gal/opengl/gl_utils.h#L49


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25449/c3566914420@github.com>

VZ

unread,
Nov 23, 2025, 11:19:02 AMNov 23
to wx-...@googlegroups.com, Push

@vadz pushed 4 commits.

  • 76ee8d6 Add wxGLCanvasX11::GLXSetSwapInterval()
  • 5b2b995 Inline wxGLSetSwapInterval() in the only place where it's called
  • b696177 Check for GLX_EXT_swap_control availability
  • 96fd532 Fall back on GLX_MESA_swap_control if GLX_EXT_swap_control is NA


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25449/before/42331e266b7a8dd55ca839d3e2b3961bd4b256bc/after/96fd5328f937e323a58b744acc08face29e2f34a@github.com>

VZ

unread,
Nov 23, 2025, 11:24:50 AMNov 23
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25449)

I think SetSwapInterval needs to be implemented in each GL backend, not just wxGLCanvasX11::GLXSetSwapInterval.

I may have forgotten (or just misunderstood) things but I thought that we wanted to add it to allow customizing setting of the swap interval to 0 done right now in Unix (GLX and EGL) backends. Do we really need it elsewhere? It wouldn't be that difficult to call wglSwapIntervalEXT() under Windows and apparently there is CGLSetParameter(kCGLCPSwapInterval) for macOS, but would this be really useful there? Will KiCad use this?

And I don't think the interval should be changed inside SwapBuffers.

Note that this is only done once. It's a way to allow setting the interval before it can be applied. Is it still a problem?

For Wayland, I think a solution similar to SDL can be implemented (see #24977 (comment))

This seems complicated and fragile :-( The original commit message speaks about "upcoming protocols that should improve the situation", would anybody know if anything has happened since then (2021)?

glXSwapIntervalEXT function may exist in the client library, but GLX_EXT_swap_control/GLX_EXT_swap_control_tear extensions may not supported by the driver.

Thanks, this is definitely a good point, I've updated this PR with a better check. I've also added a check for MESA extension, although I'm unable to test this because all my systems support EXT_swap_control — but it looks like it shouldn't do any harm. I didn't add support for GLX_SGI_swap_control, even though it would be easy to do, of course, because it looks like this one shouldn't be relevant any longer.

Finally, I've rebased everything on master.

Next steps are:

  1. Decide if we need this under Windows (easy to do, questionable utility).
  2. And under macOS (slightly less clear how to do, same question about utility).
  3. Implement at least GLXDontSetSwapInterval() for EGL backend (simple to do, might be useful?).
  4. Think about whether we really need GLXSetSwapInterval() with arbitrary interval for EGL too and do something like what SDL does, but I'm still not sure if this is really a wise thing to do — and would definitely welcome any better ideas!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25449/c3568125621@github.com>

VZ

unread,
Dec 10, 2025, 11:02:39 AM (3 days ago) Dec 10
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25449)

This would need to be redone once #26023 is merged, but I am still not sure about (4) (and also (1) and (2)...) from above.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25449/c3637802215@github.com>

Reply all
Reply to author
Forward
0 new messages