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