mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-18 22:35:39 +00:00
OpenGLHostDisplay: Update sync interval on MakeCurrent()
This commit is contained in:
parent
9d23df3aba
commit
dfdbc9a8ce
|
@ -46,6 +46,7 @@ public:
|
||||||
virtual bool ChangeSurface(const WindowInfo& new_wi) = 0;
|
virtual bool ChangeSurface(const WindowInfo& new_wi) = 0;
|
||||||
virtual void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) = 0;
|
virtual void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) = 0;
|
||||||
virtual bool SwapBuffers() = 0;
|
virtual bool SwapBuffers() = 0;
|
||||||
|
virtual bool IsCurrent() = 0;
|
||||||
virtual bool MakeCurrent() = 0;
|
virtual bool MakeCurrent() = 0;
|
||||||
virtual bool DoneCurrent() = 0;
|
virtual bool DoneCurrent() = 0;
|
||||||
virtual bool SetSwapInterval(s32 interval) = 0;
|
virtual bool SetSwapInterval(s32 interval) = 0;
|
||||||
|
|
|
@ -29,6 +29,7 @@ public:
|
||||||
bool ChangeSurface(const WindowInfo& new_wi) override;
|
bool ChangeSurface(const WindowInfo& new_wi) override;
|
||||||
void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
|
void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
|
||||||
bool SwapBuffers() override;
|
bool SwapBuffers() override;
|
||||||
|
bool IsCurrent() override;
|
||||||
bool MakeCurrent() override;
|
bool MakeCurrent() override;
|
||||||
bool DoneCurrent() override;
|
bool DoneCurrent() override;
|
||||||
bool SetSwapInterval(s32 interval) override;
|
bool SetSwapInterval(s32 interval) override;
|
||||||
|
|
|
@ -121,6 +121,11 @@ bool ContextAGL::SwapBuffers()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ContextAGL::IsCurrent()
|
||||||
|
{
|
||||||
|
return (m_context != nil && [NSOpenGLContext currentContext] == m_context);
|
||||||
|
}
|
||||||
|
|
||||||
bool ContextAGL::MakeCurrent()
|
bool ContextAGL::MakeCurrent()
|
||||||
{
|
{
|
||||||
[m_context makeCurrentContext];
|
[m_context makeCurrentContext];
|
||||||
|
|
|
@ -133,6 +133,11 @@ bool ContextEGL::SwapBuffers()
|
||||||
return eglSwapBuffers(m_display, m_surface);
|
return eglSwapBuffers(m_display, m_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ContextEGL::IsCurrent()
|
||||||
|
{
|
||||||
|
return m_context && eglGetCurrentContext() == m_context;
|
||||||
|
}
|
||||||
|
|
||||||
bool ContextEGL::MakeCurrent()
|
bool ContextEGL::MakeCurrent()
|
||||||
{
|
{
|
||||||
if (!eglMakeCurrent(m_display, m_surface, m_surface, m_context))
|
if (!eglMakeCurrent(m_display, m_surface, m_surface, m_context))
|
||||||
|
|
|
@ -20,6 +20,7 @@ public:
|
||||||
virtual bool ChangeSurface(const WindowInfo& new_wi) override;
|
virtual bool ChangeSurface(const WindowInfo& new_wi) override;
|
||||||
virtual void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
|
virtual void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
|
||||||
bool SwapBuffers() override;
|
bool SwapBuffers() override;
|
||||||
|
bool IsCurrent() override;
|
||||||
bool MakeCurrent() override;
|
bool MakeCurrent() override;
|
||||||
bool DoneCurrent() override;
|
bool DoneCurrent() override;
|
||||||
bool SetSwapInterval(s32 interval) override;
|
bool SetSwapInterval(s32 interval) override;
|
||||||
|
|
|
@ -123,6 +123,11 @@ bool ContextGLX::SwapBuffers()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ContextGLX::IsCurrent()
|
||||||
|
{
|
||||||
|
return (m_context && glXGetCurrentContext() == m_context);
|
||||||
|
}
|
||||||
|
|
||||||
bool ContextGLX::MakeCurrent()
|
bool ContextGLX::MakeCurrent()
|
||||||
{
|
{
|
||||||
return (glXMakeContextCurrent(GetDisplay(), GetDrawable(), GetDrawable(), m_context) == True);
|
return (glXMakeContextCurrent(GetDisplay(), GetDrawable(), GetDrawable(), m_context) == True);
|
||||||
|
|
|
@ -21,6 +21,7 @@ public:
|
||||||
bool ChangeSurface(const WindowInfo& new_wi) override;
|
bool ChangeSurface(const WindowInfo& new_wi) override;
|
||||||
void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
|
void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
|
||||||
bool SwapBuffers() override;
|
bool SwapBuffers() override;
|
||||||
|
bool IsCurrent() override;
|
||||||
bool MakeCurrent() override;
|
bool MakeCurrent() override;
|
||||||
bool DoneCurrent() override;
|
bool DoneCurrent() override;
|
||||||
bool SetSwapInterval(s32 interval) override;
|
bool SetSwapInterval(s32 interval) override;
|
||||||
|
|
|
@ -129,6 +129,11 @@ bool ContextWGL::SwapBuffers()
|
||||||
return ::SwapBuffers(m_dc);
|
return ::SwapBuffers(m_dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ContextWGL::IsCurrent()
|
||||||
|
{
|
||||||
|
return (m_rc && wglGetCurrentContext() == m_rc);
|
||||||
|
}
|
||||||
|
|
||||||
bool ContextWGL::MakeCurrent()
|
bool ContextWGL::MakeCurrent()
|
||||||
{
|
{
|
||||||
if (!wglMakeCurrent(m_dc, m_rc))
|
if (!wglMakeCurrent(m_dc, m_rc))
|
||||||
|
|
|
@ -24,6 +24,7 @@ public:
|
||||||
bool ChangeSurface(const WindowInfo& new_wi) override;
|
bool ChangeSurface(const WindowInfo& new_wi) override;
|
||||||
void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
|
void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
|
||||||
bool SwapBuffers() override;
|
bool SwapBuffers() override;
|
||||||
|
bool IsCurrent() override;
|
||||||
bool MakeCurrent() override;
|
bool MakeCurrent() override;
|
||||||
bool DoneCurrent() override;
|
bool DoneCurrent() override;
|
||||||
bool SetSwapInterval(s32 interval) override;
|
bool SetSwapInterval(s32 interval) override;
|
||||||
|
|
|
@ -328,7 +328,6 @@ bool OpenGLHostDisplay::SetupDevice()
|
||||||
if (!CreateResources())
|
if (!CreateResources())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SetSwapInterval();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,6 +339,7 @@ bool OpenGLHostDisplay::MakeCurrent()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetSwapInterval();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +361,9 @@ bool OpenGLHostDisplay::ChangeWindow(const WindowInfo& new_wi)
|
||||||
m_window_info = m_gl_context->GetWindowInfo();
|
m_window_info = m_gl_context->GetWindowInfo();
|
||||||
|
|
||||||
// Update swap interval for new surface.
|
// Update swap interval for new surface.
|
||||||
|
if (m_gl_context->IsCurrent())
|
||||||
SetSwapInterval();
|
SetSwapInterval();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue