From 5fff965369168bc3db164b33ecf6973059567e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 1 Sep 2009 17:37:45 +0200 Subject: Fixed issues with using GLenum in public API on mac. The type of GLenum was changed between 10.4 and 10.5, so to support compiling on one and deploying on the other we need this hack. Also get rid of the complex QGLFramebufferObjectFormat constructor in favor of a simple default constructor and setters, which is more Qt-ish anyway, and avoids ambiguities on mac. Reviewed-by: Trond --- src/opengl/qglframebufferobject.cpp | 72 +++++++++++++++++++++---------------- src/opengl/qglframebufferobject.h | 18 ++++------ src/opengl/qglpixmapfilter.cpp | 2 +- src/opengl/qpixmapdata_gl.cpp | 2 +- src/opengl/qwindowsurface_gl.cpp | 2 +- 5 files changed, 50 insertions(+), 46 deletions(-) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 427aab3..a03e627 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -109,38 +109,28 @@ public: */ /*! - Creates a QGLFramebufferObjectFormat object with properties specifying + Creates a QGLFramebufferObjectFormat object for specifying the format of an OpenGL framebuffer object. - A multisample framebuffer object is specified by setting \a samples - to a value different from zero. If the desired amount of samples per pixel is - not supported by the hardware then the maximum number of samples per pixel - will be used. Note that multisample framebuffer objects can not be bound as - textures. Also, the \c{GL_EXT_framebuffer_multisample} extension is required - to create a framebuffer with more than one sample per pixel. - - For multisample framebuffer objects a color render buffer is created, - otherwise a texture with the texture target \a target is created. - The color render buffer or texture will have the internal format - \a internalFormat, and will be bound to the \c GL_COLOR_ATTACHMENT0 - attachment in the framebuffer object. - - The \a attachment parameter describes the depth/stencil buffer - configuration. + By default the format specifies a non-multisample framebuffer object with no + attachments, texture target \c GL_TEXTURE_2D, and internal format \c GL_RGBA8. \sa samples(), attachment(), target(), internalFormat() */ -QGLFramebufferObjectFormat::QGLFramebufferObjectFormat(int samples, - QGLFramebufferObject::Attachment attachment, - GLenum target, - GLenum internalFormat) +#ifndef QT_OPENGL_ES +#define DEFAULT_FORMAT GL_RGBA8 +#else +#define DEFAULT_FORMAT GL_RGBA +#endif + +QGLFramebufferObjectFormat::QGLFramebufferObjectFormat() { d = new QGLFramebufferObjectFormatPrivate; - d->samples = samples; - d->attachment = attachment; - d->target = target; - d->internal_format = internalFormat; + d->samples = 0; + d->attachment = QGLFramebufferObject::NoAttachment; + d->target = GL_TEXTURE_2D; + d->internal_format = DEFAULT_FORMAT; } /*! @@ -176,6 +166,12 @@ QGLFramebufferObjectFormat::~QGLFramebufferObjectFormat() to \a samples. A sample count of 0 represents a regular non-multisample framebuffer object. + If the desired amount of samples per pixel is not supported by the hardware + then the maximum number of samples per pixel will be used. Note that + multisample framebuffer objects can not be bound as textures. Also, the + \c{GL_EXT_framebuffer_multisample} extension is required to create a + framebuffer with more than one sample per pixel. + \sa samples() */ void QGLFramebufferObjectFormat::setSamples(int samples) @@ -195,7 +191,7 @@ int QGLFramebufferObjectFormat::samples() const } /*! - Sets the attachments a framebuffer object should have to \a attachment. + Sets the attachment configuration of a framebuffer object to \a attachment. \sa attachment() */ @@ -259,6 +255,20 @@ GLenum QGLFramebufferObjectFormat::internalFormat() const return d->internal_format; } +#ifdef Q_MAC_COMPAT_GL_FUNCTIONS +/*! \internal */ +void QGLFramebufferObjectFormat::setTextureTarget(QMacCompatGLenum target) +{ + d->target = target; +} + +/*! \internal */ +void QGLFramebufferObjectFormat::setInternalFormat(QMacCompatGLenum internalFormat) +{ + d->internal_format = internalFormat; +} +#endif + class QGLFramebufferObjectPrivate { public: @@ -526,6 +536,12 @@ void QGLFramebufferObjectPrivate::init(const QSize &sz, QGLFramebufferObject::At the constructors that take a QGLFramebufferObject parameter, and set the QGLFramebufferObject::samples() property to a non-zero value. + For multisample framebuffer objects a color render buffer is created, + otherwise a texture with the specified texture target is created. + The color render buffer or texture will have the specified internal + format, and will be bound to the \c GL_COLOR_ATTACHMENT0 + attachment in the framebuffer object. + If you want to use a framebuffer object with multisampling enabled as a texture, you first need to copy from it to a regular framebuffer object using QGLContext::blitFramebuffer(). @@ -579,12 +595,6 @@ void QGLFramebufferObjectPrivate::init(const QSize &sz, QGLFramebufferObject::At \sa size(), texture(), attachment() */ -#ifndef QT_OPENGL_ES -#define DEFAULT_FORMAT GL_RGBA8 -#else -#define DEFAULT_FORMAT GL_RGBA -#endif - QGLFramebufferObject::QGLFramebufferObject(const QSize &size, GLenum target) : d_ptr(new QGLFramebufferObjectPrivate) { diff --git a/src/opengl/qglframebufferobject.h b/src/opengl/qglframebufferobject.h index cfc824b..ad14e50 100644 --- a/src/opengl/qglframebufferobject.h +++ b/src/opengl/qglframebufferobject.h @@ -137,18 +137,7 @@ class QGLFramebufferObjectFormatPrivate; class Q_OPENGL_EXPORT QGLFramebufferObjectFormat { public: -#if !defined(QT_OPENGL_ES) || defined(Q_QDOC) - QGLFramebufferObjectFormat(int samples = 0, - QGLFramebufferObject::Attachment attachment = QGLFramebufferObject::NoAttachment, - GLenum target = GL_TEXTURE_2D, - GLenum internalFormat = GL_RGBA8); -#else - QGLFramebufferObjectFormat(int samples = 0, - QGLFramebufferObject::Attachment attachment = QGLFramebufferObject::NoAttachment, - GLenum target = GL_TEXTURE_2D, - GLenum internalFormat = GL_RGBA); -#endif - + QGLFramebufferObjectFormat(); QGLFramebufferObjectFormat(const QGLFramebufferObjectFormat &other); QGLFramebufferObjectFormat &operator=(const QGLFramebufferObjectFormat &other); ~QGLFramebufferObjectFormat(); @@ -165,6 +154,11 @@ public: void setInternalFormat(GLenum internalFormat); GLenum internalFormat() const; +#ifdef Q_MAC_COMPAT_GL_FUNCTIONS + void setTextureTarget(QMacCompatGLenum target); + void setInternalFormat(QMacCompatGLenum internalFormat); +#endif + private: QGLFramebufferObjectFormatPrivate *d; }; diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index c51ccc7..56e5baa 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -324,7 +324,7 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const filter->setSource(generateBlurShader(radius(), quality() == Qt::SmoothTransformation)); QGLFramebufferObjectFormat format; - format.setInternalFormat(src.hasAlphaChannel() ? GL_RGBA : GL_RGB); + format.setInternalFormat(GLenum(src.hasAlphaChannel() ? GL_RGBA : GL_RGB)); QGLFramebufferObject *fbo = qgl_fbo_pool()->acquire(src.size(), format); if (!fbo) diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index 5e87e96..b6f5012 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -467,7 +467,7 @@ QPaintEngine* QGLPixmapData::paintEngine() const QGLFramebufferObjectFormat format; format.setAttachment(QGLFramebufferObject::CombinedDepthStencil); format.setSamples(4); - format.setInternalFormat(m_hasAlpha ? GL_RGBA : GL_RGB); + format.setInternalFormat(GLenum(m_hasAlpha ? GL_RGBA : GL_RGB)); m_renderFbo = qgl_fbo_pool()->acquire(size(), format); diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index a59501c..f974938 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -569,7 +569,7 @@ void QGLWindowSurface::updateGeometry() QGLFramebufferObjectFormat format; format.setAttachment(QGLFramebufferObject::CombinedDepthStencil); - format.setInternalFormat(GL_RGBA); + format.setInternalFormat(GLenum(GL_RGBA)); format.setTextureTarget(target); if (QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit) -- cgit v0.12