Skip to content
Permalink
Browse files

OpenGL: Force OpenGL sync to vblank for OS X.

OS X does not offer any facility to enable OpenGL vsync, so enable it by
default. Refactor MythRenderOpenGL::Create.
  • Loading branch information
Mark Kendall
Mark Kendall committed Sep 28, 2011
1 parent a6d4268 commit f063d4ed6c8463a2db1c8ca17f564010e20b8091
@@ -287,17 +287,14 @@ bool VideoOutputOpenGL::SetupContext(void)
return true;
}

QGLFormat fmt;
fmt.setDepth(false);

QGLWidget *device = (QGLWidget*)QWidget::find(gl_parent_win);
if (!device)
{
LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to cast parent to QGLWidget");
return false;
}

gl_context = MythRenderOpenGL::Create(fmt, device);
gl_context = MythRenderOpenGL::Create(device);
if (gl_context && gl_context->create())
{
gl_context->Init();
@@ -961,9 +961,7 @@ void MythMainWindow::Init(void)
{
LOG(VB_GENERAL, LOG_INFO, "Trying the OpenGL painter");
d->painter = new MythOpenGLPainter();
QGLFormat fmt;
fmt.setDepth(false);
d->render = MythRenderOpenGL::Create(fmt);
d->render = MythRenderOpenGL::Create();
MythRenderOpenGL *gl = dynamic_cast<MythRenderOpenGL*>(d->render);
d->paintwin = new MythPainterWindowGL(this, d, gl);
QGLWidget *qgl = dynamic_cast<QGLWidget *>(d->paintwin);
@@ -42,8 +42,15 @@ OpenGLLocker::~OpenGLLocker()
m_render->doneCurrent();
}

MythRenderOpenGL* MythRenderOpenGL::Create(const QGLFormat& format, QPaintDevice* device)
MythRenderOpenGL* MythRenderOpenGL::Create(QPaintDevice* device)
{
QGLFormat format;
format.setDepth(false);

#if defined(Q_WS_MAC)
format.setSwapInterval(1);
#endif

#ifdef USING_OPENGLES
if (device)
return new MythRenderOpenGL2ES(format, device);
@@ -98,8 +98,7 @@ class MUI_PUBLIC OpenGLLocker
class MUI_PUBLIC MythRenderOpenGL : public QGLContext, public MythRender
{
public:
static MythRenderOpenGL* Create(const QGLFormat& format,
QPaintDevice* device = NULL);
static MythRenderOpenGL* Create(QPaintDevice* device = NULL);

MythRenderOpenGL(const QGLFormat& format, QPaintDevice* device,
RenderType type = kRenderUnknown);

0 comments on commit f063d4e

Please sign in to comment.
You can’t perform that action at this time.