HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE_Visual.h
Go to the documentation of this file.
1 #ifndef __RE_Visual_h__
2 #define __RE_Visual_h__
3 
4 #include "RE_API.h"
5 #include "RE_Types.h"
6 
7 #include <UT/UT_Lock.h>
9 
10 // Include this before including any QOpenGL files.
11 // This ensures that our OpenGL core profile API is included
12 // instead of the one shipped with Qt.
13 // TODO: We should look into moving over to Qt's OpenGL API
14 // (i.e. include QtGui/qopengl.h or maybe QtGui/QOpenGLFunctions.h
15 // instead of glcorearb.h)
16 #include "RE_OGL.h"
17 
18 class RE_Server;
20 class RE_Window;
21 class RE_WindowDrawable;
22 
23 class QOpenGLContext;
24 class QSurfaceFormat;
25 class QWidget;
26 
27 
29 {
30 public:
31  RE_Visual(RE_DisplayMode newmode);
32  ~RE_Visual();
33 
34  /// ======================================================================
35  /// For new 2D UI drawing.
36 
37  // These methods manage drawables that support OpenGL painting.
38  // {
39  RE_WindowDrawable *createDrawable(RE_Window *win) const;
40  void deleteDrawable(RE_WindowDrawable *drawable) const;
41 
42  RE_WindowDrawable *grabDrawable(RE_Window *win, bool attach = true);
43  void returnDrawable(
44  RE_Window *win, RE_WindowDrawable *drawable);
45  // }
46 
47  // These methods manage drawables that only supports QPainter painting
48  // (no OpenGL painting).
49  // {
50  RE_QPainterDrawable *createQPainterDrawable(RE_Window *win) const;
51  void deleteQPainterDrawable(
52  RE_QPainterDrawable *drawable) const;
53 
54  RE_QPainterDrawable *grabQPainterDrawable(RE_Window *win, bool attach = true);
55  void returnQPainterDrawable(
56  RE_Window *win, RE_QPainterDrawable *drawable);
57  // }
58 
59 
60  /// ======================================================================
61  //
62 
63  /// ======================================================================
64  /// For OpenGL 2D UI drawing.
65  RE_OGLContext createContext(RE_Window *win) const;
66  void deleteContext(RE_OGLContext) const;
67 
68  RE_OGLContext grabContext(RE_Window *win, bool attach = true);
69  void returnContext(RE_Window *win, RE_OGLContext ctx);
70  /// ======================================================================
71 
72  // isMode() returns true on an exact match. isCompatibleWithMode() returns
73  // true if this visual is equal to or a superset of the features in 'match'
74  bool isMode(RE_DisplayMode match) const;
75  bool isCompatibleWithMode(RE_DisplayMode match) const;
76 
77  bool isRGB() const;
78 
79  /// Returns the display mode used for the request to create this visual.
80  RE_DisplayMode getMode() const { return myVisualMode; }
81 
82  const QSurfaceFormat * getPixelFormat() const;
83  static QOpenGLContext * getSharedGLContext();
84  static void initDefaultGLFormat();
85 
86  /// Return the tag we use to identify our GL widgets.
87  /// This is useful when handling events in the event loop.
88  static const char * glWidgetTag();
89 
90  /// Return the tag we use to identify our GL widget wrappers.
91  /// This is useful when handling events in the event loop.
92  static const char * glWidgetWrapperTag();
93 
94  /// Return the window widget that is bound to the specified GL widget.
95  static QWidget * ownerWindowWidget(QWidget *gl_widget);
96 
97  /// ======================================================================
98  /// For new 2D UI drawing.
99  bool canDrawableSupportQuadBufferStereo(
100  RE_WindowDrawable *drawable);
101  /// ======================================================================
102 
103  /// ======================================================================
104  /// For OpenGL 2D UI drawing.
105  bool canSupportQuadBufferStereo(OGLDrawable drawable);
106  /// ======================================================================
107 
108 private:
109  void initPixelFormat_(RE_DisplayMode mode);
110  void createSharedGLWidget_();
111  void testGLVersions_();
112  bool canCreateGLContext_(
113  int gl_major, int gl_minor,
114  bool use_core_profile);
115 
116  RE_DisplayMode myVisualMode;
117 
118  /// ======================================================================
119  /// For new 2D UI drawing.
120 
121  UT_Lock myDrawableLock;
122  UT_Array<RE_WindowDrawable *> myVisibleDrawables[7];
123 
124  UT_Lock myQPainterDrawableLock;
125  UT_Array<RE_QPainterDrawable *> myVisibleQPainterDrawables;
126  /// ======================================================================
127 
128  /// ======================================================================
129  /// For OpenGL 2D UI drawing.
130  UT_Lock myContextLock;
131  UT_Array<RE_OGLContext> myVisibleContexts;
132  /// ======================================================================
133 
134  // This widget is for stashing away returned GL widgets by containing them
135  // as children. This causes the GL widgets to be parented at all times so
136  // that their window flags do not change.
137  QWidget *myStashWidget;
138 
139  QSurfaceFormat * myPixelFormat;
140 };
141 
142 #endif
#define RE_API
Definition: RE_API.h:10
==========================================================================
Definition: RE_Window.h:56
RE_DisplayMode
Definition: RE_Types.h:580
RE_DisplayMode getMode() const
Returns the display mode used for the request to create this visual.
Definition: RE_Visual.h:80
GLenum mode
Definition: glcorearb.h:99
Window drawable that uses only QPainter for the new UI path.
QOpenGLContext * RE_OGLContext
Definition: RE_Types.h:956