1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtOpenGL module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QGLFRAMEBUFFEROBJECT_H
43 #define QGLFRAMEBUFFEROBJECT_H
45 #include <QtOpenGL/qgl.h>
46 #include <QtGui/qpaintdevice.h>
53 class QGLFramebufferObjectPrivate;
54 class QGLFramebufferObjectFormat;
56 class Q_OPENGL_EXPORT QGLFramebufferObject : public QPaintDevice
58 Q_DECLARE_PRIVATE(QGLFramebufferObject)
66 QGLFramebufferObject(const QSize &size, GLenum target = GL_TEXTURE_2D);
67 QGLFramebufferObject(int width, int height, GLenum target = GL_TEXTURE_2D);
68 #if !defined(QT_OPENGL_ES) || defined(Q_QDOC)
69 QGLFramebufferObject(const QSize &size, Attachment attachment,
70 GLenum target = GL_TEXTURE_2D, GLenum internal_format = GL_RGBA8);
71 QGLFramebufferObject(int width, int height, Attachment attachment,
72 GLenum target = GL_TEXTURE_2D, GLenum internal_format = GL_RGBA8);
74 QGLFramebufferObject(const QSize &size, Attachment attachment,
75 GLenum target = GL_TEXTURE_2D, GLenum internal_format = GL_RGBA);
76 QGLFramebufferObject(int width, int height, Attachment attachment,
77 GLenum target = GL_TEXTURE_2D, GLenum internal_format = GL_RGBA);
80 QGLFramebufferObject(const QSize &size, const QGLFramebufferObjectFormat &format);
81 QGLFramebufferObject(int width, int height, const QGLFramebufferObjectFormat &format);
83 virtual ~QGLFramebufferObject();
85 QGLFramebufferObjectFormat format() const;
92 GLuint texture() const;
94 QImage toImage() const;
95 Attachment attachment() const;
97 QPaintEngine *paintEngine() const;
98 GLuint handle() const;
100 static bool bindDefault();
102 static bool hasOpenGLFramebufferObjects();
104 void drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
105 void drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
107 static bool hasOpenGLFramebufferBlit();
108 static void blitFramebuffer(QGLFramebufferObject *target, const QRect &targetRect,
109 QGLFramebufferObject *source, const QRect &sourceRect,
110 GLbitfield buffers = GL_COLOR_BUFFER_BIT,
111 GLenum filter = GL_NEAREST);
114 int metric(PaintDeviceMetric metric) const;
115 int devType() const { return QInternal::FramebufferObject; }
118 Q_DISABLE_COPY(QGLFramebufferObject)
119 QScopedPointer<QGLFramebufferObjectPrivate> d_ptr;
120 friend class QGLPaintDevice;
121 friend class QGLFBOGLPaintDevice;
124 class QGLFramebufferObjectFormatPrivate;
125 class Q_OPENGL_EXPORT QGLFramebufferObjectFormat
128 QGLFramebufferObjectFormat();
129 QGLFramebufferObjectFormat(const QGLFramebufferObjectFormat &other);
130 QGLFramebufferObjectFormat &operator=(const QGLFramebufferObjectFormat &other);
131 ~QGLFramebufferObjectFormat();
133 void setSamples(int samples);
136 void setMipmap(bool enabled);
139 void setAttachment(QGLFramebufferObject::Attachment attachment);
140 QGLFramebufferObject::Attachment attachment() const;
142 void setTextureTarget(GLenum target);
143 GLenum textureTarget() const;
145 void setInternalTextureFormat(GLenum internalTextureFormat);
146 GLenum internalTextureFormat() const;
148 bool operator==(const QGLFramebufferObjectFormat& other) const;
149 bool operator!=(const QGLFramebufferObjectFormat& other) const;
152 QGLFramebufferObjectFormatPrivate *d;
160 #endif // QGLFRAMEBUFFEROBJECT_H