Overte C++ Documentation
Basic2DWindowOpenGLDisplayPlugin.h
1 //
2 // Created by Bradley Austin Davis on 2015/05/29
3 // Copyright 2015 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 #pragma once
9 
10 #include "OpenGLDisplayPlugin.h"
11 
12 #if defined(Q_OS_ANDROID)
13 #include "VirtualPadManager.h"
14 #endif
15 
16 const float TARGET_FRAMERATE_Basic2DWindowOpenGL = 60.0f;
17 
18 class QScreen;
19 class QAction;
20 
21 class Basic2DWindowOpenGLDisplayPlugin : public OpenGLDisplayPlugin {
22  Q_OBJECT
23  using Parent = OpenGLDisplayPlugin;
24 public:
25  virtual const QString getName() const override { return NAME; }
26 
27  virtual float getTargetFrameRate() const override { return _framerateTarget ? (float) _framerateTarget : TARGET_FRAMERATE_Basic2DWindowOpenGL; }
28 
29  virtual void customizeContext() override;
30  virtual void uncustomizeContext() override;
31 
32  virtual bool internalActivate() override;
33 
34  virtual bool isThrottled() const override;
35 
36  virtual void compositeExtra() override;
37 
38  virtual void pluginUpdate() override {};
39 
40  virtual gpu::PipelinePointer getRenderTexturePipeline() override;
41 
42 protected:
43  mutable bool _isThrottled = false;
44 
45 private:
46  static const QString NAME;
47  QScreen* getFullscreenTarget();
48  std::vector<QAction*> _framerateActions;
49  QAction* _vsyncAction { nullptr };
50  uint32_t _framerateTarget { 0 };
51  int _fullscreenTarget{ -1 };
52 
53 #if defined(Q_OS_ANDROID)
54  gpu::TexturePointer _virtualPadStickTexture;
55  gpu::TexturePointer _virtualPadStickBaseTexture;
56  qreal _virtualPadPixelSize;
57 
58  gpu::TexturePointer _virtualPadJumpBtnTexture;
59  qreal _virtualPadJumpBtnPixelSize;
60 
61  gpu::TexturePointer _virtualPadRbBtnTexture;
62  qreal _virtualPadRbBtnPixelSize;
63 
64  class VirtualPadButton {
65  public:
66 
67  VirtualPadButton() {}
68  VirtualPadButton(qreal pixelSize, QString iconPath, VirtualPad::Manager::Button button);
69 
70  void draw(gpu::Batch& batch, glm::vec2 buttonPosition);
71 
72  gpu::TexturePointer _texture;
73  qreal _pixelSize;
74  VirtualPad::Manager::Button _button;
75  };
76  QVector<VirtualPadButton> _virtualPadButtons;
77 
78 #endif
79 };