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_p.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_P_H
5#define QOPENGLFRAMEBUFFEROBJECT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qvarlengtharray.h>
19#include <qopenglframebufferobject.h>
20#include <private/qopenglcontext_p.h>
21#include <private/qopenglextensions_p.h>
22
24
26{
27public:
29 : ref(1),
30 samples(0),
33 mipmap(false)
34 {
35#if !QT_CONFIG(opengles2)
36 // There is nothing that says QOpenGLFramebufferObjectFormat needs a current
37 // context, so we need a fallback just to be safe, even though in practice there
38 // will usually be a current context.
39 QOpenGLContext *ctx = QOpenGLContext::currentContext();
40 const bool isES = ctx ? ctx->isOpenGLES() : QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL;
41 internal_format = isES ? GL_RGBA : GL_RGBA8;
42#else
43 internal_format = GL_RGBA;
44#endif
45 }
57 {
58 return samples == other->samples &&
59 attachment == other->attachment &&
60 target == other->target &&
61 internal_format == other->internal_format &&
62 mipmap == other->mipmap;
63 }
64
71};
72
74{
75public:
77 , stencil_buffer_guard(nullptr)
78 , valid(false) {}
80
81 void init(QOpenGLFramebufferObject *q, const QSize &size,
82 QOpenGLFramebufferObject::Attachment attachment,
83 GLenum texture_target, GLenum internal_format,
84 GLint samples = 0, bool mipmap = false);
85 void initTexture(int idx);
86 void initColorBuffer(int idx, GLint *samples);
87 void initDepthStencilAttachments(QOpenGLContext *ctx, QOpenGLFramebufferObject::Attachment attachment);
88
89 bool checkFramebufferStatus(QOpenGLContext *ctx) const;
95 QOpenGLFramebufferObjectFormat format;
100
110
111 inline GLuint fbo() const { return fbo_guard ? fbo_guard->id() : 0; }
112};
113
114Q_OPENGL_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
115
116QT_END_NAMESPACE
117
118#endif // QOPENGLFRAMEBUFFEROBJECT_P_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.
\inmodule QtGui
Definition qimage.h:37
bool equals(const QOpenGLFramebufferObjectFormatPrivate *other)
QOpenGLFramebufferObjectFormatPrivate(const QOpenGLFramebufferObjectFormatPrivate *other)
The QOpenGLFramebufferObjectFormat class specifies the format of an OpenGL framebuffer object.
bool checkFramebufferStatus(QOpenGLContext *ctx) const
void initDepthStencilAttachments(QOpenGLContext *ctx, QOpenGLFramebufferObject::Attachment attachment)
QOpenGLSharedResourceGuard * fbo_guard
void init(QOpenGLFramebufferObject *q, const QSize &size, QOpenGLFramebufferObject::Attachment attachment, GLenum texture_target, GLenum internal_format, GLint samples=0, bool mipmap=false)
void initColorBuffer(int idx, GLint *samples)
QOpenGLFramebufferObjectFormat format
QOpenGLSharedResourceGuard * depth_buffer_guard
QVarLengthArray< ColorAttachment, 8 > colorAttachments
QOpenGLSharedResourceGuard * stencil_buffer_guard
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
ColorAttachment(const QSize &size, GLenum internalFormat)
QFixed height() const