| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** All rights reserved. | 
|---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com) | 
|---|
| 6 | ** | 
|---|
| 7 | ** This file is part of the QtOpenGL module of the Qt Toolkit. | 
|---|
| 8 | ** | 
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 10 | ** Commercial Usage | 
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 14 | ** a written agreement between you and Nokia. | 
|---|
| 15 | ** | 
|---|
| 16 | ** GNU Lesser General Public License Usage | 
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software | 
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
|---|
| 20 | ** packaging of this file.  Please review the following information to | 
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
|---|
| 23 | ** | 
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional | 
|---|
| 25 | ** rights.  These rights are described in the Nokia Qt LGPL Exception | 
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | 
|---|
| 27 | ** | 
|---|
| 28 | ** GNU General Public License Usage | 
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software | 
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 32 | ** packaging of this file.  Please review the following information to | 
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be | 
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** If you have questions regarding the use of this file, please contact | 
|---|
| 37 | ** Nokia at qt-info@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | #ifndef QGLPIXELBUFFER_P_H | 
|---|
| 43 | #define QGLPIXELBUFFER_P_H | 
|---|
| 44 |  | 
|---|
| 45 | // | 
|---|
| 46 | //  W A R N I N G | 
|---|
| 47 | //  ------------- | 
|---|
| 48 | // | 
|---|
| 49 | // This file is not part of the Qt API.  It exists for the convenience | 
|---|
| 50 | // of the QLibrary class.  This header file may change from | 
|---|
| 51 | // version to version without notice, or even be removed. | 
|---|
| 52 | // | 
|---|
| 53 | // We mean it. | 
|---|
| 54 | // | 
|---|
| 55 |  | 
|---|
| 56 | QT_BEGIN_NAMESPACE | 
|---|
| 57 |  | 
|---|
| 58 | QT_BEGIN_INCLUDE_NAMESPACE | 
|---|
| 59 | #include "QtOpenGL/qglpixelbuffer.h" | 
|---|
| 60 | #include <private/qgl_p.h> | 
|---|
| 61 | #include <private/qglpaintdevice_p.h> | 
|---|
| 62 |  | 
|---|
| 63 | #if defined(Q_WS_X11) && defined(QT_NO_EGL) | 
|---|
| 64 | #include <GL/glx.h> | 
|---|
| 65 |  | 
|---|
| 66 | // The below is needed to for compilation on HPUX, due to broken GLX | 
|---|
| 67 | // headers. Some of the systems define GLX_VERSION_1_3 without | 
|---|
| 68 | // defining the GLXFBConfig structure, which is wrong. | 
|---|
| 69 | #if defined (Q_OS_HPUX) && defined(QT_DEFINE_GLXFBCONFIG_STRUCT) | 
|---|
| 70 | typedef unsigned long GLXPbuffer; | 
|---|
| 71 |  | 
|---|
| 72 | struct GLXFBConfig { | 
|---|
| 73 | int visualType; | 
|---|
| 74 | int transparentType; | 
|---|
| 75 | /*    colors are floats scaled to ints */ | 
|---|
| 76 | int transparentRed, transparentGreen, transparentBlue, transparentAlpha; | 
|---|
| 77 | int transparentIndex; | 
|---|
| 78 |  | 
|---|
| 79 | int visualCaveat; | 
|---|
| 80 |  | 
|---|
| 81 | int associatedVisualId; | 
|---|
| 82 | int screen; | 
|---|
| 83 |  | 
|---|
| 84 | int drawableType; | 
|---|
| 85 | int renderType; | 
|---|
| 86 |  | 
|---|
| 87 | int maxPbufferWidth, maxPbufferHeight, maxPbufferPixels; | 
|---|
| 88 | int optimalPbufferWidth, optimalPbufferHeight;  /* for SGIX_pbuffer */ | 
|---|
| 89 |  | 
|---|
| 90 | int visualSelectGroup;      /* visuals grouped by select priority */ | 
|---|
| 91 |  | 
|---|
| 92 | unsigned int id; | 
|---|
| 93 |  | 
|---|
| 94 | GLboolean rgbMode; | 
|---|
| 95 | GLboolean colorIndexMode; | 
|---|
| 96 | GLboolean doubleBufferMode; | 
|---|
| 97 | GLboolean stereoMode; | 
|---|
| 98 | GLboolean haveAccumBuffer; | 
|---|
| 99 | GLboolean haveDepthBuffer; | 
|---|
| 100 | GLboolean haveStencilBuffer; | 
|---|
| 101 |  | 
|---|
| 102 | /* The number of bits present in various buffers */ | 
|---|
| 103 | GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits; | 
|---|
| 104 | GLint depthBits; | 
|---|
| 105 | GLint stencilBits; | 
|---|
| 106 | GLint indexBits; | 
|---|
| 107 | GLint redBits, greenBits, blueBits, alphaBits; | 
|---|
| 108 | GLuint redMask, greenMask, blueMask, alphaMask; | 
|---|
| 109 |  | 
|---|
| 110 | GLuint multiSampleSize;     /* Number of samples per pixel (0 if no ms) */ | 
|---|
| 111 |  | 
|---|
| 112 | GLuint nMultiSampleBuffers; /* Number of available ms buffers */ | 
|---|
| 113 | GLint maxAuxBuffers; | 
|---|
| 114 |  | 
|---|
| 115 | /* frame buffer level */ | 
|---|
| 116 | GLint level; | 
|---|
| 117 |  | 
|---|
| 118 | /* color ranges (for SGI_color_range) */ | 
|---|
| 119 | GLboolean extendedRange; | 
|---|
| 120 | GLdouble minRed, maxRed; | 
|---|
| 121 | GLdouble minGreen, maxGreen; | 
|---|
| 122 | GLdouble minBlue, maxBlue; | 
|---|
| 123 | GLdouble minAlpha, maxAlpha; | 
|---|
| 124 | }; | 
|---|
| 125 |  | 
|---|
| 126 | #endif // Q_OS_HPUX | 
|---|
| 127 |  | 
|---|
| 128 | #elif defined(Q_WS_WIN) | 
|---|
| 129 | DECLARE_HANDLE(HPBUFFERARB); | 
|---|
| 130 | #elif !defined(QT_NO_EGL) | 
|---|
| 131 | #include <QtGui/private/qegl_p.h> | 
|---|
| 132 | #endif | 
|---|
| 133 | QT_END_INCLUDE_NAMESPACE | 
|---|
| 134 |  | 
|---|
| 135 | class QEglContext; | 
|---|
| 136 |  | 
|---|
| 137 |  | 
|---|
| 138 | class QGLPBufferGLPaintDevice : public QGLPaintDevice | 
|---|
| 139 | { | 
|---|
| 140 | public: | 
|---|
| 141 | virtual QPaintEngine* paintEngine() const {return pbuf->paintEngine();} | 
|---|
| 142 | virtual QSize size() const {return pbuf->size();} | 
|---|
| 143 | virtual QGLContext* context() const; | 
|---|
| 144 | virtual void endPaint(); | 
|---|
| 145 | void setPBuffer(QGLPixelBuffer* pb); | 
|---|
| 146 | private: | 
|---|
| 147 | QGLPixelBuffer* pbuf; | 
|---|
| 148 | }; | 
|---|
| 149 |  | 
|---|
| 150 | class QGLPixelBufferPrivate { | 
|---|
| 151 | Q_DECLARE_PUBLIC(QGLPixelBuffer) | 
|---|
| 152 | public: | 
|---|
| 153 | QGLPixelBufferPrivate(QGLPixelBuffer *q) : q_ptr(q), invalid(true), qctx(0), pbuf(0), ctx(0) | 
|---|
| 154 | { | 
|---|
| 155 | #ifdef Q_WS_WIN | 
|---|
| 156 | dc = 0; | 
|---|
| 157 | #elif defined(Q_WS_MACX) | 
|---|
| 158 | share_ctx = 0; | 
|---|
| 159 | #endif | 
|---|
| 160 | } | 
|---|
| 161 | bool init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget); | 
|---|
| 162 | void common_init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget); | 
|---|
| 163 | bool cleanup(); | 
|---|
| 164 |  | 
|---|
| 165 | QGLPixelBuffer *q_ptr; | 
|---|
| 166 | bool invalid; | 
|---|
| 167 | QGLContext *qctx; | 
|---|
| 168 | QGLPBufferGLPaintDevice glDevice; | 
|---|
| 169 | QGLFormat format; | 
|---|
| 170 |  | 
|---|
| 171 | QGLFormat req_format; | 
|---|
| 172 | QPointer<QGLWidget> req_shareWidget; | 
|---|
| 173 | QSize req_size; | 
|---|
| 174 |  | 
|---|
| 175 | #if defined(Q_WS_X11) && defined(QT_NO_EGL) | 
|---|
| 176 | GLXPbuffer pbuf; | 
|---|
| 177 | GLXContext ctx; | 
|---|
| 178 | #elif defined(Q_WS_WIN) | 
|---|
| 179 | HDC dc; | 
|---|
| 180 | bool has_render_texture :1; | 
|---|
| 181 | #if !defined(QT_OPENGL_ES) | 
|---|
| 182 | HPBUFFERARB pbuf; | 
|---|
| 183 | HGLRC ctx; | 
|---|
| 184 | #endif | 
|---|
| 185 | #elif defined(Q_WS_MACX) | 
|---|
| 186 | #  ifdef QT_MAC_USE_COCOA | 
|---|
| 187 | void *pbuf; | 
|---|
| 188 | void *ctx; | 
|---|
| 189 | void *share_ctx; | 
|---|
| 190 | #  else | 
|---|
| 191 | AGLPbuffer pbuf; | 
|---|
| 192 | AGLContext ctx; | 
|---|
| 193 | AGLContext share_ctx; | 
|---|
| 194 | #  endif | 
|---|
| 195 | #endif | 
|---|
| 196 | #ifndef QT_NO_EGL | 
|---|
| 197 | EGLSurface pbuf; | 
|---|
| 198 | QEglContext *ctx; | 
|---|
| 199 | int textureFormat; | 
|---|
| 200 | #endif | 
|---|
| 201 | }; | 
|---|
| 202 |  | 
|---|
| 203 | QT_END_NAMESPACE | 
|---|
| 204 |  | 
|---|
| 205 | #endif // QGLPIXELBUFFER_P_H | 
|---|