From 12fa4e32798e1c4f998870aaceea0e7525a3fe14 Mon Sep 17 00:00:00 2001 From: ExMix Date: Fri, 10 Jan 2014 12:46:38 +0300 Subject: [PATCH] [drape] create QtOpenGLContext in constructor. In this moment QWindow must be exposed. --- drape_head/qtoglcontext.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drape_head/qtoglcontext.cpp b/drape_head/qtoglcontext.cpp index beba1b1338..076416129e 100644 --- a/drape_head/qtoglcontext.cpp +++ b/drape_head/qtoglcontext.cpp @@ -1,16 +1,20 @@ #include "qtoglcontext.hpp" #include "../base/assert.hpp" +#include "../base/logging.hpp" QtOGLContext::QtOGLContext(QWindow * surface, QtOGLContext * contextToShareWith) { m_isContextCreated = false; m_surface = surface; - m_nativeContext = new QOpenGLContext(NULL); - m_nativeContext->setFormat(m_surface->requestedFormat()); + m_nativeContext = new QOpenGLContext(); if (contextToShareWith != NULL) m_nativeContext->setShareContext(contextToShareWith->m_nativeContext); + + m_nativeContext->setFormat(m_surface->requestedFormat()); + ASSERT(m_surface->isExposed(), ()); + VERIFY(m_nativeContext->create(), ()); } QtOGLContext::~QtOGLContext() @@ -20,19 +24,19 @@ QtOGLContext::~QtOGLContext() void QtOGLContext::makeCurrent() { - if (!m_isContextCreated) - { - ASSERT(m_surface->isExposed(), ()); - m_nativeContext->create(); - m_isContextCreated = true; - } ASSERT(m_nativeContext->isValid(), ()); m_nativeContext->makeCurrent(m_surface); + +#ifdef DEBUG + LOG(LDEBUG, ("Current context : ", m_nativeContext)); + QList list = QOpenGLContextGroup::currentContextGroup()->shares(); + for (int i = 0; i < list.size(); ++i) + LOG(LDEBUG, ("Share context : ", list[i])); +#endif } void QtOGLContext::present() { - ASSERT(m_isContextCreated, ()); m_nativeContext->makeCurrent(m_surface); m_nativeContext->swapBuffers(m_surface); }