Some cleanup in CStdGLCtxQt

qteditor
Armin Burgmeier 2016-03-25 17:40:37 -07:00
parent 2a2fc68e3f
commit cf708a7cb1
1 changed files with 11 additions and 6 deletions

View File

@ -655,16 +655,16 @@ bool CStdGLCtx::PageFlip()
#include <QOpenGLContext> #include <QOpenGLContext>
#include <QOffscreenSurface> #include <QOffscreenSurface>
CStdGLCtxQt::CStdGLCtxQt() { } CStdGLCtxQt::CStdGLCtxQt() { context = NULL; surface = NULL; }
void CStdGLCtxQt::Clear(bool multisample_change) void CStdGLCtxQt::Clear(bool multisample_change)
{ {
pWindow = nullptr;
if (context) if (context)
{ {
delete context; if (!pWindow->glwidget) delete context;
delete surface; delete surface;
} }
pWindow = nullptr;
} }
bool CStdGLCtxQt::Init(C4Window *window, C4AbstractApp *app) bool CStdGLCtxQt::Init(C4Window *window, C4AbstractApp *app)
@ -693,6 +693,11 @@ bool CStdGLCtxQt::Init(C4Window *window, C4AbstractApp *app)
return pGL->Error(reinterpret_cast<const char*>(glewGetErrorString(err))); return pGL->Error(reinterpret_cast<const char*>(glewGetErrorString(err)));
} }
} }
else
{
// The Qt GL widget has its own context
context = pWindow->glwidget->context();
}
this_context = contexts.insert(contexts.end(), this); this_context = contexts.insert(contexts.end(), this);
return true; return true;
@ -700,7 +705,7 @@ bool CStdGLCtxQt::Init(C4Window *window, C4AbstractApp *app)
bool CStdGLCtxQt::Select(bool verbose) bool CStdGLCtxQt::Select(bool verbose)
{ {
if (context) if (!pWindow->glwidget)
{ {
if (!context->makeCurrent(surface)) if (!context->makeCurrent(surface))
return false; return false;
@ -724,7 +729,7 @@ bool CStdGLCtxQt::Select(bool verbose)
void CStdGLCtxQt::Deselect() void CStdGLCtxQt::Deselect()
{ {
if (context) if (!pWindow->glwidget)
context->doneCurrent(); context->doneCurrent();
else else
{ {
@ -743,7 +748,7 @@ bool CStdGLCtxQt::PageFlip()
// flush GL buffer // flush GL buffer
glFlush(); glFlush();
if (!pWindow) return false; if (!pWindow) return false;
if (context) if (!pWindow->glwidget)
return false; return false;
return true; return true;
} }