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

#include <qglxintegration.h>

Inheritance diagram for QGLXContext:
QPlatformGLContext QPlatformGLContext

Public Functions

virtual void doneCurrent ()
 Reimplement in subclass to release current context. More...
 
virtual void doneCurrent ()
 Reimplement in subclass to release current context. More...
 
virtual void * getProcAddress (const QString &procName)
 Reimplement in subclass to native getProcAddr calls. More...
 
virtual void * getProcAddress (const QString &procName)
 Reimplement in subclass to native getProcAddr calls. More...
 
GLXContext glxContext () const
 
GLXContext glxContext () const
 
virtual void makeCurrent ()
 Reimplement in subclass to do makeCurrent on native GL context. More...
 
virtual void makeCurrent ()
 Reimplement in subclass to do makeCurrent on native GL context. More...
 
QPlatformWindowFormat platformWindowFormat () const
 QWidget has the function qplatformWindowFormat(). More...
 
QPlatformWindowFormat platformWindowFormat () const
 QWidget has the function qplatformWindowFormat(). More...
 
 QGLXContext (Window window, QXcbScreen *xd, const QPlatformWindowFormat &format)
 
 QGLXContext (Window window, QXlibScreen *xd, const QPlatformWindowFormat &format)
 
virtual void swapBuffers ()
 Reimplement in subclass to native swap buffers calls. More...
 
virtual void swapBuffers ()
 Reimplement in subclass to native swap buffers calls. More...
 
 ~QGLXContext ()
 
 ~QGLXContext ()
 
- Public Functions inherited from QPlatformGLContext
 QPlatformGLContext ()
 All subclasses needs to specify the platformWindow. More...
 
virtual ~QPlatformGLContext ()
 If this is the current context for the thread, doneCurrent is called. More...
 

Private Functions

 QGLXContext (QXcbScreen *screen, Drawable drawable, GLXContext context)
 
 QGLXContext (QXlibScreen *screen, Drawable drawable, GLXContext context)
 

Properties

GLXContext m_context
 
Drawable m_drawable
 
QXcbScreenm_screen
 
QXlibScreenm_screen
 
QPlatformWindowFormat m_windowFormat
 

Additional Inherited Members

- Static Public Functions inherited from QPlatformGLContext
static const QPlatformGLContextcurrentContext ()
 Returns the last context which called makeCurrent. More...
 
- Protected Variables inherited from QPlatformGLContext
QScopedPointer< QPlatformGLContextPrivated_ptr
 

Detailed Description

Definition at line 54 of file qglxintegration.h.

Constructors and Destructors

◆ QGLXContext() [1/4]

QGLXContext::QGLXContext ( Window  window,
QXcbScreen xd,
const QPlatformWindowFormat format 
)

Definition at line 60 of file qglxintegration.cpp.

62  , m_screen(screen)
63  , m_drawable((Drawable)window)
64  , m_context(0)
65 {
67  const QPlatformGLContext *sharePlatformContext;
68  sharePlatformContext = format.sharedGLContext();
69  GLXContext shareGlxContext = 0;
70  if (sharePlatformContext)
71  shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext();
72 
73  GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format);
74  m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, shareGlxContext, TRUE);
77 }
GLXContext m_context
Drawable m_drawable
QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx)
#define DISPLAY_FROM_XCB(object)
QXcbConnection * connection() const
Definition: qxcbobject.h:53
NSWindow * window
QPlatformGLContext * sharedGLContext() const
GLXFBConfig qglx_findConfig(Display *display, int screen, const QPlatformWindowFormat &format, int drawableBit)
#define TRUE
Synonym for true.
Definition: qglobal.h:1018
The QPlatformGLContext class provides an abstraction for native GL contexts.
QXcbScreen * m_screen
QPlatformWindowFormat m_windowFormat
#define GLX_RGBA_TYPE
#define Q_XCB_NOOP(c)
QPlatformGLContext()
All subclasses needs to specify the platformWindow.
GLXContext glxContext() const
#define glXCreateNewContext

◆ ~QGLXContext() [1/2]

QGLXContext::~QGLXContext ( )

Definition at line 85 of file qglxintegration.cpp.

Referenced by QGLXContext().

86 {
88  if (m_context)
89  glXDestroyContext(DISPLAY_FROM_XCB(m_screen), m_context);
91 }
GLXContext m_context
#define DISPLAY_FROM_XCB(object)
QXcbConnection * connection() const
Definition: qxcbobject.h:53
QXcbScreen * m_screen
#define Q_XCB_NOOP(c)

◆ QGLXContext() [2/4]

QGLXContext::QGLXContext ( QXcbScreen screen,
Drawable  drawable,
GLXContext  context 
)
private

Definition at line 79 of file qglxintegration.cpp.

80  : QPlatformGLContext(), m_screen(screen), m_drawable(drawable), m_context(context)
81 {
82 
83 }
GLXContext m_context
Drawable m_drawable
QXcbScreen * m_screen
QPlatformGLContext()
All subclasses needs to specify the platformWindow.

◆ QGLXContext() [3/4]

QGLXContext::QGLXContext ( Window  window,
QXlibScreen xd,
const QPlatformWindowFormat format 
)

Definition at line 62 of file qglxintegration.cpp.

64  , m_screen(screen)
65  , m_drawable((Drawable)window)
66  , m_context(0)
67 {
68 
69  const QPlatformGLContext *sharePlatformContext;
70  sharePlatformContext = format.sharedGLContext();
71  GLXContext shareGlxContext = 0;
72  if (sharePlatformContext)
73  shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext();
74 
75  GLXFBConfig config = qglx_findConfig(screen->display()->nativeDisplay(),screen->xScreenNumber(),format);
76  m_context = glXCreateNewContext(screen->display()->nativeDisplay(),config,GLX_RGBA_TYPE,shareGlxContext,TRUE);
77  m_windowFormat = qglx_platformWindowFromGLXFBConfig(screen->display()->nativeDisplay(),config,m_context);
78 
79 #ifdef MYX11_DEBUG
80  qDebug() << "QGLXGLContext::create context" << m_context;
81 #endif
82 }
GLXContext m_context
Drawable m_drawable
QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx)
Q_CORE_EXPORT void qDebug(const char *,...)
NSWindow * window
QPlatformGLContext * sharedGLContext() const
GLXFBConfig qglx_findConfig(Display *display, int screen, const QPlatformWindowFormat &format, int drawableBit)
#define TRUE
Synonym for true.
Definition: qglobal.h:1018
The QPlatformGLContext class provides an abstraction for native GL contexts.
QXcbScreen * m_screen
QPlatformWindowFormat m_windowFormat
#define GLX_RGBA_TYPE
QPlatformGLContext()
All subclasses needs to specify the platformWindow.
GLXContext glxContext() const
#define glXCreateNewContext

◆ ~QGLXContext() [2/2]

QGLXContext::~QGLXContext ( )

◆ QGLXContext() [4/4]

QGLXContext::QGLXContext ( QXlibScreen screen,
Drawable  drawable,
GLXContext  context 
)
private

Definition at line 84 of file qglxintegration.cpp.

85  : QPlatformGLContext(), m_screen(screen), m_drawable(drawable), m_context(context)
86 {
87 
88 }
GLXContext m_context
Drawable m_drawable
QXcbScreen * m_screen
QPlatformGLContext()
All subclasses needs to specify the platformWindow.

Functions

◆ doneCurrent() [1/2]

void QGLXContext::doneCurrent ( )
virtual

Reimplement in subclass to release current context.

Typically this is calling makeCurrent with 0 "surface"

Reimplemented from QPlatformGLContext.

Definition at line 101 of file qglxintegration.cpp.

Referenced by QGLXContext().

102 {
105  glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), 0, 0);
107 }
#define DISPLAY_FROM_XCB(object)
virtual void doneCurrent()
Reimplement in subclass to release current context.
QXcbConnection * connection() const
Definition: qxcbobject.h:53
QXcbScreen * m_screen
#define Q_XCB_NOOP(c)

◆ doneCurrent() [2/2]

virtual void QGLXContext::doneCurrent ( )
virtual

Reimplement in subclass to release current context.

Typically this is calling makeCurrent with 0 "surface"

Reimplemented from QPlatformGLContext.

◆ getProcAddress() [1/2]

void * QGLXContext::getProcAddress ( const QString procName)
virtual

Reimplement in subclass to native getProcAddr calls.

Note: its convenient to use qPrintable(const QString &str) to get the const char * pointer

Implements QPlatformGLContext.

Definition at line 116 of file qglxintegration.cpp.

Referenced by QGLXContext().

117 {
119  typedef void *(*qt_glXGetProcAddressARB)(const GLubyte *);
120  static qt_glXGetProcAddressARB glXGetProcAddressARB = 0;
121  static bool resolved = false;
122 
123  if (resolved && !glXGetProcAddressARB)
124  return 0;
125  if (!glXGetProcAddressARB) {
126  QList<QByteArray> glxExt = QByteArray(glXGetClientString(DISPLAY_FROM_XCB(m_screen), GLX_EXTENSIONS)).split(' ');
127  if (glxExt.contains("GLX_ARB_get_proc_address")) {
128 #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
129  void *handle = dlopen(NULL, RTLD_LAZY);
130  if (handle) {
131  glXGetProcAddressARB = (qt_glXGetProcAddressARB) dlsym(handle, "glXGetProcAddressARB");
132  dlclose(handle);
133  }
134  if (!glXGetProcAddressARB)
135 #endif
136  {
137  extern const QString qt_gl_library_name();
138 // QLibrary lib(qt_gl_library_name());
139  QLibrary lib(QLatin1String("GL"));
140  glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
141  }
142  }
143  resolved = true;
144  }
145  if (!glXGetProcAddressARB)
146  return 0;
147  return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.toLatin1().data()));
148 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
#define DISPLAY_FROM_XCB(object)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
QXcbConnection * connection() const
Definition: qxcbobject.h:53
Q_OPENGL_EXPORT const QString qt_gl_library_name()
Definition: qgl.cpp:5827
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays...
QXcbScreen * m_screen
#define Q_XCB_NOOP(c)
The QLibrary class loads shared libraries at runtime.
Definition: qlibrary.h:62

◆ getProcAddress() [2/2]

virtual void* QGLXContext::getProcAddress ( const QString procName)
virtual

Reimplement in subclass to native getProcAddr calls.

Note: its convenient to use qPrintable(const QString &str) to get the const char * pointer

Implements QPlatformGLContext.

◆ glxContext() [1/2]

GLXContext QGLXContext::glxContext ( ) const
inline

Definition at line 65 of file qglxintegration.h.

Referenced by QGLXContext().

65 { return m_context; }
GLXContext m_context

◆ glxContext() [2/2]

GLXContext QGLXContext::glxContext ( ) const
inline

Definition at line 68 of file qglxintegration.h.

68 {return m_context;}
GLXContext m_context

◆ makeCurrent() [1/2]

void QGLXContext::makeCurrent ( )
virtual

Reimplement in subclass to do makeCurrent on native GL context.

Reimplemented from QPlatformGLContext.

Definition at line 93 of file qglxintegration.cpp.

Referenced by QGLXContext().

94 {
97  glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), m_drawable, m_context);
99 }
GLXContext m_context
Drawable m_drawable
#define DISPLAY_FROM_XCB(object)
QXcbConnection * connection() const
Definition: qxcbobject.h:53
virtual void makeCurrent()
Reimplement in subclass to do makeCurrent on native GL context.
QXcbScreen * m_screen
#define Q_XCB_NOOP(c)

◆ makeCurrent() [2/2]

virtual void QGLXContext::makeCurrent ( )
virtual

Reimplement in subclass to do makeCurrent on native GL context.

Reimplemented from QPlatformGLContext.

◆ platformWindowFormat() [1/2]

QPlatformWindowFormat QGLXContext::platformWindowFormat ( ) const
virtual

QWidget has the function qplatformWindowFormat().

That function is for the application programmer to request the format of the window and the context that he wants.

Reimplement this function in a subclass to indicate what format the glContext actually has.

Implements QPlatformGLContext.

Definition at line 150 of file qglxintegration.cpp.

Referenced by glxContext(), and QGLXContext().

151 {
152  return m_windowFormat;
153 }
QPlatformWindowFormat m_windowFormat

◆ platformWindowFormat() [2/2]

QPlatformWindowFormat QGLXContext::platformWindowFormat ( ) const
virtual

QWidget has the function qplatformWindowFormat().

That function is for the application programmer to request the format of the window and the context that he wants.

Reimplement this function in a subclass to indicate what format the glContext actually has.

Implements QPlatformGLContext.

◆ swapBuffers() [1/2]

void QGLXContext::swapBuffers ( )
virtual

Reimplement in subclass to native swap buffers calls.

Implements QPlatformGLContext.

Definition at line 109 of file qglxintegration.cpp.

Referenced by QGLXContext().

110 {
112  glXSwapBuffers(DISPLAY_FROM_XCB(m_screen), m_drawable);
114 }
Drawable m_drawable
#define DISPLAY_FROM_XCB(object)
QXcbConnection * connection() const
Definition: qxcbobject.h:53
QXcbScreen * m_screen
#define Q_XCB_NOOP(c)

◆ swapBuffers() [2/2]

virtual void QGLXContext::swapBuffers ( )
virtual

Reimplement in subclass to native swap buffers calls.

Implements QPlatformGLContext.

Properties

◆ m_context

GLXContext QGLXContext::m_context
private

Definition at line 72 of file qglxintegration.h.

Referenced by glxContext(), makeCurrent(), QGLXContext(), and ~QGLXContext().

◆ m_drawable

Drawable QGLXContext::m_drawable
private

Definition at line 71 of file qglxintegration.h.

Referenced by makeCurrent(), QGLXContext(), and swapBuffers().

◆ m_screen [1/2]

QXcbScreen* QGLXContext::m_screen
private

◆ m_screen [2/2]

QXlibScreen* QGLXContext::m_screen
private

Definition at line 73 of file qglxintegration.h.

◆ m_windowFormat

QPlatformWindowFormat QGLXContext::m_windowFormat
private

Definition at line 73 of file qglxintegration.h.

Referenced by platformWindowFormat(), and QGLXContext().


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