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

qtoglcontext.hpp « qt - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1e4ac1dab436ee8f82f21932167e30c174df5cfd (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
50
51
52
53
#pragma once

#include "drape/oglcontext.hpp"
#include "std/mutex.hpp"

#include <QtGui/QOffscreenSurface>
#include <QtGui/QOpenGLFramebufferObject>
#include <QtGui/QOpenGLContext>

class QtRenderOGLContext : public dp::OGLContext
{
public:
  QtRenderOGLContext(QOpenGLContext * rootContext, QOffscreenSurface * surface);
  ~QtRenderOGLContext();

  void present() override;
  void makeCurrent() override;
  void doneCurrent() override;
  void setDefaultFramebuffer() override;
  void resize(int w, int h) override;

  void lockFrame();
  GLuint getTextureHandle() const;
  QRectF const & getTexRect() const;
  void unlockFrame();

private:
  QOffscreenSurface * m_surface = nullptr;
  QOpenGLContext * m_ctx = nullptr;

  QOpenGLFramebufferObject * m_frontFrame = nullptr;
  QOpenGLFramebufferObject * m_backFrame = nullptr;
  QRectF m_texRect = QRectF(0.0, 0.0, 0.0, 0.0);

  mutex m_lock;
  bool m_resizeLock = false;
};

class QtUploadOGLContext: public dp::OGLContext
{
public:
  QtUploadOGLContext(QOpenGLContext * rootContext, QOffscreenSurface * surface);
  ~QtUploadOGLContext();

  void present() override;
  void makeCurrent() override;
  void doneCurrent() override;
  void setDefaultFramebuffer() override;

private:
  QOpenGLContext * m_ctx = nullptr;
  QOffscreenSurface * m_surface = nullptr;
};