4#ifndef QOPENGLFRAMEBUFFEROBJECT_P_H
5#define QOPENGLFRAMEBUFFEROBJECT_P_H
18#include <QtCore/qvarlengtharray.h>
19#include <qopenglframebufferobject.h>
20#include <private/qopenglcontext_p.h>
21#include <private/qopenglextensions_p.h>
35#if !QT_CONFIG(opengles2)
39 QOpenGLContext *ctx = QOpenGLContext::currentContext();
40 const bool isES = ctx ? ctx->isOpenGLES() : QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL;
41 internal_format = isES ? GL_RGBA : GL_RGBA8;
43 internal_format = GL_RGBA;
58 return samples == other->samples &&
59 attachment == other->attachment &&
60 target == other->target &&
61 internal_format == other->internal_format &&
62 mipmap == other->mipmap;
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);
95 QOpenGLFramebufferObjectFormat
format;
111 inline GLuint fbo()
const {
return fbo_guard ? fbo_guard->id() : 0; }
114Q_OPENGL_EXPORT
QImage qt_gl_read_framebuffer(
const QSize &size,
bool alpha_format,
bool include_alpha);
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.
bool checkFramebufferStatus(QOpenGLContext *ctx) const
void initDepthStencilAttachments(QOpenGLContext *ctx, QOpenGLFramebufferObject::Attachment attachment)
QOpenGLSharedResourceGuard * fbo_guard
QOpenGLFramebufferObjectPrivate()
~QOpenGLFramebufferObjectPrivate()
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)
void initTexture(int idx)
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)
QList< QSize > sizes() const
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.
@ RestoreFramebufferBindingToDefault
@ RestoreFrameBufferBinding
@ DontRestoreFramebufferBinding
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 ...
friend class QOpenGLFBOGLPaintDevice
QImage toImage(bool flipped=true) const
Returns the contents of this framebuffer object as a QImage.
friend class QOpenGLPaintDevice
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.
Combined button and popup list for selecting options.
Q_TRACE_METADATA(qtcore, "ENUM { AUTO, RANGE User ... MaxUser } QEvent::Type;")
#define GL_RENDERBUFFER_SAMPLES
#define GL_DEPTH24_STENCIL8
#define GL_DRAW_FRAMEBUFFER
#define GL_READ_FRAMEBUFFER
#define GL_DEPTH_COMPONENT24
#define GL_UNSIGNED_INT_8_8_8_8_REV
#define QT_RESET_GLERROR()
#define QT_CHECK_GLERROR()
Q_TRACE_PARAM_REPLACE(GLenum, int)
QOpenGLSharedResourceGuard * guard
ColorAttachment(const QSize &size, GLenum internalFormat)