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;
19 class RE_Window;
20 class RE_WindowDrawable;
21 
22 class QOpenGLContext;
23 class QSurfaceFormat;
24 class QWidget;
25 
26 
28 {
29 public:
30  RE_Visual(RE_DisplayMode newmode);
31  ~RE_Visual();
32 
33  /// ======================================================================
34  /// For new 2D UI drawing.
35  RE_WindowDrawable *createDrawable(RE_Window *win) const;
36  void deleteDrawable(RE_WindowDrawable *drawable) const;
37 
38  RE_WindowDrawable *grabDrawable(RE_Window *win, bool attach = true);
39  void returnDrawable(
40  RE_Window *win, RE_WindowDrawable *drawable);
41  /// ======================================================================
42  //
43 
44  /// ======================================================================
45  /// For OpenGL 2D UI drawing.
46  RE_OGLContext createContext(RE_Window *win) const;
47  void deleteContext(RE_OGLContext) const;
48 
49  RE_OGLContext grabContext(RE_Window *win, bool attach = true);
50  void returnContext(RE_Window *win, RE_OGLContext ctx);
51  /// ======================================================================
52 
53  // isMode() returns true on an exact match. isCompatibleWithMode() returns
54  // true if this visual is equal to or a superset of the features in 'match'
55  bool isMode(RE_DisplayMode match) const;
56  bool isCompatibleWithMode(RE_DisplayMode match) const;
57 
58  bool isRGB() const;
59 
60  /// Returns the display mode used for the request to create this visual.
61  RE_DisplayMode getMode() const { return myVisualMode; }
62 
63  const QSurfaceFormat * getPixelFormat() const;
64  static QOpenGLContext * getSharedGLContext();
65  static void initDefaultGLFormat();
66 
67  /// Return the tag we use to identify our GL widgets.
68  /// This is useful when handling events in the event loop.
69  static const char * glWidgetTag();
70 
71  /// Return the tag we use to identify our GL widget wrappers.
72  /// This is useful when handling events in the event loop.
73  static const char * glWidgetWrapperTag();
74 
75  /// Return the window widget that is bound to the specified GL widget.
76  static QWidget * ownerWindowWidget(QWidget *gl_widget);
77 
78  /// ======================================================================
79  /// For new 2D UI drawing.
80  bool canDrawableSupportQuadBufferStereo(
81  RE_WindowDrawable *drawable);
82  /// ======================================================================
83 
84  /// ======================================================================
85  /// For OpenGL 2D UI drawing.
86  bool canSupportQuadBufferStereo(OGLDrawable drawable);
87  /// ======================================================================
88 
89 private:
90  void initPixelFormat_(RE_DisplayMode mode);
91  void createSharedGLWidget_();
92  void testGLVersions_();
93  bool canCreateGLContext_(
94  int gl_major, int gl_minor,
95  bool use_core_profile);
96 
97  RE_DisplayMode myVisualMode;
98 
99  /// ======================================================================
100  /// For new 2D UI drawing.
101  UT_Lock myDrawableLock;
102  UT_Array<RE_WindowDrawable *> myVisibleDrawables;
103  /// ======================================================================
104 
105  /// ======================================================================
106  /// For OpenGL 2D UI drawing.
107  UT_Lock myContextLock;
108  UT_Array<RE_OGLContext> myVisibleContexts;
109  /// ======================================================================
110 
111  // This widget is for stashing away returned GL widgets by containing them
112  // as children. This causes the GL widgets to be parented at all times so
113  // that their window flags do not change.
114  QWidget *myStashWidget;
115 
116  QSurfaceFormat * myPixelFormat;
117 };
118 
119 #endif
#define RE_API
Definition: RE_API.h:10
==========================================================================
Definition: RE_Window.h:50
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:61
GLenum mode
Definition: glcorearb.h:99
QOpenGLContext * RE_OGLContext
Definition: RE_Types.h:949