44 #include <private/qgl_p.h> 46 #include <private/qglpixelbuffer_p.h> 62 typedef BOOL (WINAPI *
PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc,
const int *piAttribIList,
const FLOAT *pfAttribFList, UINT nMaxFormats,
int *piFormats, UINT *nNumFormats);
67 #ifndef WGL_ARB_pbuffer 68 #define WGL_DRAW_TO_PBUFFER_ARB 0x202D 69 #define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E 70 #define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F 71 #define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 72 #define WGL_PBUFFER_LARGEST_ARB 0x2033 73 #define WGL_PBUFFER_WIDTH_ARB 0x2034 74 #define WGL_PBUFFER_HEIGHT_ARB 0x2035 75 #define WGL_PBUFFER_LOST_ARB 0x2036 78 #ifndef WGL_ARB_pixel_format 79 #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 80 #define WGL_DRAW_TO_WINDOW_ARB 0x2001 81 #define WGL_DRAW_TO_BITMAP_ARB 0x2002 82 #define WGL_ACCELERATION_ARB 0x2003 83 #define WGL_NEED_PALETTE_ARB 0x2004 84 #define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 85 #define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 86 #define WGL_SWAP_METHOD_ARB 0x2007 87 #define WGL_NUMBER_OVERLAYS_ARB 0x2008 88 #define WGL_NUMBER_UNDERLAYS_ARB 0x2009 89 #define WGL_TRANSPARENT_ARB 0x200A 90 #define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 91 #define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 92 #define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 93 #define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A 94 #define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B 95 #define WGL_SHARE_DEPTH_ARB 0x200C 96 #define WGL_SHARE_STENCIL_ARB 0x200D 97 #define WGL_SHARE_ACCUM_ARB 0x200E 98 #define WGL_SUPPORT_GDI_ARB 0x200F 99 #define WGL_SUPPORT_OPENGL_ARB 0x2010 100 #define WGL_DOUBLE_BUFFER_ARB 0x2011 101 #define WGL_STEREO_ARB 0x2012 102 #define WGL_PIXEL_TYPE_ARB 0x2013 103 #define WGL_COLOR_BITS_ARB 0x2014 104 #define WGL_RED_BITS_ARB 0x2015 105 #define WGL_RED_SHIFT_ARB 0x2016 106 #define WGL_GREEN_BITS_ARB 0x2017 107 #define WGL_GREEN_SHIFT_ARB 0x2018 108 #define WGL_BLUE_BITS_ARB 0x2019 109 #define WGL_BLUE_SHIFT_ARB 0x201A 110 #define WGL_ALPHA_BITS_ARB 0x201B 111 #define WGL_ALPHA_SHIFT_ARB 0x201C 112 #define WGL_ACCUM_BITS_ARB 0x201D 113 #define WGL_ACCUM_RED_BITS_ARB 0x201E 114 #define WGL_ACCUM_GREEN_BITS_ARB 0x201F 115 #define WGL_ACCUM_BLUE_BITS_ARB 0x2020 116 #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 117 #define WGL_DEPTH_BITS_ARB 0x2022 118 #define WGL_STENCIL_BITS_ARB 0x2023 119 #define WGL_AUX_BUFFERS_ARB 0x2024 120 #define WGL_NO_ACCELERATION_ARB 0x2025 121 #define WGL_GENERIC_ACCELERATION_ARB 0x2026 122 #define WGL_FULL_ACCELERATION_ARB 0x2027 123 #define WGL_SWAP_EXCHANGE_ARB 0x2028 124 #define WGL_SWAP_COPY_ARB 0x2029 125 #define WGL_SWAP_UNDEFINED_ARB 0x202A 126 #define WGL_TYPE_RGBA_ARB 0x202B 127 #define WGL_TYPE_COLORINDEX_ARB 0x202C 130 #ifndef WGL_ARB_render_texture 131 #define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 132 #define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 133 #define WGL_TEXTURE_FORMAT_ARB 0x2072 134 #define WGL_TEXTURE_TARGET_ARB 0x2073 135 #define WGL_MIPMAP_TEXTURE_ARB 0x2074 136 #define WGL_TEXTURE_RGB_ARB 0x2075 137 #define WGL_TEXTURE_RGBA_ARB 0x2076 138 #define WGL_NO_TEXTURE_ARB 0x2077 139 #define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 140 #define WGL_TEXTURE_1D_ARB 0x2079 141 #define WGL_TEXTURE_2D_ARB 0x207A 142 #define WGL_MIPMAP_LEVEL_ARB 0x207B 143 #define WGL_CUBE_MAP_FACE_ARB 0x207C 144 #define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D 145 #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E 146 #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F 147 #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 148 #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 149 #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 150 #define WGL_FRONT_LEFT_ARB 0x2083 151 #define WGL_FRONT_RIGHT_ARB 0x2084 152 #define WGL_BACK_LEFT_ARB 0x2085 153 #define WGL_BACK_RIGHT_ARB 0x2086 154 #define WGL_AUX0_ARB 0x2087 155 #define WGL_AUX1_ARB 0x2088 156 #define WGL_AUX2_ARB 0x2089 157 #define WGL_AUX3_ARB 0x208A 158 #define WGL_AUX4_ARB 0x208B 159 #define WGL_AUX5_ARB 0x208C 160 #define WGL_AUX6_ARB 0x208D 161 #define WGL_AUX7_ARB 0x208E 162 #define WGL_AUX8_ARB 0x208F 163 #define WGL_AUX9_ARB 0x2090 166 #ifndef WGL_FLOAT_COMPONENTS_NV 167 #define WGL_FLOAT_COMPONENTS_NV 0x20B0 170 #ifndef WGL_ARB_multisample 171 #define WGL_SAMPLE_BUFFERS_ARB 0x2041 172 #define WGL_SAMPLES_ARB 0x2042 175 #ifndef GL_SAMPLES_ARB 176 #define GL_SAMPLES_ARB 0x80A9 189 if (has_render_texture) {
197 attribs[i++] =
FALSE;
260 if (!wglCreatePbufferARB)
263 dc = wglGetCurrentDC();
272 if (wglGetExtensionsStringARB) {
282 unsigned int num_formats = 0;
284 wglChoosePixelFormatARB(
dc, attribs, 0, 1, &pixel_format, &num_formats);
288 if (num_formats == 0 && f.
accum()) {
292 wglChoosePixelFormatARB(
dc, attribs, 0, 1, &pixel_format, &num_formats);
295 if (num_formats == 0) {
296 qWarning(
"QGLPixelBuffer: Unable to find a pixel format with pbuffer - giving up.");
306 int pb_attribs_null[] = {0};
312 pbuf = wglCreatePbufferARB(
dc, pixel_format, size.
width(), size.
height(), pb_attribs_null);
315 qWarning(
"QGLPixelBuffer: Unable to create pbuffer [w=%d, h=%d] - giving up.", size.
width(), size.
height());
320 dc = wglGetPbufferDCARB(
pbuf);
321 ctx = wglCreateContext(
dc);
323 qWarning(
"QGLPixelBuffer: Unable to create pbuffer context - giving up.");
330 wglMakeCurrent(
dc,
ctx);
336 HGLRC share_ctx = shareWidget ? shareWidget->d_func()->glcx->d_func()->rc : 0;
337 if (share_ctx && !wglShareLists(share_ctx,
ctx))
338 qWarning(
"QGLPixelBuffer: Unable to share display lists - with share widget.");
352 if (!
invalid && wglReleasePbufferDCARB && wglDestroyPbufferARB) {
353 wglReleasePbufferDCARB(
pbuf,
dc);
354 wglDestroyPbufferARB(
pbuf);
362 if (
d->invalid || !
d->has_render_texture)
366 if (wglBindTexImageARB) {
376 if (
d->invalid || !
d->has_render_texture)
380 if (wglReleaseTexImageARB)
392 if (wglGetExtensionsStringARB) {
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
#define QT_END_NAMESPACE
This macro expands to.
BOOL(WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC)(HPBUFFERARB hPbuffer, const int *piAttribList)
#define WGL_ALPHA_BITS_ARB
HPBUFFERARB(WINAPI * PFNWGLCREATEPBUFFERARBPROC)(HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static void qt_format_to_attrib_list(bool has_render_texture, const QGLFormat &f, int attribs[])
static bool hasOpenGLPbuffers()
Returns true if the OpenGL pbuffer extension is present on this system; otherwise returns false...
#define WGL_SAMPLE_BUFFERS_ARB
The QString class provides a Unicode character string.
BOOL(WINAPI * PFNWGLRELEASETEXIMAGEARBPROC)(HPBUFFERARB hPbuffer, int iBuffer)
Q_GUI_EXPORT QString extensions()
BOOL(WINAPI * PFNWGLBINDTEXIMAGEARBPROC)(HPBUFFERARB hPbuffer, int iBuffer)
#define WGL_TEXTURE_RGBA_ARB
#define WGL_BLUE_BITS_ARB
static const QGLContext * currentContext()
Returns the current context, i.e.
#define WGL_PBUFFER_HEIGHT_ARB
int width() const
Returns the width.
#define WGL_ACCUM_BITS_ARB
#define QT_BEGIN_NAMESPACE
This macro expands to.
#define WGL_PBUFFER_WIDTH_ARB
#define WGL_COLOR_BITS_ARB
#define WGL_FLOAT_COMPONENTS_NV
BOOL(WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC)(HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats)
Q_CORE_EXPORT void qWarning(const char *,...)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
int(WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer, HDC hDC)
#define FALSE
Synonym for false.
QGLFormat pfiToQGLFormat(HDC hdc, int pfi)
The QGLPixelBuffer class encapsulates an OpenGL pbuffer.
#define WGL_BIND_TO_TEXTURE_RGBA_ARB
#define WGL_STENCIL_BITS_ARB
const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC hdc)
#define TRUE
Synonym for true.
#define WGL_FRONT_LEFT_ARB
BOOL(WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues)
bool bindToDynamicTexture(GLuint texture)
Generates and binds a 2D GL texture that is the same size as the pbuffer, and returns the texture's I...
#define WGL_GREEN_BITS_ARB
HDC(WINAPI * PFNWGLGETPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer)
#define WGL_DOUBLE_BUFFER_ARB
BOOL(WINAPI * PFNWGLQUERYPBUFFERARBPROC)(HPBUFFERARB hPbuffer, int iAttribute, int *piValue)
#define WGL_DRAW_TO_PBUFFER_ARB
BOOL(WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues)
#define WGL_TEXTURE_2D_ARB
#define WGL_DEPTH_BITS_ARB
#define WGL_SUPPORT_OPENGL_ARB
int height() const
Returns the height.
static Extensions glExtensions()
bool init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget)
The QSize class defines the size of a two-dimensional object using integer point precision.
BOOL(WINAPI * PFNWGLDESTROYPBUFFERARBPROC)(HPBUFFERARB hPbuffer)
void releaseFromDynamicTexture()
Releases the pbuffer from any previously bound texture.
#define WGL_TEXTURE_FORMAT_ARB
#define WGL_TEXTURE_TARGET_ARB