Overte C++ Documentation
GLWidget.h
1 //
2 // Created by Bradley Austin Davis on 2015/12/03
3 // Derived from interface/src/GLCanvas.h created by Stephen Birarda on 8/14/13.
4 // Copyright 2013-2015 High Fidelity, Inc.
5 //
6 // Distributed under the Apache License, Version 2.0.
7 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
8 //
9 
10 #ifndef hifi_GLWidget_h
11 #define hifi_GLWidget_h
12 
13 #include <QtWidgets/QWidget>
14 
15 namespace gl {
16  class Context;
17 }
18 
19 class QOpenGLContext;
20 
22 class GLWidget : public QWidget {
23  Q_OBJECT
24 
25 public:
26  GLWidget();
27  ~GLWidget();
28  int getDeviceWidth() const;
29  int getDeviceHeight() const;
30  QSize getDeviceSize() const { return QSize(getDeviceWidth(), getDeviceHeight()); }
31  QPaintEngine* paintEngine() const override;
32  void createContext(QOpenGLContext* shareContext = nullptr);
33  bool makeCurrent();
34  void doneCurrent();
35  void swapBuffers();
36  gl::Context* context() { return _context; }
37  QOpenGLContext* qglContext();
38  virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
39 
40 protected:
41  virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
42  virtual bool event(QEvent* event) override;
43  gl::Context* _context { nullptr };
44 
45 private:
46  QPaintEngine* _paintEngine { nullptr };
47  bool _vsyncSupported { false };
48 };
49 
50 #endif // hifi_GLCanvas_h
customized canvas that simply forwards requests/events to the singleton application
Definition: GLWidget.h:22