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