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 QtGui 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 QOPENGLFRAMEBUFFEROBJECT_P_H
43 #define QOPENGLFRAMEBUFFEROBJECT_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 <qopenglframebufferobject.h>
61 #include <private/qopenglcontext_p.h>
62 #include <private/qopenglextensions_p.h>
64 QT_END_INCLUDE_NAMESPACE
67 #define DEFAULT_FORMAT GL_RGBA8
69 #define DEFAULT_FORMAT GL_RGBA
72 class QOpenGLFramebufferObjectFormatPrivate
75 QOpenGLFramebufferObjectFormatPrivate()
78 attachment(QOpenGLFramebufferObject::NoAttachment),
79 target(GL_TEXTURE_2D),
80 internal_format(DEFAULT_FORMAT),
84 QOpenGLFramebufferObjectFormatPrivate
85 (const QOpenGLFramebufferObjectFormatPrivate *other)
87 samples(other->samples),
88 attachment(other->attachment),
89 target(other->target),
90 internal_format(other->internal_format),
94 bool equals(const QOpenGLFramebufferObjectFormatPrivate *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 QOpenGLFramebufferObject::Attachment attachment;
107 GLenum internal_format;
111 class QOpenGLFramebufferObjectPrivate
114 QOpenGLFramebufferObjectPrivate() : fbo_guard(0), texture_guard(0), depth_buffer_guard(0)
115 , stencil_buffer_guard(0), color_buffer_guard(0)
117 ~QOpenGLFramebufferObjectPrivate() {}
119 void init(QOpenGLFramebufferObject *q, const QSize& sz,
120 QOpenGLFramebufferObject::Attachment attachment,
121 GLenum internal_format, GLenum texture_target,
122 GLint samples = 0, bool mipmap = false);
123 void initAttachments(QOpenGLContext *ctx, QOpenGLFramebufferObject::Attachment attachment);
125 bool checkFramebufferStatus(QOpenGLContext *ctx) const;
126 QOpenGLSharedResourceGuard *fbo_guard;
127 QOpenGLSharedResourceGuard *texture_guard;
128 QOpenGLSharedResourceGuard *depth_buffer_guard;
129 QOpenGLSharedResourceGuard *stencil_buffer_guard;
130 QOpenGLSharedResourceGuard *color_buffer_guard;
133 QOpenGLFramebufferObjectFormat format;
135 QOpenGLFramebufferObject::Attachment fbo_attachment;
136 QOpenGLExtensions funcs;
138 inline GLuint fbo() const { return fbo_guard ? fbo_guard->id() : 0; }
144 #endif // QOPENGLFRAMEBUFFEROBJECT_P_H