Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qopenglframebufferobject.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QOPENGLFRAMEBUFFEROBJECT_H
5#define QOPENGLFRAMEBUFFEROBJECT_H
6
7#include <QtOpenGL/qtopenglglobal.h>
8
9#include <QtGui/qopengl.h>
10#include <QtGui/qpaintdevice.h>
11
12#include <QtCore/qscopedpointer.h>
13
14#if defined(Q_QDOC)
15#undef GLuint
16typedef unsigned int GLuint;
17#undef GLenum
18typedef unsigned int GLenum;
19#undef GL_TEXTURE_2D
20#define GL_TEXTURE_2D 0x0DE1
21#undef GLbitfield
22typedef unsigned int GLbitfield;
23#endif
24
25QT_BEGIN_NAMESPACE
26
27class QOpenGLFramebufferObjectPrivate;
28class QOpenGLFramebufferObjectFormat;
29
30class Q_OPENGL_EXPORT QOpenGLFramebufferObject
31{
32 Q_DECLARE_PRIVATE(QOpenGLFramebufferObject)
33public:
34 enum Attachment {
35 NoAttachment,
36 CombinedDepthStencil,
37 Depth
38 };
39
40 explicit QOpenGLFramebufferObject(const QSize &size, GLenum target = GL_TEXTURE_2D);
41 QOpenGLFramebufferObject(int width, int height, GLenum target = GL_TEXTURE_2D);
42
43 QOpenGLFramebufferObject(const QSize &size, Attachment attachment,
44 GLenum target = GL_TEXTURE_2D, GLenum internalFormat = 0);
45 QOpenGLFramebufferObject(int width, int height, Attachment attachment,
46 GLenum target = GL_TEXTURE_2D, GLenum internalFormat = 0);
47
48 QOpenGLFramebufferObject(const QSize &size, const QOpenGLFramebufferObjectFormat &format);
49 QOpenGLFramebufferObject(int width, int height, const QOpenGLFramebufferObjectFormat &format);
50
51 virtual ~QOpenGLFramebufferObject();
52
53 void addColorAttachment(const QSize &size, GLenum internalFormat = 0);
54 void addColorAttachment(int width, int height, GLenum internalFormat = 0);
55
56 QOpenGLFramebufferObjectFormat format() const;
57
58 bool isValid() const;
59 bool isBound() const;
60 bool bind();
61 bool release();
62
63 int width() const { return size().width(); }
64 int height() const { return size().height(); }
65
66 GLuint texture() const;
67 QList<GLuint> textures() const;
68
70 GLuint takeTexture(int colorAttachmentIndex);
71
72 QSize size() const;
73 QList<QSize> sizes() const;
74
75 QImage toImage(bool flipped = true) const;
76 QImage toImage(bool flipped, int colorAttachmentIndex) const;
77
78 Attachment attachment() const;
79 void setAttachment(Attachment attachment);
80
81 GLuint handle() const;
82
83 static bool bindDefault();
84
85 static bool hasOpenGLFramebufferObjects();
86
87 static bool hasOpenGLFramebufferBlit();
88
94
95 static void blitFramebuffer(QOpenGLFramebufferObject *target, const QRect &targetRect,
96 QOpenGLFramebufferObject *source, const QRect &sourceRect,
97 GLbitfield buffers,
98 GLenum filter,
99 int readColorAttachmentIndex,
100 int drawColorAttachmentIndex,
101 FramebufferRestorePolicy restorePolicy);
102 static void blitFramebuffer(QOpenGLFramebufferObject *target, const QRect &targetRect,
103 QOpenGLFramebufferObject *source, const QRect &sourceRect,
104 GLbitfield buffers,
105 GLenum filter,
106 int readColorAttachmentIndex,
107 int drawColorAttachmentIndex);
108 static void blitFramebuffer(QOpenGLFramebufferObject *target, const QRect &targetRect,
109 QOpenGLFramebufferObject *source, const QRect &sourceRect,
110 GLbitfield buffers = GL_COLOR_BUFFER_BIT,
111 GLenum filter = GL_NEAREST);
112 static void blitFramebuffer(QOpenGLFramebufferObject *target,
113 QOpenGLFramebufferObject *source,
114 GLbitfield buffers = GL_COLOR_BUFFER_BIT,
115 GLenum filter = GL_NEAREST);
116
117private:
118 Q_DISABLE_COPY(QOpenGLFramebufferObject)
119 QScopedPointer<QOpenGLFramebufferObjectPrivate> d_ptr;
120 friend class QOpenGLPaintDevice;
122};
123
126{
127public:
128 QOpenGLFramebufferObjectFormat();
129 QOpenGLFramebufferObjectFormat(const QOpenGLFramebufferObjectFormat &other);
130 QOpenGLFramebufferObjectFormat &operator=(const QOpenGLFramebufferObjectFormat &other);
131 ~QOpenGLFramebufferObjectFormat();
132
133 void setSamples(int samples);
134 int samples() const;
135
136 void setMipmap(bool enabled);
137 bool mipmap() const;
138
139 void setAttachment(QOpenGLFramebufferObject::Attachment attachment);
140 QOpenGLFramebufferObject::Attachment attachment() const;
141
142 void setTextureTarget(GLenum target);
143 GLenum textureTarget() const;
144
145 void setInternalTextureFormat(GLenum internalTextureFormat);
146 GLenum internalTextureFormat() const;
147
148 bool operator==(const QOpenGLFramebufferObjectFormat& other) const;
149 bool operator!=(const QOpenGLFramebufferObjectFormat& other) const;
150
151private:
152 QOpenGLFramebufferObjectFormatPrivate *d;
153
154 void detach();
155};
156
157QT_END_NAMESPACE
158
159#endif // QOPENGLFRAMEBUFFEROBJECT_H
QByteArray format() const
Returns the format QImageReader uses for reading images.
QSize size() const
Returns the size of the image, without actually reading the image contents.
The QOpenGLFramebufferObjectFormat class specifies the format of an OpenGL framebuffer object.
bool checkFramebufferStatus(QOpenGLContext *ctx) const
The QOpenGLFramebufferObject class encapsulates an OpenGL framebuffer object.
Attachment attachment() const
Returns the status of the depth and stencil buffers attached to this framebuffer object.
QImage toImage(bool flipped, int colorAttachmentIndex) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
static void blitFramebuffer(QOpenGLFramebufferObject *target, const QRect &targetRect, QOpenGLFramebufferObject *source, const QRect &sourceRect, GLbitfield buffers, GLenum filter, int readColorAttachmentIndex, int drawColorAttachmentIndex, FramebufferRestorePolicy restorePolicy)
QOpenGLFramebufferObject(int width, int height, GLenum target=GL_TEXTURE_2D)
Constructs an OpenGL framebuffer object and binds a 2D OpenGL texture to the buffer of the given widt...
static bool bindDefault()
Switches rendering back to the default, windowing system provided framebuffer.
void setAttachment(Attachment attachment)
Sets the attachments of the framebuffer object to attachment.
GLuint takeTexture()
Returns the texture id for the texture attached to this framebuffer object.
QOpenGLFramebufferObject(const QSize &size, Attachment attachment, GLenum target=GL_TEXTURE_2D, GLenum internalFormat=0)
Constructs an OpenGL framebuffer object and binds a texture to the buffer of the given size.
GLuint takeTexture(int colorAttachmentIndex)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static bool hasOpenGLFramebufferBlit()
Returns true if the OpenGL {GL_EXT_framebuffer_blit} extension is present on this system; otherwise r...
void addColorAttachment(const QSize &size, GLenum internalFormat=0)
Creates and attaches an additional texture or renderbuffer of size width and height.
QOpenGLFramebufferObject(int width, int height, Attachment attachment, GLenum target=GL_TEXTURE_2D, GLenum internalFormat=0)
Constructs an OpenGL framebuffer object and binds a texture to the buffer of the given width and heig...
bool release()
Switches rendering back to the default, windowing system provided framebuffer.
QOpenGLFramebufferObject(const QSize &size, GLenum target=GL_TEXTURE_2D)
Constructs an OpenGL framebuffer object and binds a 2D OpenGL texture to the buffer of the size size.
bool isBound() const
Returns true if the framebuffer object is currently bound to the current context, otherwise false is ...
QImage toImage(bool flipped=true) const
Returns the contents of this framebuffer object as a QImage.
QOpenGLFramebufferObject(int width, int height, const QOpenGLFramebufferObjectFormat &format)
Constructs an OpenGL framebuffer object of the given width and height based on the supplied format.
static bool hasOpenGLFramebufferObjects()
Returns true if the OpenGL {GL_EXT_framebuffer_object} extension is present on this system; otherwise...
GLuint texture() const
Returns the texture id for the texture attached as the default rendering target in this framebuffer o...
QList< GLuint > textures() const
Returns the texture id for all attached textures.
void addColorAttachment(int width, int height, GLenum internalFormat=0)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool bind()
Switches rendering from the default, windowing system provided framebuffer to this framebuffer object...
QOpenGLFramebufferObject(const QSize &size, const QOpenGLFramebufferObjectFormat &format)
Constructs an OpenGL framebuffer object of the given size based on the supplied format.
qreal width() const
Returns the width of the generated outlines.
HKEY handle() const
bool isValid() const
Combined button and popup list for selecting options.
Q_TRACE_METADATA(qtcore, "ENUM { AUTO, RANGE User ... MaxUser } QEvent::Type;")
#define GL_CONTEXT_LOST
Definition qopengl.cpp:30
#define GL_RENDERBUFFER_SAMPLES
#define GL_DEPTH24_STENCIL8
#define GL_RGBA16F
Definition qopenglext.h:913
#define GL_RGB16F
Definition qopenglext.h:914
#define GL_BGRA
Definition qopenglext.h:97
#define GL_DRAW_FRAMEBUFFER
#define GL_MAX_SAMPLES
#define GL_HALF_FLOAT
#define GL_READ_FRAMEBUFFER
#define GL_RGBA32F
Definition qopenglext.h:911
#define GL_DEPTH_COMPONENT24
Definition qopenglext.h:329
#define GL_RGB32F
Definition qopenglext.h:912
#define GL_UNSIGNED_INT_8_8_8_8_REV
Definition qopenglext.h:94
#define GL_RGB10
#define GL_RGB16
#define QT_RESET_GLERROR()
#define GL_RGB8
#define QT_CHECK_GLERROR()
Q_TRACE_PARAM_REPLACE(GLenum, int)
#define GL_RGBA16
#define GL_UNSIGNED_INT_2_10_10_10_REV
#define GL_RGBA8
QFixed height() const