Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion include/wx/unix/glx11.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ class WXDLLIMPEXP_GL wxGLCanvasX11 : public wxGLCanvasBase
// GLX-specific methods
// --------------------

// Set swap interval to the specified value.
void GLXSetSwapInterval(int interval);

// Disable automatic setting of the swap interval done by default.
void GLXDontSetSwapInterval();


// override some wxWindow methods
// ------------------------------

Expand All @@ -100,7 +107,8 @@ class WXDLLIMPEXP_GL wxGLCanvasX11 : public wxGLCanvasBase
GLXFBConfig *m_fbc;
void* m_vi;

bool m_swapIntervalSet = false;
// The value of swap interval to set, -1 means not to set it.
int m_swapIntervalToSet = 0;
};

// ----------------------------------------------------------------------------
Expand Down
28 changes: 22 additions & 6 deletions src/unix/glx11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,26 @@ void wxGLSetSwapInterval(Display* dpy, GLXDrawable drawable, int interval)

} // anonymous namespace

void wxGLCanvasX11::GLXSetSwapInterval(int interval)
{
const Window xid = GetXWindow();
if ( !xid )
{
// Remember to do it later in SwapBuffers().
m_swapIntervalToSet = interval;
return;
}

wxGLSetSwapInterval(wxGetX11Display(), xid, interval);

GLXDontSetSwapInterval();
}

void wxGLCanvasX11::GLXDontSetSwapInterval()
{
m_swapIntervalToSet = -1;
}

bool wxGLCanvasX11::SwapBuffers()
{
const Window xid = GetXWindow();
Expand All @@ -807,13 +827,9 @@ bool wxGLCanvasX11::SwapBuffers()

// Disable blocking in glXSwapBuffers, as this is needed under XWayland for
// the reasons explained in wxGLCanvasEGL::SwapBuffers().
if ( !m_swapIntervalSet )
if ( m_swapIntervalToSet != -1 )
{
wxGLSetSwapInterval(dpy, xid, 0);

// Don't try again in any case, if we failed this time, we'll fail the
// next one anyhow.
m_swapIntervalSet = true;
GLXSetSwapInterval(m_swapIntervalToSet);
}

glXSwapBuffers(dpy, xid);
Expand Down
Loading