4#ifndef QOPENGLFRAMEBUFFEROBJECT_H
5#define QOPENGLFRAMEBUFFEROBJECT_H
7#include <QtOpenGL/qtopenglglobal.h>
9#include <QtGui/qopengl.h>
10#include <QtGui/qpaintdevice.h>
12#include <QtCore/qscopedpointer.h>
16typedef unsigned int GLuint;
18typedef unsigned int GLenum;
20#define GL_TEXTURE_2D 0x0DE1
22typedef unsigned int GLbitfield;
27class QOpenGLFramebufferObjectPrivate;
28class QOpenGLFramebufferObjectFormat;
32 Q_DECLARE_PRIVATE(QOpenGLFramebufferObject)
51 virtual ~QOpenGLFramebufferObject();
56 QOpenGLFramebufferObjectFormat
format()
const;
63 int width()
const {
return size().width(); }
64 int height()
const {
return size().height(); }
95 static void blitFramebuffer(QOpenGLFramebufferObject *target,
const QRect &targetRect,
96 QOpenGLFramebufferObject *source,
const QRect &sourceRect,
99 int readColorAttachmentIndex,
100 int drawColorAttachmentIndex,
101 FramebufferRestorePolicy restorePolicy);
102 static void blitFramebuffer(QOpenGLFramebufferObject *target,
const QRect &targetRect,
103 QOpenGLFramebufferObject *source,
const QRect &sourceRect,
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);
113 QOpenGLFramebufferObject *source,
114 GLbitfield buffers = GL_COLOR_BUFFER_BIT,
115 GLenum filter = GL_NEAREST);
118 Q_DISABLE_COPY(QOpenGLFramebufferObject)
119 QScopedPointer<QOpenGLFramebufferObjectPrivate> d_ptr;
128 QOpenGLFramebufferObjectFormat();
129 QOpenGLFramebufferObjectFormat(
const QOpenGLFramebufferObjectFormat &other);
130 QOpenGLFramebufferObjectFormat &operator=(
const QOpenGLFramebufferObjectFormat &other);
131 ~QOpenGLFramebufferObjectFormat();
133 void setSamples(
int samples);
136 void setMipmap(
bool enabled);
139 void setAttachment(QOpenGLFramebufferObject::Attachment attachment);
140 QOpenGLFramebufferObject::Attachment attachment()
const;
142 void setTextureTarget(GLenum target);
143 GLenum textureTarget()
const;
145 void setInternalTextureFormat(GLenum internalTextureFormat);
146 GLenum internalTextureFormat()
const;
148 bool operator==(
const QOpenGLFramebufferObjectFormat& other)
const;
149 bool operator!=(
const QOpenGLFramebufferObjectFormat& other)
const;
152 QOpenGLFramebufferObjectFormatPrivate *d;
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
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)