Welcome to mirror list, hosted at ThFree Co, Russian Federation.

qtoglcontext.cpp « qt - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0ae989938ee24bc218d85dd89c50f4de820fcee2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "qt/qtoglcontext.hpp"

#include "base/assert.hpp"
#include "base/logging.hpp"

#include "drape/glfunctions.hpp"

QtOGLContext::QtOGLContext(QWindow * surface, QtOGLContext * contextToShareWith)
{
  m_isContextCreated = false;
  m_surface = surface;
  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()
{
  delete m_nativeContext;
}

void QtOGLContext::makeCurrent()
{
  ASSERT(m_nativeContext->isValid(), ());
  m_nativeContext->makeCurrent(m_surface);

#ifdef DEBUG
  LOG(LDEBUG, ("Current context : ", m_nativeContext));
  QList<QOpenGLContext *> list = QOpenGLContextGroup::currentContextGroup()->shares();
  for (int i = 0; i < list.size(); ++i)
    LOG(LDEBUG, ("Share context : ", list[i]));
#endif
}

void QtOGLContext::present()
{
  m_nativeContext->makeCurrent(m_surface);
  m_nativeContext->swapBuffers(m_surface);
}

void QtOGLContext::setDefaultFramebuffer()
{
  GLFunctions::glBindFramebuffer(GL_FRAMEBUFFER, 0);
}