Skip to content

Commit

Permalink
OpenGL: Force OpenGL sync to vblank for OS X.
Browse files Browse the repository at this point in the history
OS X does not offer any facility to enable OpenGL vsync, so enable it by
default. Refactor MythRenderOpenGL::Create.
  • Loading branch information
Mark Kendall committed Sep 28, 2011
1 parent a6d4268 commit f063d4e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
5 changes: 1 addition & 4 deletions mythtv/libs/libmythtv/videoout_opengl.cpp
Expand Up @@ -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();
Expand Down
4 changes: 1 addition & 3 deletions mythtv/libs/libmythui/mythmainwindow.cpp
Expand Up @@ -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);
Expand Down
9 changes: 8 additions & 1 deletion mythtv/libs/libmythui/mythrender_opengl.cpp
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions mythtv/libs/libmythui/mythrender_opengl.h
Expand Up @@ -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);
Expand Down

0 comments on commit f063d4e

Please sign in to comment.