diff options
Diffstat (limited to 'src/threed/surfaces')
19 files changed, 0 insertions, 2250 deletions
diff --git a/src/threed/surfaces/qglabstractsurface.cpp b/src/threed/surfaces/qglabstractsurface.cpp deleted file mode 100644 index 9e2bf216..00000000 --- a/src/threed/surfaces/qglabstractsurface.cpp +++ /dev/null @@ -1,318 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglabstractsurface.h" -#include "qglcontextsurface_p.h" -#include "qglframebufferobjectsurface.h" -#include "qglpixelbuffersurface.h" -#include "qglsubsurface.h" -#include "qglwidgetsurface.h" -#include <QtGui/qpaintdevice.h> - -QT_BEGIN_NAMESPACE - -/*! - \class QGLAbstractSurface - \brief The QGLAbstractSurface class represents an OpenGL drawing surface. - \since 4.8 - \ingroup qt3d - \ingroup qt3d::painting - - OpenGL can be used to draw into a number of different surface types: - windows, pixel buffers (pbuffers), framebuffer objects, and so on. - It is also possible to use only part of a surface by setting - the \c{glViewport()} to restrict drawing to that part. An example - of a subsurface may be the left or right eye image of a stereoscopic - pair that is rendered into the two halves of a window. - - Activating a surface for OpenGL drawing, and deactivating it afterwards - can be quite varied across surface types. Sometimes it is enough - to just make a QGLContext current and set the \c{glViewport()}. - Other times a context must be made current, followed by binding a - framebuffer object, and finally setting the \c{glViewport()}. - - QGLAbstractSurface and its subclasses simplify the activation and - deactivation of surfaces by encapsulating the logic needed to - use a particular kind of surface into activate() and deactivate() - respectively. - - Normally surfaces are activated by calling QGLPainter::pushSurface() - as in the following example of switching drawing to a framebuffer - object: - - \code - QGLPainter painter; - painter.begin(widget); - QGLFramebufferObjectSurface surface(fbo); - painter.pushSurface(&surface); - ... // draw into the fbo - painter.popSurface(); - ... // draw into the widget - \endcode - - QGLPainter maintains a stack of surfaces, starting with the paint - device specified to QGLPainter::begin() (usually a widget). - The QGLPainter::pushSurface() function calls deactivate() on the - current surface, activate() on the new surface, and then adjusts the - \c{glViewport()} to match the value of viewportGL() for the new surface. - When QGLPainter::popSurface() is called, the previous surface - is re-activated and the \c{glViewport()} changed accordingly. - - \sa QGLFramebufferObjectSurface, QGLWidgetSurface, QGLSubsurface - \sa QGLPixelBufferSurface, QGLPainter::pushSurface() -*/ - -/*! - \enum QGLAbstractSurface::SurfaceType - This enum defines the type of a QGLAbstractSurface. - - \value Widget Instance of QGLWidgetSurface. - \value FramebufferObject Instance of QGLFramebufferObjectSurface. - \value PixelBuffer Instance of QGLPixelBufferSurface. - \value Subsurface Instance of QGLSubsurface. - \value User First user-defined surface type for use by applications. -*/ - -/*! - \fn QGLAbstractSurface::QGLAbstractSurface(int surfaceType) - - Constructs an OpenGL drawing surface of the specified \a surfaceType. -*/ - -/*! - Destroys this OpenGL drawing surface. -*/ -QGLAbstractSurface::~QGLAbstractSurface() -{ -} - -/*! - \fn int QGLAbstractSurface::surfaceType() const - - Returns the type of this surface. -*/ - -/*! - \fn QPaintDevice *QGLAbstractSurface::device() const - - Returns the raw device that this surface will draw on. - - If the surface is an instance of QGLSubsurface, then this will - return the device of the surface that underlies the subsurface. - The viewportRect() defines the region to render into. - - \sa viewportRect() -*/ - -/*! - \fn bool QGLAbstractSurface::activate(QGLAbstractSurface *prevSurface) - - Activate this surface by making its context current, and binding - the associated framebuffer object, if any. - - If \a prevSurface is null, then that surface has just been deactivated - in the process of switching to this surface. This may allow activate() - to optimize the transition to avoid unnecessary state changes. - - Returns true if the surface was activated; false otherwise. - - \sa deactivate(), switchTo() -*/ - -/*! - \fn void QGLAbstractSurface::deactivate(QGLAbstractSurface *nextSurface) - - Deactivate this surface from the current context, but leave the - context current. Typically this will release the framebuffer - object associated with the surface. - - If \a nextSurface is null, then that surface will be activated next - in the process of switching away from this surface. This may allow - deactivate() to optimize the transition to avoid unnecessary state - changes. - - \sa activate(), switchTo() -*/ - -/*! - Returns the rectangle of the surface device() that is occupied by - the viewport for this surface. The origin is at the top-left. - - This function calls viewportGL() and then flips the rectangle - upside down using the height of device() so that the origin - is at the top-left instead of the bottom-right. - - \sa viewportGL(), device() -*/ -QRect QGLAbstractSurface::viewportRect() const -{ - QRect view = viewportGL(); - QPaintDevice *dev = device(); - int height; - if (dev->devType() == QInternal::Widget) - height = static_cast<QWidget *>(dev)->height(); - else - height = dev->height(); - return QRect(view.x(), height - (view.y() + view.height()), - view.width(), view.height()); -} - -/*! - \fn QRect QGLAbstractSurface::viewportGL() const - - Returns the rectangle of the surface device() that is occupied by - the viewport for this surface. The origin is at the bottom-left, - which makes the value suitable for passing to \c{glViewport()}: - - \code - QRect viewport = surface->viewportGL(); - glViewport(viewport.x(), viewport.y(), viewport.width(), viewport.height()); - \endcode - - Normally the viewport rectangle is the full extent of the device(), - but it could be smaller if the application only wishes to draw - into a subpart of the device(). An example would be rendering left - and right stereo eye images into the two halves of a QGLWidget. - The eye surfaces would typically be instances of QGLSubsurface. - - \sa viewportRect(), device() -*/ - -/*! - Returns the aspect ratio of viewportGL() after correcting for the - DPI of device(). - - The return value is used to correct perspective and orthographic - projections for the aspect ratio of the drawing surface. Subclasses - may override this function to adjust the return value if the DPI of - device() is not sufficient to determine the aspect ratio. -*/ -qreal QGLAbstractSurface::aspectRatio() const -{ - // Get the size of the current viewport. - QSize size = viewportGL().size(); - if (size.width() == 0 || size.height() == 0 || - size.width() == size.height()) - return 1.0f; - - // Use the device's DPI setting to determine the pixel aspect ratio. - QPaintDevice *device = this->device(); - int dpiX = device->logicalDpiX(); - int dpiY = device->logicalDpiY(); - if (dpiX <= 0 || dpiY <= 0) - dpiX = dpiY = 1; - - // Return the final aspect ratio based on viewport and pixel size. - return ((qreal)(size.width() * dpiY)) / ((qreal)(size.height() * dpiX)); -} - -/*! - Switches from this surface to \a nextSurface by calling deactivate() - on this surface and activate() on \a nextSurface. - - Returns true if \a nextSurface was activated, or false otherwise. - If \a nextSurface could not be activated, then this surface will - remain activated. - - \sa activate(), deactivate() -*/ -bool QGLAbstractSurface::switchTo(QGLAbstractSurface *nextSurface) -{ - if (nextSurface) { - deactivate(nextSurface); - if (nextSurface->activate(this)) - return true; - activate(); - return false; - } else { - deactivate(); - return true; - } -} - -/*! - Creates an OpenGL drawing surface for the specified paint \a device. - Returns null if it is not possible to create a surface for \a device. - - \sa createSurfaceForContext() -*/ -QGLAbstractSurface *QGLAbstractSurface::createSurfaceForDevice - (QPaintDevice *device) -{ - Q_ASSERT(device); - switch (device->devType()) { - case QInternal::Widget: { - QGLWidget *glw = qobject_cast<QGLWidget *> - (static_cast<QWidget *>(device)); - if (glw) - return new QGLWidgetSurface(glw); - else - return 0; - } - case QInternal::Pbuffer: - return new QGLPixelBufferSurface(static_cast<QGLPixelBuffer *>(device)); - case QInternal::FramebufferObject: - return new QGLFramebufferObjectSurface - (static_cast<QGLFramebufferObject *>(device)); - default: - return 0; - } -} - -/*! - Creates an OpenGL drawing surface for the paint device - underlying \a context. If the paint device is not recognized, - then a generic surface will be created that makes \a context - current when the surface is activated. - - \sa createSurfaceForDevice() -*/ -QGLAbstractSurface *QGLAbstractSurface::createSurfaceForContext - (const QGLContext *context) -{ - Q_ASSERT(context); - QGLAbstractSurface *surface = createSurfaceForDevice(context->device()); - if (!surface) - surface = new QGLContextSurface(context); - return surface; -} - -QT_END_NAMESPACE diff --git a/src/threed/surfaces/qglabstractsurface.h b/src/threed/surfaces/qglabstractsurface.h deleted file mode 100644 index 715abb47..00000000 --- a/src/threed/surfaces/qglabstractsurface.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLABSTRACTSURFACE_H -#define QGLABSTRACTSURFACE_H - -#include "qt3dglobal.h" -#include <QtOpenGL/qgl.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Qt3D) - -class Q_QT3D_EXPORT QGLAbstractSurface -{ -public: - virtual ~QGLAbstractSurface(); - - enum SurfaceType - { - Widget, - FramebufferObject, - PixelBuffer, - Subsurface, - User = 1000 - }; - - int surfaceType() const { return m_type; } - - virtual QPaintDevice *device() const = 0; - virtual bool activate(QGLAbstractSurface *prevSurface = 0) = 0; - virtual void deactivate(QGLAbstractSurface *nextSurface = 0) = 0; - virtual QRect viewportGL() const = 0; - QRect viewportRect() const; - virtual qreal aspectRatio() const; - - bool switchTo(QGLAbstractSurface *nextSurface); - - static QGLAbstractSurface *createSurfaceForDevice(QPaintDevice *device); - static QGLAbstractSurface *createSurfaceForContext(const QGLContext *context); - -protected: - QGLAbstractSurface(int surfaceType) : m_type(surfaceType) {} - -private: - int m_type; - - Q_DISABLE_COPY(QGLAbstractSurface) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/threed/surfaces/qglcontextsurface.cpp b/src/threed/surfaces/qglcontextsurface.cpp deleted file mode 100644 index 98a96f36..00000000 --- a/src/threed/surfaces/qglcontextsurface.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglcontextsurface_p.h" - -QT_BEGIN_NAMESPACE - -QPaintDevice *QGLContextSurface::device() const -{ - return m_context->device(); -} - -bool QGLContextSurface::activate(QGLAbstractSurface *prevSurface) -{ - Q_UNUSED(prevSurface); - if (QGLContext::currentContext() != m_context) - const_cast<QGLContext *>(m_context)->makeCurrent(); - return true; -} - -void QGLContextSurface::deactivate(QGLAbstractSurface *nextSurface) -{ - Q_UNUSED(nextSurface); -} - -QRect QGLContextSurface::viewportGL() const -{ - QPaintDevice *device = m_context->device(); - return QRect(0, 0, device->width(), device->height()); -} - -QT_END_NAMESPACE diff --git a/src/threed/surfaces/qglcontextsurface_p.h b/src/threed/surfaces/qglcontextsurface_p.h deleted file mode 100644 index 6c1a8beb..00000000 --- a/src/threed/surfaces/qglcontextsurface_p.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLCONTEXTSURFACE_P_H -#define QGLCONTEXTSURFACE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qglabstractsurface.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGLContextSurface : public QGLAbstractSurface -{ -public: - explicit QGLContextSurface(const QGLContext *context) - : QGLAbstractSurface(502) - , m_context(context) {} - ~QGLContextSurface() {} - - QPaintDevice *device() const; - bool activate(QGLAbstractSurface *prevSurface); - void deactivate(QGLAbstractSurface *nextSurface); - QRect viewportGL() const; - -private: - const QGLContext *m_context; - - Q_DISABLE_COPY(QGLContextSurface) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/threed/surfaces/qgldrawbuffersurface.cpp b/src/threed/surfaces/qgldrawbuffersurface.cpp deleted file mode 100644 index 11aaa610..00000000 --- a/src/threed/surfaces/qgldrawbuffersurface.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgldrawbuffersurface_p.h" - -QT_BEGIN_NAMESPACE - -QPaintDevice *QGLDrawBufferSurface::device() const -{ - return m_surface->device(); -} - -bool QGLDrawBufferSurface::activate(QGLAbstractSurface *prevSurface) -{ - if (!m_surface->activate(prevSurface)) - return false; -#if defined(GL_BACK_LEFT) && defined(GL_BACK_RIGHT) - glDrawBuffer(m_buffer); -#endif - return true; -} - -void QGLDrawBufferSurface::deactivate(QGLAbstractSurface *nextSurface) -{ - m_surface->deactivate(nextSurface); -} - -QRect QGLDrawBufferSurface::viewportGL() const -{ - return m_surface->viewportGL(); -} - -QT_END_NAMESPACE diff --git a/src/threed/surfaces/qgldrawbuffersurface_p.h b/src/threed/surfaces/qgldrawbuffersurface_p.h deleted file mode 100644 index 9fe6c2cc..00000000 --- a/src/threed/surfaces/qgldrawbuffersurface_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLDRAWBUFFERSURFACE_P_H -#define QGLDRAWBUFFERSURFACE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qglabstractsurface.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGLDrawBufferSurface : public QGLAbstractSurface -{ -public: - QGLDrawBufferSurface(QGLAbstractSurface *surface, GLenum buffer) - : QGLAbstractSurface(500) - , m_surface(surface), m_buffer(buffer) {} - ~QGLDrawBufferSurface() {} - - QPaintDevice *device() const; - bool activate(QGLAbstractSurface *prevSurface); - void deactivate(QGLAbstractSurface *nextSurface); - QRect viewportGL() const; - -private: - QGLAbstractSurface *m_surface; - GLenum m_buffer; - - Q_DISABLE_COPY(QGLDrawBufferSurface) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/threed/surfaces/qglframebufferobjectsurface.cpp b/src/threed/surfaces/qglframebufferobjectsurface.cpp deleted file mode 100644 index 99551c26..00000000 --- a/src/threed/surfaces/qglframebufferobjectsurface.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglframebufferobjectsurface.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QGLFramebufferObjectSurface - \brief The QGLFramebufferObjectSurface class represents a framebuffer object that is being used as an OpenGL drawing surface. - \since 4.8 - \ingroup qt3d - \ingroup qt3d::painting -*/ - -class QGLFramebufferObjectSurfacePrivate -{ -public: - QGLFramebufferObjectSurfacePrivate - (QGLFramebufferObject *fbo, const QGLContext *ctx) - : framebufferObject(fbo), context(ctx) {} - - QGLFramebufferObject *framebufferObject; - const QGLContext *context; -}; - -/*! - Constructs a default framebuffer object surface. This constructor - should be followed by a call to setFramebufferObject(). -*/ -QGLFramebufferObjectSurface::QGLFramebufferObjectSurface() - : QGLAbstractSurface(QGLAbstractSurface::FramebufferObject) - , d_ptr(new QGLFramebufferObjectSurfacePrivate(0, 0)) -{ -} - -/*! - Constructs a framebuffer object surface for \a fbo and \a context. - If \a context is null, then the framebuffer will be bound to the - current context when activate() is called. -*/ -QGLFramebufferObjectSurface::QGLFramebufferObjectSurface - (QGLFramebufferObject *fbo, const QGLContext *context) - : QGLAbstractSurface(QGLAbstractSurface::FramebufferObject) - , d_ptr(new QGLFramebufferObjectSurfacePrivate(fbo, context)) -{ -} - -/*! - Destroys this framebuffer object surface. -*/ -QGLFramebufferObjectSurface::~QGLFramebufferObjectSurface() -{ -} - -/*! - Returns the context that owns framebufferObject(); or null - if the framebufferObject() should be assumed to be owned by - the current context when activate() is called. - - \sa setContext(), framebufferObject() -*/ -const QGLContext *QGLFramebufferObjectSurface::context() const -{ - Q_D(const QGLFramebufferObjectSurface); - return d->context; -} - -/*! - Sets the \a context that owns framebufferObject(). - - When activate() is called, it checks to see if \a context is sharing - with the current context. If it is, then the framebufferObject() - is directly bound to the current context. Otherwise, \a context - is made current and then framebufferObject() is bound. - - If \a context is null, then framebufferObject() will be bound - to whatever the current context is when activate() is called. - - \sa context() -*/ -void QGLFramebufferObjectSurface::setContext(const QGLContext *context) -{ - Q_D(QGLFramebufferObjectSurface); - d->context = context; -} - -/*! - Returns the framebuffer object for this surface, or null if - it has not been set yet. - - \sa setFramebufferObject(), context() -*/ -QGLFramebufferObject *QGLFramebufferObjectSurface::framebufferObject() const -{ - Q_D(const QGLFramebufferObjectSurface); - return d->framebufferObject; -} - -/*! - Sets the framebuffer object for this surface to \a fbo. - - \sa framebufferObject() -*/ -void QGLFramebufferObjectSurface::setFramebufferObject - (QGLFramebufferObject *fbo) -{ - Q_D(QGLFramebufferObjectSurface); - d->framebufferObject = fbo; -} - -/*! - \reimp -*/ -QPaintDevice *QGLFramebufferObjectSurface::device() const -{ - Q_D(const QGLFramebufferObjectSurface); - return d->framebufferObject; -} - -/*! - \reimp -*/ -bool QGLFramebufferObjectSurface::activate(QGLAbstractSurface *prevSurface) -{ - Q_UNUSED(prevSurface); - Q_D(QGLFramebufferObjectSurface); - if (d->context) { - if (!QGLContext::areSharing(QGLContext::currentContext(), d->context)) - const_cast<QGLContext *>(d->context)->makeCurrent(); - } else { - // If we don't have a current context, then something is wrong. - Q_ASSERT(QGLContext::currentContext()); - } - if (d->framebufferObject) - return d->framebufferObject->bind(); - return false; -} - -/*! - \reimp -*/ -void QGLFramebufferObjectSurface::deactivate(QGLAbstractSurface *nextSurface) -{ - Q_D(QGLFramebufferObjectSurface); - if (d->framebufferObject) { - if (nextSurface && nextSurface->surfaceType() == FramebufferObject) { - // If we are about to switch to another fbo that is on the - // same context, then don't bother doing the release(). - // This saves an unnecessary glBindFramebuffer(0) call. - if (static_cast<QGLFramebufferObjectSurface *>(nextSurface) - ->context() == d->context) - return; - } - d->framebufferObject->release(); - } -} - -/*! - \reimp -*/ -QRect QGLFramebufferObjectSurface::viewportGL() const -{ - Q_D(const QGLFramebufferObjectSurface); - if (d->framebufferObject) - return QRect(QPoint(0, 0), d->framebufferObject->size()); - else - return QRect(); -} - -QT_END_NAMESPACE diff --git a/src/threed/surfaces/qglframebufferobjectsurface.h b/src/threed/surfaces/qglframebufferobjectsurface.h deleted file mode 100644 index 3135e81f..00000000 --- a/src/threed/surfaces/qglframebufferobjectsurface.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLFRAMEBUFFEROBJECTSURFACE_H -#define QGLFRAMEBUFFEROBJECTSURFACE_H - -#include "qglabstractsurface.h" -#include <QtOpenGL/qglframebufferobject.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Qt3D) - -class QGLFramebufferObjectSurfacePrivate; - -class Q_QT3D_EXPORT QGLFramebufferObjectSurface : public QGLAbstractSurface -{ -public: - QGLFramebufferObjectSurface(); - explicit QGLFramebufferObjectSurface - (QGLFramebufferObject *fbo, const QGLContext *context = 0); - ~QGLFramebufferObjectSurface(); - - const QGLContext *context() const; - void setContext(const QGLContext *context); - - QGLFramebufferObject *framebufferObject() const; - void setFramebufferObject(QGLFramebufferObject *fbo); - - QPaintDevice *device() const; - bool activate(QGLAbstractSurface *prevSurface = 0); - void deactivate(QGLAbstractSurface *nextSurface = 0); - QRect viewportGL() const; - -private: - QScopedPointer<QGLFramebufferObjectSurfacePrivate> d_ptr; - - Q_DECLARE_PRIVATE(QGLFramebufferObjectSurface) - Q_DISABLE_COPY(QGLFramebufferObjectSurface) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/threed/surfaces/qglmaskedsurface.cpp b/src/threed/surfaces/qglmaskedsurface.cpp deleted file mode 100644 index d2d46237..00000000 --- a/src/threed/surfaces/qglmaskedsurface.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglmaskedsurface_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QGLMaskedSurface - \brief The QGLMaskedSurface class represents a masked copy of another OpenGL drawing surface. - \since 4.8 - \ingroup qt3d - \ingroup qt3d::painting - \internal - - Masked surfaces are typically used to render red-cyan anaglyph images - into an underlying surface(). For the left eye image, the mask() - is set to RedMask | AlphaMask. Then for the right eye image, the mask() - is set to GreenMask | BlueMask. -*/ - -/*! - \enum QGLMaskedSurface::BufferMaskBit - This enum defines the channels to mask with QGLMaskedSurface. - - \value RedMask Allow the red channel to be written to the color buffer. - \value GreenMask Allow the green channel to be written to the color buffer. - \value BlueMask Allow the blue channel to be written to the color buffer. - \value AlphaMask Allow the alpha channel to be written to the color buffer. -*/ - -class QGLMaskedSurfacePrivate -{ -public: - QGLMaskedSurfacePrivate - (QGLAbstractSurface *surf = 0, - QGLMaskedSurface::BufferMask msk = QGLMaskedSurface::RedMask | - QGLMaskedSurface::GreenMask | - QGLMaskedSurface::BlueMask | - QGLMaskedSurface::AlphaMask) - : surface(surf), mask(msk) {} - - QGLAbstractSurface *surface; - QGLMaskedSurface::BufferMask mask; -}; - -#define MaskedSurfaceType 501 - -/*! - Constructs a masked OpenGL drawing surface with surface() initially - set to null and mask() initially set to allow all channels to be - written to the color buffer. -*/ -QGLMaskedSurface::QGLMaskedSurface() - : QGLAbstractSurface(MaskedSurfaceType) - , d_ptr(new QGLMaskedSurfacePrivate) -{ -} - -/*! - Constructs a masked OpenGL drawing surface that applies \a mask - to \a surface when activate() is called. -*/ -QGLMaskedSurface::QGLMaskedSurface - (QGLAbstractSurface *surface, QGLMaskedSurface::BufferMask mask) - : QGLAbstractSurface(MaskedSurfaceType) - , d_ptr(new QGLMaskedSurfacePrivate(surface, mask)) -{ -} - -/*! - Destroys this masked OpenGL drawing surface. -*/ -QGLMaskedSurface::~QGLMaskedSurface() -{ -} - -/*! - Returns the underlying surface that mask() will be applied to - when activate() is called. - - \sa setSurface(), mask() -*/ -QGLAbstractSurface *QGLMaskedSurface::surface() const -{ - Q_D(const QGLMaskedSurface); - return d->surface; -} - -/*! - Sets the underlying \a surface that mask() will be applied to - when activate() is called. - - \sa surface(), setMask() -*/ -void QGLMaskedSurface::setSurface(QGLAbstractSurface *surface) -{ - Q_D(QGLMaskedSurface); - d->surface = surface; -} - -/*! - Returns the color mask to apply to surface() when activate() - is called. - - \sa setMask(), surface() -*/ -QGLMaskedSurface::BufferMask QGLMaskedSurface::mask() const -{ - Q_D(const QGLMaskedSurface); - return d->mask; -} - -/*! - Sets the color \a mask to apply to surface() when activate() - is called. - - \sa mask(), setSurface() -*/ -void QGLMaskedSurface::setMask(QGLMaskedSurface::BufferMask mask) -{ - Q_D(QGLMaskedSurface); - d->mask = mask; -} - -/*! - \reimp -*/ -QPaintDevice *QGLMaskedSurface::device() const -{ - Q_D(const QGLMaskedSurface); - return d->surface ? d->surface->device() : 0; -} - -/*! - \reimp -*/ -bool QGLMaskedSurface::activate(QGLAbstractSurface *prevSurface) -{ - Q_D(const QGLMaskedSurface); - if (!d->surface || !d->surface->activate(prevSurface)) - return false; - glColorMask((d->mask & RedMask) != 0, (d->mask & GreenMask) != 0, - (d->mask & BlueMask) != 0, (d->mask & AlphaMask) != 0); - return true; -} - -/*! - \reimp -*/ -void QGLMaskedSurface::deactivate(QGLAbstractSurface *nextSurface) -{ - Q_D(QGLMaskedSurface); - if (d->surface) - d->surface->deactivate(nextSurface); - if (nextSurface && nextSurface->surfaceType() == MaskedSurfaceType) { - // If we are about to switch to another masked surface for - // the same underlying surface, then don't bother calling - // glColorMask() for this one. - QGLMaskedSurface *next = static_cast<QGLMaskedSurface *>(nextSurface); - if (d->surface == next->surface()) - return; - } - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); -} - -/*! - \reimp -*/ -QRect QGLMaskedSurface::viewportGL() const -{ - Q_D(const QGLMaskedSurface); - return d->surface ? d->surface->viewportGL() : QRect(); -} - -QT_END_NAMESPACE diff --git a/src/threed/surfaces/qglmaskedsurface_p.h b/src/threed/surfaces/qglmaskedsurface_p.h deleted file mode 100644 index b2b0c61d..00000000 --- a/src/threed/surfaces/qglmaskedsurface_p.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLMASKEDSURFACE_H -#define QGLMASKEDSURFACE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qglabstractsurface.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGLMaskedSurfacePrivate; - -class QGLMaskedSurface : public QGLAbstractSurface -{ -public: - enum BufferMaskBit - { - RedMask = 0x0001, - GreenMask = 0x0002, - BlueMask = 0x0004, - AlphaMask = 0x0008 - }; - Q_DECLARE_FLAGS(BufferMask, BufferMaskBit) - - QGLMaskedSurface(); - QGLMaskedSurface - (QGLAbstractSurface *surface, QGLMaskedSurface::BufferMask mask); - ~QGLMaskedSurface(); - - QGLAbstractSurface *surface() const; - void setSurface(QGLAbstractSurface *surface); - - QGLMaskedSurface::BufferMask mask() const; - void setMask(QGLMaskedSurface::BufferMask mask); - - QPaintDevice *device() const; - bool activate(QGLAbstractSurface *prevSurface = 0); - void deactivate(QGLAbstractSurface *nextSurface = 0); - QRect viewportGL() const; - -private: - QScopedPointer<QGLMaskedSurfacePrivate> d_ptr; - - Q_DECLARE_PRIVATE(QGLMaskedSurface) - Q_DISABLE_COPY(QGLMaskedSurface) -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QGLMaskedSurface::BufferMask) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/threed/surfaces/qglpaintersurface.cpp b/src/threed/surfaces/qglpaintersurface.cpp deleted file mode 100644 index 98e9d436..00000000 --- a/src/threed/surfaces/qglpaintersurface.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglpaintersurface_p.h" - -QT_BEGIN_NAMESPACE - -QPaintDevice *QGLPainterSurface::device() const -{ - return m_painter->device(); -} - -bool QGLPainterSurface::activate(QGLAbstractSurface *prevSurface) -{ - if (m_painterContext != QGLContext::currentContext()) - const_cast<QGLContext *>(m_painterContext)->makeCurrent(); - if (!prevSurface) - m_painter->beginNativePainting(); - return true; -} - -void QGLPainterSurface::deactivate(QGLAbstractSurface *nextSurface) -{ - if (!nextSurface) - m_painter->endNativePainting(); -} - -QRect QGLPainterSurface::viewportGL() const -{ - QPaintDevice *device = m_painter->device(); - return QRect(0, 0, device->width(), device->height()); -} - -QT_END_NAMESPACE diff --git a/src/threed/surfaces/qglpaintersurface_p.h b/src/threed/surfaces/qglpaintersurface_p.h deleted file mode 100644 index 0dc49161..00000000 --- a/src/threed/surfaces/qglpaintersurface_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLPAINTERSURFACE_P_H -#define QGLPAINTERSURFACE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qglabstractsurface.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGLPainterSurface : public QGLAbstractSurface -{ -public: - explicit QGLPainterSurface(QPainter *painter) - : QGLAbstractSurface(503) - , m_painter(painter), m_painterContext(QGLContext::currentContext()) {} - ~QGLPainterSurface() {} - - QPaintDevice *device() const; - bool activate(QGLAbstractSurface *prevSurface); - void deactivate(QGLAbstractSurface *nextSurface); - QRect viewportGL() const; - -private: - QPainter *m_painter; - const QGLContext *m_painterContext; - - Q_DISABLE_COPY(QGLPainterSurface) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/threed/surfaces/qglpixelbuffersurface.cpp b/src/threed/surfaces/qglpixelbuffersurface.cpp deleted file mode 100644 index 45735cc3..00000000 --- a/src/threed/surfaces/qglpixelbuffersurface.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglpixelbuffersurface.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QGLPixelBufferSurface - \brief The QGLPixelBufferSurface class represents a pixel buffer that is being used as an OpenGL drawing surface. - \since 4.8 - \ingroup qt3d - \ingroup qt3d::painting -*/ - -/*! - Constructs a default pixel buffer surface. This constructor - should be followed by a call to setPixelBuffer(). -*/ -QGLPixelBufferSurface::QGLPixelBufferSurface() - : QGLAbstractSurface(QGLAbstractSurface::PixelBuffer) - , m_pbuffer(0) -{ -} - -/*! - Constructs a pixel buffer surface for \a pbuffer. -*/ -QGLPixelBufferSurface::QGLPixelBufferSurface(QGLPixelBuffer *pbuffer) - : QGLAbstractSurface(QGLAbstractSurface::PixelBuffer) - , m_pbuffer(pbuffer) -{ -} - -/*! - Destroys this pixel buffer surface. -*/ -QGLPixelBufferSurface::~QGLPixelBufferSurface() -{ -} - -/*! - Returns the pixel buffer for this surface, or null if - it has not been set yet. - - \sa setPixelBuffer() -*/ -QGLPixelBuffer *QGLPixelBufferSurface::pixelBuffer() const -{ - return m_pbuffer; -} - -/*! - Sets the framebuffer object for this surface to \a pbuffer. - - \sa pixelBuffer() -*/ -void QGLPixelBufferSurface::setPixelBuffer - (QGLPixelBuffer *pbuffer) -{ - m_pbuffer = pbuffer; -} - -/*! - \reimp -*/ -QPaintDevice *QGLPixelBufferSurface::device() const -{ - return m_pbuffer; -} - -/*! - \reimp -*/ -bool QGLPixelBufferSurface::activate(QGLAbstractSurface *prevSurface) -{ - Q_UNUSED(prevSurface); - if (m_pbuffer) - return m_pbuffer->makeCurrent(); - else - return false; -} - -/*! - \reimp -*/ -void QGLPixelBufferSurface::deactivate(QGLAbstractSurface *nextSurface) -{ - // Nothing to do here - leave the context current. - Q_UNUSED(nextSurface); -} - -/*! - \reimp -*/ -QRect QGLPixelBufferSurface::viewportGL() const -{ - if (m_pbuffer) - return QRect(0, 0, m_pbuffer->width(), m_pbuffer->height()); - else - return QRect(); -} - -QT_END_NAMESPACE diff --git a/src/threed/surfaces/qglpixelbuffersurface.h b/src/threed/surfaces/qglpixelbuffersurface.h deleted file mode 100644 index 22dac86c..00000000 --- a/src/threed/surfaces/qglpixelbuffersurface.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLPIXELBUFFERSURFACE_H -#define QGLPIXELBUFFERSURFACE_H - -#include "qglabstractsurface.h" -#include <QtOpenGL/qglpixelbuffer.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Qt3D) - -class Q_QT3D_EXPORT QGLPixelBufferSurface : public QGLAbstractSurface -{ -public: - QGLPixelBufferSurface(); - explicit QGLPixelBufferSurface(QGLPixelBuffer *pbuffer); - ~QGLPixelBufferSurface(); - - QGLPixelBuffer *pixelBuffer() const; - void setPixelBuffer(QGLPixelBuffer *pbuffer); - - QPaintDevice *device() const; - bool activate(QGLAbstractSurface *prevSurface = 0); - void deactivate(QGLAbstractSurface *nextSurface = 0); - QRect viewportGL() const; - -private: - QGLPixelBuffer *m_pbuffer; - - Q_DISABLE_COPY(QGLPixelBufferSurface) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/threed/surfaces/qglsubsurface.cpp b/src/threed/surfaces/qglsubsurface.cpp deleted file mode 100644 index 367dd621..00000000 --- a/src/threed/surfaces/qglsubsurface.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglsubsurface.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QGLSubsurface - \brief The QGLSubsurface class represents a sub-surface of another OpenGL drawing surface. - \since 4.8 - \ingroup qt3d - \ingroup qt3d::painting -*/ - -class QGLSubsurfacePrivate -{ -public: - QGLSubsurfacePrivate() : surface(0) {} - QGLSubsurfacePrivate(QGLAbstractSurface *surf, const QRect &rgn) - : surface(surf), region(rgn) {} - - QGLAbstractSurface *surface; - QRect region; -}; - -/*! - Constructs a new subsurface. This constructor should be followed - by calls to setSurface() and setRegion(). -*/ -QGLSubsurface::QGLSubsurface() - : QGLAbstractSurface(QGLAbstractSurface::Subsurface) - , d_ptr(new QGLSubsurfacePrivate) -{ -} - -/*! - Constructs a new subsurface that occupies \a region within - \a surface. The \a region has its origin at the top-left - of \a surface. -*/ -QGLSubsurface::QGLSubsurface - (QGLAbstractSurface *surface, const QRect ®ion) - : QGLAbstractSurface(QGLAbstractSurface::Subsurface) - , d_ptr(new QGLSubsurfacePrivate(surface, region)) -{ -} - -/*! - Destroys this subsurface. -*/ -QGLSubsurface::~QGLSubsurface() -{ -} - -/*! - Returns the surface behind this subsurface, or null if the - surface has not been set. - - \sa setSurface(), region() -*/ -QGLAbstractSurface *QGLSubsurface::surface() const -{ - Q_D(const QGLSubsurface); - return d->surface; -} - -/*! - Sets the \a surface behind this subsurface. - - \sa surface(), setRegion() -*/ -void QGLSubsurface::setSurface(QGLAbstractSurface *surface) -{ - Q_D(QGLSubsurface); - d->surface = surface; -} - -/*! - Returns the region within surface() that is occupied by this - subsurface, relative to the viewportRect() of surface(). - The origin is at the top-left of surface(). - - \sa setRegion(), surface() -*/ -QRect QGLSubsurface::region() const -{ - Q_D(const QGLSubsurface); - return d->region; -} - -/*! - Sets the \a region within surface() that is occupied by this - subsurface, relative to the viewportRect() of surface(). - The origin is at the top-left of surface(). - - \sa region(), setSurface() -*/ -void QGLSubsurface::setRegion(const QRect ®ion) -{ - Q_D(QGLSubsurface); - d->region = region; -} - -/*! - \reimp -*/ -QPaintDevice *QGLSubsurface::device() const -{ - Q_D(const QGLSubsurface); - if (d->surface) - return d->surface->device(); - else - return 0; -} - -/*! - \reimp -*/ -bool QGLSubsurface::activate(QGLAbstractSurface *prevSurface) -{ - Q_D(QGLSubsurface); - if (d->surface) - return d->surface->activate(prevSurface); - else - return false; -} - -/*! - \reimp -*/ -void QGLSubsurface::deactivate(QGLAbstractSurface *nextSurface) -{ - Q_D(QGLSubsurface); - if (d->surface) - d->surface->deactivate(nextSurface); -} - -/*! - \reimp -*/ -QRect QGLSubsurface::viewportGL() const -{ - Q_D(const QGLSubsurface); - if (d->surface) { - // The underlying surface's viewportGL() has its origin - // at the bottom-left, whereas d->region has its origin - // at the top-left. Flip the sub-region and adjust. - QRect rect = d->surface->viewportGL(); - return QRect(rect.x() + d->region.x(), - rect.y() + rect.height() - - (d->region.y() + d->region.height()), - d->region.width(), d->region.height()); - } else { - // Don't know the actual height of the surrounding surface, - // so the best we can do is assume the region is bottom-aligned. - return QRect(d->region.x(), 0, d->region.width(), d->region.height()); - } -} - -QT_END_NAMESPACE diff --git a/src/threed/surfaces/qglsubsurface.h b/src/threed/surfaces/qglsubsurface.h deleted file mode 100644 index 69904a19..00000000 --- a/src/threed/surfaces/qglsubsurface.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLSUBSURFACE_H -#define QGLSUBSURFACE_H - -#include "qglabstractsurface.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Qt3D) - -class QGLSubsurfacePrivate; - -class Q_QT3D_EXPORT QGLSubsurface : public QGLAbstractSurface -{ -public: - QGLSubsurface(); - QGLSubsurface(QGLAbstractSurface *surface, const QRect ®ion); - ~QGLSubsurface(); - - QGLAbstractSurface *surface() const; - void setSurface(QGLAbstractSurface *subSurface); - - QRect region() const; - void setRegion(const QRect ®ion); - - QPaintDevice *device() const; - bool activate(QGLAbstractSurface *prevSurface = 0); - void deactivate(QGLAbstractSurface *nextSurface = 0); - QRect viewportGL() const; - -private: - QScopedPointer<QGLSubsurfacePrivate> d_ptr; - - Q_DECLARE_PRIVATE(QGLSubsurface) - Q_DISABLE_COPY(QGLSubsurface) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/threed/surfaces/qglwidgetsurface.cpp b/src/threed/surfaces/qglwidgetsurface.cpp deleted file mode 100644 index 7d137eb6..00000000 --- a/src/threed/surfaces/qglwidgetsurface.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglwidgetsurface.h" -#include <QtGui/qpainter.h> -#include <QtGui/qpaintengine.h> - -QT_BEGIN_NAMESPACE - -/*! - \class QGLWidgetSurface - \brief The QGLWidgetSurface class represents a QGLWidget that is begin used as an OpenGL drawing surface. - \since 4.8 - \ingroup qt3d - \ingroup qt3d::painting -*/ - -/*! - Constructs a widget surface. This constructor should be followed - by a call to setWidget(). -*/ -QGLWidgetSurface::QGLWidgetSurface() - : QGLAbstractSurface(QGLAbstractSurface::Widget) - , m_widget(0) -{ -} - -/*! - Constructs a widget surface for \a widget. -*/ -QGLWidgetSurface::QGLWidgetSurface(QGLWidget *widget) - : QGLAbstractSurface(QGLAbstractSurface::Widget) - , m_widget(widget) -{ -} - -/*! - Destroys this widget surface. -*/ -QGLWidgetSurface::~QGLWidgetSurface() -{ -} - -/*! - Returns the widget that is underlying this surface. - - \sa setWidget() -*/ -QGLWidget *QGLWidgetSurface::widget() const -{ - return m_widget; -} - -/*! - Sets the \a widget that is underlying this surface. - - \sa widget() -*/ -void QGLWidgetSurface::setWidget(QGLWidget *widget) -{ - m_widget = widget; -} - -/*! - \reimp -*/ -QPaintDevice *QGLWidgetSurface::device() const -{ - return m_widget; -} - -/*! - \reimp -*/ -bool QGLWidgetSurface::activate(QGLAbstractSurface *prevSurface) -{ - Q_UNUSED(prevSurface); - if (m_widget) { - const QGLContext *context = m_widget->context(); - if (QGLContext::currentContext() != context) - const_cast<QGLContext *>(context)->makeCurrent(); - return true; - } else { - return false; - } -} - -/*! - \reimp -*/ -void QGLWidgetSurface::deactivate(QGLAbstractSurface *nextSurface) -{ - // Nothing to do here - leave the context current. - Q_UNUSED(nextSurface); -} - -/*! - \reimp -*/ -QRect QGLWidgetSurface::viewportGL() const -{ - if (m_widget) - return m_widget->rect(); // Origin assumed to be (0, 0). - else - return QRect(); -} - -QT_END_NAMESPACE diff --git a/src/threed/surfaces/qglwidgetsurface.h b/src/threed/surfaces/qglwidgetsurface.h deleted file mode 100644 index e0ce8e27..00000000 --- a/src/threed/surfaces/qglwidgetsurface.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the QtQuick3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLWIDGETSURFACE_H -#define QGLWIDGETSURFACE_H - -#include "qglabstractsurface.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Qt3D) - -class QGLWidgetSurfacePrivate; - -class Q_QT3D_EXPORT QGLWidgetSurface : public QGLAbstractSurface -{ -public: - QGLWidgetSurface(); - explicit QGLWidgetSurface(QGLWidget *widget); - ~QGLWidgetSurface(); - - QGLWidget *widget() const; - void setWidget(QGLWidget *widget); - - QPaintDevice *device() const; - bool activate(QGLAbstractSurface *prevSurface = 0); - void deactivate(QGLAbstractSurface *nextSurface = 0); - QRect viewportGL() const; - -private: - QGLWidget *m_widget; - - Q_DISABLE_COPY(QGLWidgetSurface) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/threed/surfaces/surfaces.pri b/src/threed/surfaces/surfaces.pri deleted file mode 100644 index 8ce35fb6..00000000 --- a/src/threed/surfaces/surfaces.pri +++ /dev/null @@ -1,23 +0,0 @@ -INCLUDEPATH += $$PWD -VPATH += $$PWD -HEADERS += \ - surfaces/qglabstractsurface.h \ - surfaces/qglframebufferobjectsurface.h \ - surfaces/qglpixelbuffersurface.h \ - surfaces/qglsubsurface.h \ - surfaces/qglwidgetsurface.h -SOURCES += \ - qglabstractsurface.cpp \ - qglcontextsurface.cpp \ - qgldrawbuffersurface.cpp \ - qglframebufferobjectsurface.cpp \ - qglmaskedsurface.cpp \ - qglpaintersurface.cpp \ - qglpixelbuffersurface.cpp \ - qglsubsurface.cpp \ - qglwidgetsurface.cpp -PRIVATE_HEADERS += \ - qglcontextsurface_p.h \ - qgldrawbuffersurface_p.h \ - qglmaskedsurface_p.h \ - qglpaintersurface_p.h |