Qt 4.8
Macros | Typedefs | Functions | Variables
qglpixelbuffer_x11.cpp File Reference
#include <qlibrary.h>
#include <qdebug.h>
#include <private/qgl_p.h>
#include <private/qt_x11_p.h>
#include <private/qpaintengine_opengl_p.h>
#include <qx11info_x11.h>
#include <GL/glx.h>
#include <qimage.h>
#include "qglpixelbuffer.h"
#include "qglpixelbuffer_p.h"
#include <dlfcn.h>

Go to the source code of this file.

Macros

#define GLX_DRAWABLE_TYPE   0x8010
 
#define GLX_PBUFFER_BIT   0x00000004
 
#define GLX_PBUFFER_HEIGHT   0x8040
 
#define GLX_PBUFFER_WIDTH   0x8041
 
#define GLX_RENDER_TYPE   0x8011
 
#define GLX_RGBA_BIT   0x00000002
 
#define GLX_RGBA_TYPE   0x8014
 
#define GLX_SAMPLE_BUFFERS_ARB   100000
 
#define GLX_SAMPLES_ARB   100001
 
#define glXChooseFBConfig   qt_glXChooseFBConfig
 
#define glXCreateNewContext   qt_glXCreateNewContext
 
#define glXCreatePbuffer   qt_glXCreatePbuffer
 
#define glXDestroyPbuffer   qt_glXDestroyPbuffer
 
#define glXGetFBConfigAttrib   qt_glXGetFBConfigAttrib
 
#define glXMakeContextCurrent   qt_glXMakeContextCurrent
 

Typedefs

typedef GLXFBConfig *(* _glXChooseFBConfig) (Display *dpy, int screen, const int *attrib_list, int *nelements)
 
typedef GLXContext(* _glXCreateNewContext) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct)
 
typedef GLXPbuffer(* _glXCreatePbuffer) (Display *dpy, GLXFBConfig config, const int *attrib_list)
 
typedef void(* _glXDestroyPbuffer) (Display *dpy, GLXPbuffer pbuf)
 
typedef int(* _glXGetFBConfigAttrib) (Display *dpy, GLXFBConfig config, int attribute, int *value)
 
typedef Bool(* _glXMakeContextCurrent) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
 

Functions

void * qglx_getProcAddress (const char *procName)
 
static void qt_format_to_attrib_list (const QGLFormat &f, int attribs[])
 
static bool qt_resolve_pbuffer_extensions ()
 

Variables

static _glXChooseFBConfig qt_glXChooseFBConfig = 0
 
static _glXCreateNewContext qt_glXCreateNewContext = 0
 
static _glXCreatePbuffer qt_glXCreatePbuffer = 0
 
static _glXDestroyPbuffer qt_glXDestroyPbuffer = 0
 
static _glXGetFBConfigAttrib qt_glXGetFBConfigAttrib = 0
 
static _glXMakeContextCurrent qt_glXMakeContextCurrent = 0
 

Macro Definition Documentation

◆ GLX_DRAWABLE_TYPE

#define GLX_DRAWABLE_TYPE   0x8010

◆ GLX_PBUFFER_BIT

#define GLX_PBUFFER_BIT   0x00000004

Definition at line 62 of file qglpixelbuffer_x11.cpp.

Referenced by buildSpec(), and qt_format_to_attrib_list().

◆ GLX_PBUFFER_HEIGHT

#define GLX_PBUFFER_HEIGHT   0x8040

Definition at line 66 of file qglpixelbuffer_x11.cpp.

Referenced by qt_format_to_attrib_list().

◆ GLX_PBUFFER_WIDTH

#define GLX_PBUFFER_WIDTH   0x8041

Definition at line 67 of file qglpixelbuffer_x11.cpp.

Referenced by qt_format_to_attrib_list().

◆ GLX_RENDER_TYPE

#define GLX_RENDER_TYPE   0x8011

Definition at line 64 of file qglpixelbuffer_x11.cpp.

Referenced by buildSpec(), qglx_buildSpec(), and qt_format_to_attrib_list().

◆ GLX_RGBA_BIT

#define GLX_RGBA_BIT   0x00000002

Definition at line 61 of file qglpixelbuffer_x11.cpp.

Referenced by buildSpec(), qglx_buildSpec(), and qt_format_to_attrib_list().

◆ GLX_RGBA_TYPE

#define GLX_RGBA_TYPE   0x8014

Definition at line 65 of file qglpixelbuffer_x11.cpp.

Referenced by QGLXContext::QGLXContext(), and qt_format_to_attrib_list().

◆ GLX_SAMPLE_BUFFERS_ARB

#define GLX_SAMPLE_BUFFERS_ARB   100000

Definition at line 71 of file qglpixelbuffer_x11.cpp.

Referenced by qt_format_to_attrib_list().

◆ GLX_SAMPLES_ARB

#define GLX_SAMPLES_ARB   100001

Definition at line 72 of file qglpixelbuffer_x11.cpp.

Referenced by qt_format_to_attrib_list().

◆ glXChooseFBConfig

#define glXChooseFBConfig   qt_glXChooseFBConfig

◆ glXCreateNewContext

#define glXCreateNewContext   qt_glXCreateNewContext

Definition at line 90 of file qglpixelbuffer_x11.cpp.

Referenced by QGLXContext::QGLXContext(), and qt_format_to_attrib_list().

◆ glXCreatePbuffer

#define glXCreatePbuffer   qt_glXCreatePbuffer

Definition at line 91 of file qglpixelbuffer_x11.cpp.

Referenced by qt_format_to_attrib_list().

◆ glXDestroyPbuffer

#define glXDestroyPbuffer   qt_glXDestroyPbuffer

Definition at line 92 of file qglpixelbuffer_x11.cpp.

Referenced by qt_format_to_attrib_list().

◆ glXGetFBConfigAttrib

#define glXGetFBConfigAttrib   qt_glXGetFBConfigAttrib

◆ glXMakeContextCurrent

#define glXMakeContextCurrent   qt_glXMakeContextCurrent

Definition at line 94 of file qglpixelbuffer_x11.cpp.

Typedef Documentation

◆ _glXChooseFBConfig

typedef GLXFBConfig*(* _glXChooseFBConfig) (Display *dpy, int screen, const int *attrib_list, int *nelements)

Definition at line 75 of file qglpixelbuffer_x11.cpp.

◆ _glXCreateNewContext

typedef GLXContext(* _glXCreateNewContext) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct)

Definition at line 79 of file qglpixelbuffer_x11.cpp.

◆ _glXCreatePbuffer

typedef GLXPbuffer(* _glXCreatePbuffer) (Display *dpy, GLXFBConfig config, const int *attrib_list)

Definition at line 77 of file qglpixelbuffer_x11.cpp.

◆ _glXDestroyPbuffer

typedef void(* _glXDestroyPbuffer) (Display *dpy, GLXPbuffer pbuf)

Definition at line 78 of file qglpixelbuffer_x11.cpp.

◆ _glXGetFBConfigAttrib

typedef int(* _glXGetFBConfigAttrib) (Display *dpy, GLXFBConfig config, int attribute, int *value)

Definition at line 76 of file qglpixelbuffer_x11.cpp.

◆ _glXMakeContextCurrent

typedef Bool(* _glXMakeContextCurrent) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)

Definition at line 80 of file qglpixelbuffer_x11.cpp.

Function Documentation

◆ qglx_getProcAddress()

void* qglx_getProcAddress ( const char *  procName)

Definition at line 350 of file qgl_x11.cpp.

Referenced by buildSpec(), qt_resolve_pbuffer_extensions(), and QGLContext::tryVisual().

351 {
352  // On systems where the GL driver is pluggable (like Mesa), we have to use
353  // the glXGetProcAddressARB extension to resolve other function pointers as
354  // the symbols wont be in the GL library, but rather in a plugin loaded by
355  // the GL library.
356  typedef void* (*qt_glXGetProcAddressARB)(const char *);
357  static qt_glXGetProcAddressARB glXGetProcAddressARB = 0;
358  static bool triedResolvingGlxGetProcAddress = false;
359  if (!triedResolvingGlxGetProcAddress) {
360  triedResolvingGlxGetProcAddress = true;
361  QGLExtensionMatcher extensions(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS));
362  if (extensions.match("GLX_ARB_get_proc_address")) {
363 #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
364  void *handle = dlopen(NULL, RTLD_LAZY);
365  if (handle) {
366  glXGetProcAddressARB = (qt_glXGetProcAddressARB) dlsym(handle, "glXGetProcAddressARB");
367  dlclose(handle);
368  }
369  if (!glXGetProcAddressARB)
370 #endif
371  {
372 #if !defined(QT_NO_LIBRARY)
373  extern const QString qt_gl_library_name();
375  lib.setLoadHints(QLibrary::ImprovedSearchHeuristics);
376  glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
377 #endif
378  }
379  }
380  }
381 
382  void *procAddress = 0;
383  if (glXGetProcAddressARB)
384  procAddress = glXGetProcAddressARB(procName);
385 
386  // If glXGetProcAddress didn't work, try looking the symbol up in the GL library
387 #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
388  if (!procAddress) {
389  void *handle = dlopen(NULL, RTLD_LAZY);
390  if (handle) {
391  procAddress = dlsym(handle, procName);
392  dlclose(handle);
393  }
394  }
395 #endif
396 #if !defined(QT_NO_LIBRARY)
397  if (!procAddress) {
398  extern const QString qt_gl_library_name();
400  lib.setLoadHints(QLibrary::ImprovedSearchHeuristics);
401  procAddress = lib.resolve(procName);
402  }
403 #endif
404 
405  return procAddress;
406 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_GUI_EXPORT QString extensions()
Definition: qegl.cpp:785
Q_OPENGL_EXPORT const QString qt_gl_library_name()
Definition: qgl.cpp:5827
static Display * display()
Returns the default display for the application.
The QLibrary class loads shared libraries at runtime.
Definition: qlibrary.h:62

◆ qt_format_to_attrib_list()

static void qt_format_to_attrib_list ( const QGLFormat f,
int  attribs[] 
)
static

Definition at line 117 of file qglpixelbuffer_x11.cpp.

118 {
119  int i = 0;
120  attribs[i++] = GLX_RENDER_TYPE;
121  attribs[i++] = GLX_RGBA_BIT;
122  attribs[i++] = GLX_DRAWABLE_TYPE;
123  attribs[i++] = GLX_PBUFFER_BIT;
124  attribs[i++] = GLX_RED_SIZE;
125  attribs[i++] = f.redBufferSize() == -1 ? 1 : f.redBufferSize();
126  attribs[i++] = GLX_GREEN_SIZE;
127  attribs[i++] = f.greenBufferSize() == -1 ? 1 : f.greenBufferSize();
128  attribs[i++] = GLX_BLUE_SIZE;
129  attribs[i++] = f.blueBufferSize() == -1 ? 1 : f.blueBufferSize();
130  if (f.doubleBuffer()) {
131  attribs[i++] = GLX_DOUBLEBUFFER;
132  attribs[i++] = true;
133  }
134  if (f.depth()) {
135  attribs[i++] = GLX_DEPTH_SIZE;
136  attribs[i++] = f.depthBufferSize() == -1 ? 1 : f.depthBufferSize();
137  }
138  if (f.stereo()) {
139  attribs[i++] = GLX_STEREO;
140  attribs[i++] = true;
141  }
142  if (f.stencil()) {
143  attribs[i++] = GLX_STENCIL_SIZE;
144  attribs[i++] = f.stencilBufferSize() == -1 ? 1 : f.stencilBufferSize();
145  }
146  if (f.alpha()) {
147  attribs[i++] = GLX_ALPHA_SIZE;
148  attribs[i++] = f.alphaBufferSize() == -1 ? 1 : f.alphaBufferSize();
149  }
150  if (f.accum()) {
151  attribs[i++] = GLX_ACCUM_RED_SIZE;
152  attribs[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
153  attribs[i++] = GLX_ACCUM_GREEN_SIZE;
154  attribs[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
155  attribs[i++] = GLX_ACCUM_BLUE_SIZE;
156  attribs[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
157  if (f.alpha()) {
158  attribs[i++] = GLX_ACCUM_ALPHA_SIZE;
159  attribs[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
160  }
161  }
162  if (f.sampleBuffers()) {
163  attribs[i++] = GLX_SAMPLE_BUFFERS_ARB;
164  attribs[i++] = 1;
165  attribs[i++] = GLX_SAMPLES_ARB;
166  attribs[i++] = f.samples() == -1 ? 4 : f.samples();
167  }
168 
169  attribs[i] = XNone;
170 }
#define GLX_SAMPLES_ARB
int greenBufferSize() const
Returns the green buffer size.
Definition: qgl.cpp:1070
#define GLX_RGBA_BIT
int redBufferSize() const
Returns the red buffer size.
Definition: qgl.cpp:1035
#define GLX_SAMPLE_BUFFERS_ARB
bool sampleBuffers() const
Returns true if multisample buffer support is enabled; otherwise returns false.
Definition: qgl.h:658
#define GLX_PBUFFER_BIT
int alphaBufferSize() const
Returns the alpha buffer size.
Definition: qgl.cpp:1132
#define GLX_DRAWABLE_TYPE
bool depth() const
Returns true if the depth buffer is enabled; otherwise returns false.
Definition: qgl.h:618
int accumBufferSize() const
Returns the accumulation buffer size.
Definition: qgl.cpp:1159
#define GLX_RENDER_TYPE
int depthBufferSize() const
Returns the depth buffer size.
Definition: qgl.cpp:1000
bool stencil() const
Returns true if the stencil buffer is enabled; otherwise returns false.
Definition: qgl.h:638
bool accum() const
Returns true if the accumulation buffer is enabled; otherwise returns false.
Definition: qgl.h:633
bool alpha() const
Returns true if the alpha buffer in the framebuffer is enabled; otherwise returns false...
Definition: qgl.h:628
int blueBufferSize() const
Returns the blue buffer size.
Definition: qgl.cpp:1105
bool doubleBuffer() const
Returns true if double buffering is enabled; otherwise returns false.
Definition: qgl.h:613
int stencilBufferSize() const
Returns the stencil buffer size.
Definition: qgl.cpp:1185
bool stereo() const
Returns true if stereo buffering is enabled; otherwise returns false.
Definition: qgl.h:643
int samples() const
Returns the number of samples per pixel when multisampling is enabled.
Definition: qgl.cpp:824

◆ qt_resolve_pbuffer_extensions()

static bool qt_resolve_pbuffer_extensions ( )
static

Definition at line 98 of file qglpixelbuffer_x11.cpp.

Referenced by qt_format_to_attrib_list().

99 {
100  static int resolved = false;
101  if (resolved && qt_glXMakeContextCurrent)
102  return true;
103  else if (resolved)
104  return false;
105 
112 
113  resolved = qt_glXMakeContextCurrent ? true : false;
114  return resolved;
115 }
static _glXGetFBConfigAttrib qt_glXGetFBConfigAttrib
static _glXDestroyPbuffer qt_glXDestroyPbuffer
GLXContext(* _glXCreateNewContext)(Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct)
static _glXChooseFBConfig qt_glXChooseFBConfig
static _glXCreateNewContext qt_glXCreateNewContext
GLXPbuffer(* _glXCreatePbuffer)(Display *dpy, GLXFBConfig config, const int *attrib_list)
static _glXCreatePbuffer qt_glXCreatePbuffer
void * qglx_getProcAddress(const char *procName)
Definition: qgl_x11.cpp:350
Bool(* _glXMakeContextCurrent)(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
GLXFBConfig *(* _glXChooseFBConfig)(Display *dpy, int screen, const int *attrib_list, int *nelements)
static _glXMakeContextCurrent qt_glXMakeContextCurrent
int(* _glXGetFBConfigAttrib)(Display *dpy, GLXFBConfig config, int attribute, int *value)
void(* _glXDestroyPbuffer)(Display *dpy, GLXPbuffer pbuf)

Variable Documentation

◆ qt_glXChooseFBConfig

_glXChooseFBConfig qt_glXChooseFBConfig = 0
static

Definition at line 82 of file qglpixelbuffer_x11.cpp.

Referenced by qt_resolve_pbuffer_extensions().

◆ qt_glXCreateNewContext

_glXCreateNewContext qt_glXCreateNewContext = 0
static

Definition at line 83 of file qglpixelbuffer_x11.cpp.

Referenced by qt_resolve_pbuffer_extensions().

◆ qt_glXCreatePbuffer

_glXCreatePbuffer qt_glXCreatePbuffer = 0
static

Definition at line 84 of file qglpixelbuffer_x11.cpp.

Referenced by qt_resolve_pbuffer_extensions().

◆ qt_glXDestroyPbuffer

_glXDestroyPbuffer qt_glXDestroyPbuffer = 0
static

Definition at line 85 of file qglpixelbuffer_x11.cpp.

Referenced by qt_resolve_pbuffer_extensions().

◆ qt_glXGetFBConfigAttrib

_glXGetFBConfigAttrib qt_glXGetFBConfigAttrib = 0
static

Definition at line 86 of file qglpixelbuffer_x11.cpp.

Referenced by qt_resolve_pbuffer_extensions().

◆ qt_glXMakeContextCurrent

_glXMakeContextCurrent qt_glXMakeContextCurrent = 0
static

Definition at line 87 of file qglpixelbuffer_x11.cpp.

Referenced by qt_resolve_pbuffer_extensions().