Qt 4.8
Public Functions | Properties | List of all members
QGLGraphicsSystem Class Reference

#include <qgraphicssystem_gl_p.h>

Inheritance diagram for QGLGraphicsSystem:
QGraphicsSystem

Public Functions

QPixmapDatacreatePixmapData (QPixmapData::PixelType type) const
 
QWindowSurfacecreateWindowSurface (QWidget *widget) const
 
 QGLGraphicsSystem (bool useX11GL)
 
- Public Functions inherited from QGraphicsSystem
virtual QPixmapDatacreatePixmapData (QPixmapData *origin)
 
virtual QGraphicsSystemExplatformExtension ()
 
virtual ~QGraphicsSystem ()
 

Properties

bool m_useX11GL
 

Additional Inherited Members

- Static Public Functions inherited from QGraphicsSystem
static QPixmapDatacreateDefaultPixmapData (QPixmapData::PixelType type)
 

Detailed Description

Definition at line 66 of file qgraphicssystem_gl_p.h.

Constructors and Destructors

◆ QGLGraphicsSystem()

QGLGraphicsSystem::QGLGraphicsSystem ( bool  useX11GL)

Definition at line 97 of file qwindowsurface_gl.cpp.

98  : QGraphicsSystem(), m_useX11GL(useX11GL)
99 {
100 #if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
101  // only override the system defaults if the user hasn't already
102  // picked a visual
103  if (X11->visual == 0 && X11->visual_id == -1 && X11->visual_class == -1) {
104  // find a double buffered, RGBA visual that supports OpenGL
105  // and set that as the default visual for windows in Qt
106  int i = 0;
107  int spec[16];
108  spec[i++] = GLX_RGBA;
109  spec[i++] = GLX_DOUBLEBUFFER;
110 
111  if (!qgetenv("QT_GL_SWAPBUFFER_PRESERVE").isNull()) {
112  spec[i++] = GLX_DEPTH_SIZE;
113  spec[i++] = 8;
114  spec[i++] = GLX_STENCIL_SIZE;
115  spec[i++] = 8;
116  spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
117  spec[i++] = 1;
118  spec[i++] = GLX_SAMPLES_ARB;
119  spec[i++] = 4;
120  }
121 
122  spec[i++] = XNone;
123 
124  XVisualInfo *vi = glXChooseVisual(X11->display, X11->defaultScreen, spec);
125  if (vi) {
126  X11->visual_id = vi->visualid;
127  X11->visual_class = vi->c_class;
128 
130  int res;
131  glXGetConfig(X11->display, vi, GLX_LEVEL, &res);
132  format.setPlane(res);
133  glXGetConfig(X11->display, vi, GLX_DOUBLEBUFFER, &res);
134  format.setDoubleBuffer(res);
135  glXGetConfig(X11->display, vi, GLX_DEPTH_SIZE, &res);
136  format.setDepth(res);
137  if (format.depth())
138  format.setDepthBufferSize(res);
139  glXGetConfig(X11->display, vi, GLX_RGBA, &res);
140  format.setRgba(res);
141  glXGetConfig(X11->display, vi, GLX_RED_SIZE, &res);
142  format.setRedBufferSize(res);
143  glXGetConfig(X11->display, vi, GLX_GREEN_SIZE, &res);
144  format.setGreenBufferSize(res);
145  glXGetConfig(X11->display, vi, GLX_BLUE_SIZE, &res);
146  format.setBlueBufferSize(res);
147  glXGetConfig(X11->display, vi, GLX_ALPHA_SIZE, &res);
148  format.setAlpha(res);
149  if (format.alpha())
150  format.setAlphaBufferSize(res);
151  glXGetConfig(X11->display, vi, GLX_ACCUM_RED_SIZE, &res);
152  format.setAccum(res);
153  if (format.accum())
154  format.setAccumBufferSize(res);
155  glXGetConfig(X11->display, vi, GLX_STENCIL_SIZE, &res);
156  format.setStencil(res);
157  if (format.stencil())
158  format.setStencilBufferSize(res);
159  glXGetConfig(X11->display, vi, GLX_STEREO, &res);
160  format.setStereo(res);
161  glXGetConfig(X11->display, vi, GLX_SAMPLE_BUFFERS_ARB, &res);
162  format.setSampleBuffers(res);
163  if (format.sampleBuffers()) {
164  glXGetConfig(X11->display, vi, GLX_SAMPLES_ARB, &res);
165  format.setSamples(res);
166  }
167 
169  XFree(vi);
170 
171  printf("using visual class %x, id %x\n", X11->visual_class, X11->visual_id);
172  }
173  }
174 #elif defined(Q_WS_WIN)
176 
177  qt_win_owndc_required = true;
178 #endif
179 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
void setSamples(int numSamples)
Set the preferred number of samples per pixel when multisampling is enabled to numSamples.
Definition: qgl.cpp:836
void setStencil(bool enable)
If enable is true enables the stencil buffer; otherwise disables the stencil buffer.
Definition: qgl.cpp:724
void setAccumBufferSize(int size)
Set the preferred accumulation buffer size, where size is the bit depth for each RGBA component...
Definition: qgl.cpp:1143
Q_GUI_EXPORT bool qt_win_owndc_required
void setRedBufferSize(int size)
Set the preferred red buffer size to size.
Definition: qgl.cpp:1015
void setAlpha(bool enable)
If enable is true enables the alpha buffer; otherwise disables the alpha buffer.
Definition: qgl.cpp:664
void setSampleBuffers(bool enable)
If enable is true, a GL context with multisample buffer support is picked; otherwise ignored...
Definition: qgl.cpp:812
#define X11
Definition: qt_x11_p.h:724
bool sampleBuffers() const
Returns true if multisample buffer support is enabled; otherwise returns false.
Definition: qgl.h:658
void setAlphaBufferSize(int size)
Set the preferred alpha buffer size to size.
Definition: qgl.cpp:1116
bool depth() const
Returns true if the depth buffer is enabled; otherwise returns false.
Definition: qgl.h:618
#define GLX_SAMPLE_BUFFERS_ARB
The QGLFormat class specifies the display format of an OpenGL rendering context.
Definition: qgl.h:175
void setDepthBufferSize(int size)
Set the minimum depth buffer size to size.
Definition: qgl.cpp:984
bool stencil() const
Returns true if the stencil buffer is enabled; otherwise returns false.
Definition: qgl.h:638
static QGLFormat surfaceFormat
void setDoubleBuffer(bool enable)
If enable is true sets double buffering; otherwise sets single buffering.
Definition: qgl.cpp:566
void setGreenBufferSize(int size)
Set the preferred green buffer size to size.
Definition: qgl.cpp:1050
bool accum() const
Returns true if the accumulation buffer is enabled; otherwise returns false.
Definition: qgl.h:633
void setDepth(bool enable)
If enable is true enables the depth buffer; otherwise disables the depth buffer.
Definition: qgl.cpp:599
void setRgba(bool enable)
If enable is true sets RGBA mode.
Definition: qgl.cpp:633
#define GLX_SAMPLES_ARB
bool alpha() const
Returns true if the alpha buffer in the framebuffer is enabled; otherwise returns false...
Definition: qgl.h:628
void setStereo(bool enable)
If enable is true enables stereo buffering; otherwise disables stereo buffering.
Definition: qgl.cpp:754
void setBlueBufferSize(int size)
Set the preferred blue buffer size to size.
Definition: qgl.cpp:1085
void setPlane(int plane)
Sets the requested plane to plane.
Definition: qgl.cpp:942
void setStencilBufferSize(int size)
Set the preferred stencil buffer size to size.
Definition: qgl.cpp:1169
void setAccum(bool enable)
If enable is true enables the accumulation buffer; otherwise disables the accumulation buffer...
Definition: qgl.cpp:694
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300

Functions

◆ createPixmapData()

QPixmapData * QGLGraphicsSystem::createPixmapData ( QPixmapData::PixelType  type) const
virtual

Implements QGraphicsSystem.

Definition at line 65 of file qgraphicssystem_gl.cpp.

66 {
67  return new QGLPixmapData(type);
68 }
int type
Definition: qmetatype.cpp:239

◆ createWindowSurface()

QWindowSurface * QGLGraphicsSystem::createWindowSurface ( QWidget widget) const
virtual

Implements QGraphicsSystem.

Definition at line 70 of file qgraphicssystem_gl.cpp.

71 {
72 #ifdef Q_WS_WIN
73  // On Windows the QGLWindowSurface class can't handle
74  // drop shadows and native effects, e.g. fading a menu in/out using
75  // top level window opacity.
76  if (widget->windowType() == Qt::Popup)
77  return new QRasterWindowSurface(widget);
78 #endif
79 
80 #if defined(Q_WS_X11) && !defined(QT_NO_EGL)
82  // If the widget is a QGraphicsView which will be re-drawing the entire
83  // scene each frame anyway, we should use QGLWindowSurface as this may
84  // provide proper buffer flipping, which should be faster than QX11GL's
85  // blitting approach:
88  return new QGLWindowSurface(widget);
89  else
90  return new QX11GLWindowSurface(widget);
91  }
92 #endif
93 
94 #if defined(Q_OS_SYMBIAN)
95  if (!QApplicationPrivate::instance()->useTranslucentEGLSurfaces) {
99  }
100 #endif
101 
102  return new QGLWindowSurface(widget);
103 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
double d
Definition: qnumeric_p.h:62
QPointer< QWidget > widget
static QApplicationPrivate * instance()
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QWindowSurface * createDefaultWindowSurface_sys()
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
ViewportUpdateMode viewportUpdateMode
how the viewport should update its contents.
Definition: qgraphicsview.h:79

Properties

◆ m_useX11GL

bool QGLGraphicsSystem::m_useX11GL
private

Definition at line 83 of file qgraphicssystem_gl_p.h.

Referenced by createWindowSurface().


The documentation for this class was generated from the following files: