- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qglframebufferobject.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtOpenGL module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QGLFRAMEBUFFEROBJECT_H
    00043 #define QGLFRAMEBUFFEROBJECT_H
    00044
    00045 #include <QtOpenGL/qgl.h>
    00046 #include <QtGui/qpaintdevice.h>
    00047
    00048 QT_BEGIN_HEADER
    00049
    00050 QT_BEGIN_NAMESPACE
    00051
    00052 QT_MODULE(OpenGL)
    00053
    00054 class QGLFramebufferObjectPrivate;
    00055 class QGLFramebufferObjectFormat;
    00056
    00057 class Q_OPENGL_EXPORT QGLFramebufferObject : public QPaintDevice
    00058 {
    00059     Q_DECLARE_PRIVATE(QGLFramebufferObject)
    00060 public:
    00061     enum Attachment {
    00062         NoAttachment,
    00063         CombinedDepthStencil,
    00064         Depth
    00065     };
    00066
    00067     QGLFramebufferObject(const QSize &size, GLenum target = GL_TEXTURE_2D);
    00068     QGLFramebufferObject(int width, int height, GLenum target = GL_TEXTURE_2D);
    00069 #if !defined(QT_OPENGL_ES) || defined(Q_QDOC)
    00070     QGLFramebufferObject(const QSize &size, Attachment attachment,
    00071                          GLenum target = GL_TEXTURE_2D, GLenum internal_format = GL_RGBA8);
    00072     QGLFramebufferObject(int width, int height, Attachment attachment,
    00073                          GLenum target = GL_TEXTURE_2D, GLenum internal_format = GL_RGBA8);
    00074 #else
    00075     QGLFramebufferObject(const QSize &size, Attachment attachment,
    00076                          GLenum target = GL_TEXTURE_2D, GLenum internal_format = GL_RGBA);
    00077     QGLFramebufferObject(int width, int height, Attachment attachment,
    00078                          GLenum target = GL_TEXTURE_2D, GLenum internal_format = GL_RGBA);
    00079 #endif
    00080
    00081     QGLFramebufferObject(const QSize &size, const QGLFramebufferObjectFormat &format);
    00082     QGLFramebufferObject(int width, int height, const QGLFramebufferObjectFormat &format);
    00083
    00084 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS
    00085     QGLFramebufferObject(const QSize &size, QMacCompatGLenum target = GL_TEXTURE_2D);
    00086     QGLFramebufferObject(int width, int height, QMacCompatGLenum target = GL_TEXTURE_2D);
    00087
    00088     QGLFramebufferObject(const QSize &size, Attachment attachment,
    00089                          QMacCompatGLenum target = GL_TEXTURE_2D, QMacCompatGLenum internal_format = GL_RGBA8);
    00090     QGLFramebufferObject(int width, int height, Attachment attachment,
    00091                          QMacCompatGLenum target = GL_TEXTURE_2D, QMacCompatGLenum internal_format = GL_RGBA8);
    00092 #endif
    00093
    00094     virtual ~QGLFramebufferObject();
    00095
    00096     QGLFramebufferObjectFormat format() const;
    00097
    00098     bool isValid() const;
    00099     bool isBound() const;
    00100     bool bind();
    00101     bool release();
    00102
    00103     GLuint texture() const;
    00104     QSize size() const;
    00105     QImage toImage() const;
    00106     Attachment attachment() const;
    00107
    00108     QPaintEngine *paintEngine() const;
    00109     GLuint handle() const;
    00110
    00111     static bool bindDefault();
    00112
    00113     static bool hasOpenGLFramebufferObjects();
    00114
    00115     void drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
    00116     void drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
    00117 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS
    00118     void drawTexture(const QRectF &target, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget = GL_TEXTURE_2D);
    00119     void drawTexture(const QPointF &point, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget = GL_TEXTURE_2D);
    00120 #endif
    00121
    00122     static bool hasOpenGLFramebufferBlit();
    00123     static void blitFramebuffer(QGLFramebufferObject *target, const QRect &targetRect,
    00124                                 QGLFramebufferObject *source, const QRect &sourceRect,
    00125                                 GLbitfield buffers = GL_COLOR_BUFFER_BIT,
    00126                                 GLenum filter = GL_NEAREST);
    00127
    00128 protected:
    00129     int metric(PaintDeviceMetric metric) const;
    00130     int devType() const { return QInternal::FramebufferObject; }
    00131
    00132 private:
    00133     Q_DISABLE_COPY(QGLFramebufferObject)
    00134     QScopedPointer<QGLFramebufferObjectPrivate> d_ptr;
    00135     friend class QGLPaintDevice;
    00136     friend class QGLFBOGLPaintDevice;
    00137 };
    00138
    00139 class QGLFramebufferObjectFormatPrivate;
    00140 class Q_OPENGL_EXPORT QGLFramebufferObjectFormat
    00141 {
    00142 public:
    00143     QGLFramebufferObjectFormat();
    00144     QGLFramebufferObjectFormat(const QGLFramebufferObjectFormat &other);
    00145     QGLFramebufferObjectFormat &operator=(const QGLFramebufferObjectFormat &other);
    00146     ~QGLFramebufferObjectFormat();
    00147
    00148     void setSamples(int samples);
    00149     int samples() const;
    00150
    00151     void setAttachment(QGLFramebufferObject::Attachment attachment);
    00152     QGLFramebufferObject::Attachment attachment() const;
    00153
    00154     void setTextureTarget(GLenum target);
    00155     GLenum textureTarget() const;
    00156
    00157     void setInternalTextureFormat(GLenum internalTextureFormat);
    00158     GLenum internalTextureFormat() const;
    00159
    00160 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS
    00161     void setTextureTarget(QMacCompatGLenum target);
    00162     void setInternalTextureFormat(QMacCompatGLenum internalTextureFormat);
    00163 #endif
    00164
    00165     bool operator==(const QGLFramebufferObjectFormat& other) const;
    00166     bool operator!=(const QGLFramebufferObjectFormat& other) const;
    00167
    00168 private:
    00169     QGLFramebufferObjectFormatPrivate *d;
    00170
    00171     void detach();
    00172 };
    00173
    00174 QT_END_NAMESPACE
    00175
    00176 QT_END_HEADER
    00177 #endif // QGLFRAMEBUFFEROBJECT_H