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

#include <qgl_p.h>

Public Functions

 QGLTemporaryContext (bool directRendering=true, QWidget *parent=0)
 
 ~QGLTemporaryContext ()
 

Properties

QScopedPointer< QGLTemporaryContextPrivated
 

Detailed Description

Definition at line 329 of file qgl_p.h.

Constructors and Destructors

◆ QGLTemporaryContext()

QGLTemporaryContext::QGLTemporaryContext ( bool  directRendering = true,
QWidget parent = 0 
)

Definition at line 132 of file qgl_mac.mm.

134 {
135  d->ctx = 0;
136 #ifndef QT_MAC_USE_COCOA
137  GLint attribs[] = {AGL_RGBA, AGL_NONE};
138  AGLPixelFormat fmt = aglChoosePixelFormat(0, 0, attribs);
139  if (!fmt) {
140  qDebug("QGLTemporaryContext: Couldn't find any RGB visuals");
141  return;
142  }
143  d->ctx = aglCreateContext(fmt, 0);
144  if (!d->ctx)
145  qDebug("QGLTemporaryContext: Unable to create context");
146  else
147  aglSetCurrentContext(d->ctx);
148  aglDestroyPixelFormat(fmt);
149 #else
151  NSOpenGLPixelFormatAttribute attribs[] = { 0 };
152  NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
153  if (!fmt) {
154  qWarning("QGLTemporaryContext: Cannot find any visuals");
155  return;
156  }
157 
158  d->ctx = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:0];
159  if (!d->ctx)
160  qWarning("QGLTemporaryContext: Cannot create context");
161  else
162  [d->ctx makeCurrentContext];
163  [fmt release];
164 #endif
165 }
QScopedPointer< QGLTemporaryContextPrivate > d
Definition: qgl_p.h:335
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT void qWarning(const char *,...)
typedef GLint
Definition: glfunctions.h:67

◆ ~QGLTemporaryContext()

QGLTemporaryContext::~QGLTemporaryContext ( )

Definition at line 167 of file qgl_mac.mm.

168 {
169  if (d->ctx) {
170 #ifndef QT_MAC_USE_COCOA
171  aglSetCurrentContext(0);
172  aglDestroyContext(d->ctx);
173 #else
174  [NSOpenGLContext clearCurrentContext];
175  [d->ctx release];
176 #endif
177  }
178 }
QScopedPointer< QGLTemporaryContextPrivate > d
Definition: qgl_p.h:335

Properties

◆ d

QScopedPointer<QGLTemporaryContextPrivate> QGLTemporaryContext::d
private

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