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