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_P_H
43 #define QGLFRAMEBUFFEROBJECT_P_H
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.
58 QT_BEGIN_INCLUDE_NAMESPACE
60 #include <qglframebufferobject.h>
61 #include <private/qglpaintdevice_p.h>
62 #include <private/qgl_p.h>
64 QT_END_INCLUDE_NAMESPACE
67 #define DEFAULT_FORMAT GL_RGBA8
69 #define DEFAULT_FORMAT GL_RGBA
72 class QGLFramebufferObjectFormatPrivate
75 QGLFramebufferObjectFormatPrivate()
78 attachment(QGLFramebufferObject::NoAttachment),
79 target(GL_TEXTURE_2D),
80 internal_format(DEFAULT_FORMAT),
84 QGLFramebufferObjectFormatPrivate
85 (const QGLFramebufferObjectFormatPrivate *other)
87 samples(other->samples),
88 attachment(other->attachment),
89 target(other->target),
90 internal_format(other->internal_format),
94 bool equals(const QGLFramebufferObjectFormatPrivate *other)
96 return samples == other->samples &&
97 attachment == other->attachment &&
98 target == other->target &&
99 internal_format == other->internal_format &&
100 mipmap == other->mipmap;
105 QGLFramebufferObject::Attachment attachment;
107 GLenum internal_format;
111 class QGLFBOGLPaintDevice : public QGLPaintDevice
114 virtual QPaintEngine* paintEngine() const {return fbo->paintEngine();}
115 virtual QSize size() const {return fbo->size();}
116 virtual QGLContext* context() const;
117 virtual QGLFormat format() const {return fboFormat;}
118 virtual bool alphaRequested() const { return reqAlpha; }
120 void setFBO(QGLFramebufferObject* f,
121 QGLFramebufferObject::Attachment attachment);
124 QGLFramebufferObject* fbo;
130 class QGLFramebufferObjectPrivate
133 QGLFramebufferObjectPrivate() : fbo_guard(0), texture_guard(0), depth_buffer_guard(0)
134 , stencil_buffer_guard(0), color_buffer_guard(0)
135 , valid(false), engine(0) {}
136 ~QGLFramebufferObjectPrivate() {}
138 void init(QGLFramebufferObject *q, const QSize& sz,
139 QGLFramebufferObject::Attachment attachment,
140 GLenum internal_format, GLenum texture_target,
141 GLint samples = 0, bool mipmap = false);
142 bool checkFramebufferStatus() const;
143 QGLSharedResourceGuardBase *fbo_guard;
144 QGLSharedResourceGuardBase *texture_guard;
145 QGLSharedResourceGuardBase *depth_buffer_guard;
146 QGLSharedResourceGuardBase *stencil_buffer_guard;
147 QGLSharedResourceGuardBase *color_buffer_guard;
150 QGLFramebufferObjectFormat format;
152 QGLFramebufferObject::Attachment fbo_attachment;
153 mutable QPaintEngine *engine;
154 QGLFBOGLPaintDevice glDevice;
156 inline GLuint fbo() const { return fbo_guard ? fbo_guard->id() : 0; }
162 #endif // QGLFRAMEBUFFEROBJECT_P_H