summaryrefslogtreecommitdiffstats
path: root/src/render/frontend/qtexture.h
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2014-08-19 09:34:17 +0200
committerSean Harmer <sean.harmer@kdab.com>2014-08-19 13:02:27 +0200
commit87a07e40e65f2a2540c9fdf579205e3d479d50e4 (patch)
tree1bc637920fb765c136d390c0559ca76f9bd7183a /src/render/frontend/qtexture.h
parent977863dd3e6a7a40f60db1f9777500d21762d404 (diff)
Texture renamed to QTexture
Change-Id: I6f5570ce042b8d3ef44aa76c1fd8ce3a1dde4d3c Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/frontend/qtexture.h')
-rw-r--r--src/render/frontend/qtexture.h303
1 files changed, 303 insertions, 0 deletions
diff --git a/src/render/frontend/qtexture.h b/src/render/frontend/qtexture.h
new file mode 100644
index 000000000..8fa8e8987
--- /dev/null
+++ b/src/render/frontend/qtexture.h
@@ -0,0 +1,303 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_QTEXTURE_H
+#define QT3D_QTEXTURE_H
+
+#include <QOpenGLTexture>
+#include <Qt3DRenderer/texturedata.h>
+#include <Qt3DRenderer/qt3drenderer_global.h>
+#include <Qt3DCore/qnode.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QTexturePrivate;
+
+class QT3DRENDERERSHARED_EXPORT QTexture : public QNode
+{
+ Q_OBJECT
+ Q_ENUMS(Target)
+ Q_ENUMS(TextureFormat)
+ Q_ENUMS(Filter)
+ Q_ENUMS(WrapMode)
+ Q_ENUMS(Status)
+ Q_PROPERTY(QTexture::Target target READ target WRITE setTarget NOTIFY targetChanged)
+ Q_PROPERTY(QTexture::TextureFormat format READ format WRITE setFormat NOTIFY formatChanged)
+ Q_PROPERTY(bool generateMipMaps READ generateMipMaps WRITE setGenerateMipMaps NOTIFY generateMipMapsChanged)
+ Q_PROPERTY(QTexture::WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
+ Q_PROPERTY(QTexture::Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
+ Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
+ Q_PROPERTY(int depth READ depth WRITE setDepth NOTIFY depthChanged)
+ Q_PROPERTY(QTexture::Filter magnificationFilter READ magnificationFilter WRITE setMagnificationFilter NOTIFY magnificationFilterChanged)
+ Q_PROPERTY(QTexture::Filter minificationFilter READ minificationFilter WRITE setMinificationFilter NOTIFY minificationFilterChanged)
+
+public:
+ explicit QTexture(QNode *parent = 0);
+ ~QTexture();
+
+ enum Status {
+ Loading = 0,
+ Loaded,
+ Error
+ };
+
+ enum Target {
+ Target1D = 0x0DE0, // GL_TEXTURE_1D
+ Target1DArray = 0x8C18, // GL_TEXTURE_1D_ARRAY
+ Target2D = 0x0DE1, // GL_TEXTURE_2D
+ Target2DArray = 0x8C1A, // GL_TEXTURE_2D_ARRAY
+ Target3D = 0x806F, // GL_TEXTURE_3D
+ TargetCubeMap = 0x8513, // GL_TEXTURE_CUBE_MAP
+ TargetCubeMapArray = 0x9009, // GL_TEXTURE_CUBE_MAP_ARRAY
+ Target2DMultisample = 0x9100, // GL_TEXTURE_2D_MULTISAMPLE
+ Target2DMultisampleArray = 0x9102, // GL_TEXTURE_2D_MULTISAMPLE_ARRAY
+ TargetRectangle = 0x84F5, // GL_TEXTURE_RECTANGLE
+ TargetBuffer = 0x8C2A // GL_TEXTURE_BUFFER
+ };
+
+ enum TextureFormat {
+ NoFormat = 0, // GL_NONE
+
+ // Unsigned normalized formats
+ R8_UNorm = 0x8229, // GL_R8
+ RG8_UNorm = 0x822B, // GL_RG8
+ RGB8_UNorm = 0x8051, // GL_RGB8
+ RGBA8_UNorm = 0x8058, // GL_RGBA8
+
+ R16_UNorm = 0x822A, // GL_R16
+ RG16_UNorm = 0x822C, // GL_RG16
+ RGB16_UNorm = 0x8054, // GL_RGB16
+ RGBA16_UNorm = 0x805B, // GL_RGBA16
+
+ // Signed normalized formats
+ R8_SNorm = 0x8F94, // GL_R8_SNORM
+ RG8_SNorm = 0x8F95, // GL_RG8_SNORM
+ RGB8_SNorm = 0x8F96, // GL_RGB8_SNORM
+ RGBA8_SNorm = 0x8F97, // GL_RGBA8_SNORM
+
+ R16_SNorm = 0x8F98, // GL_R16_SNORM
+ RG16_SNorm = 0x8F99, // GL_RG16_SNORM
+ RGB16_SNorm = 0x8F9A, // GL_RGB16_SNORM
+ RGBA16_SNorm = 0x8F9B, // GL_RGBA16_SNORM
+
+ // Unsigned integer formats
+ R8U = 0x8232, // GL_R8UI
+ RG8U = 0x8238, // GL_RG8UI
+ RGB8U = 0x8D7D, // GL_RGB8UI
+ RGBA8U = 0x8D7C, // GL_RGBA8UI
+
+ R16U = 0x8234, // GL_R16UI
+ RG16U = 0x823A, // GL_RG16UI
+ RGB16U = 0x8D77, // GL_RGB16UI
+ RGBA16U = 0x8D76, // GL_RGBA16UI
+
+ R32U = 0x8236, // GL_R32UI
+ RG32U = 0x823C, // GL_RG32UI
+ RGB32U = 0x8D71, // GL_RGB32UI
+ RGBA32U = 0x8D70, // GL_RGBA32UI
+
+ // Signed integer formats
+ R8I = 0x8231, // GL_R8I
+ RG8I = 0x8237, // GL_RG8I
+ RGB8I = 0x8D8F, // GL_RGB8I
+ RGBA8I = 0x8D8E, // GL_RGBA8I
+
+ R16I = 0x8233, // GL_R16I
+ RG16I = 0x8239, // GL_RG16I
+ RGB16I = 0x8D89, // GL_RGB16I
+ RGBA16I = 0x8D88, // GL_RGBA16I
+
+ R32I = 0x8235, // GL_R32I
+ RG32I = 0x823B, // GL_RG32I
+ RGB32I = 0x8D83, // GL_RGB32I
+ RGBA32I = 0x8D82, // GL_RGBA32I
+
+ // Floating point formats
+ R16F = 0x822D, // GL_R16F
+ RG16F = 0x822F, // GL_RG16F
+ RGB16F = 0x881B, // GL_RGB16F
+ RGBA16F = 0x881A, // GL_RGBA16F
+
+ R32F = 0x822E, // GL_R32F
+ RG32F = 0x8230, // GL_RG32F
+ RGB32F = 0x8815, // GL_RGB32F
+ RGBA32F = 0x8814, // GL_RGBA32F
+
+ // Packed formats
+ RGB9E5 = 0x8C3D, // GL_RGB9_E5
+ RG11B10F = 0x8C3A, // GL_R11F_G11F_B10F
+ RG3B2 = 0x2A10, // GL_R3_G3_B2
+ R5G6B5 = 0x8D62, // GL_RGB565
+ RGB5A1 = 0x8057, // GL_RGB5_A1
+ RGBA4 = 0x8056, // GL_RGBA4
+ RGB10A2 = 0x906F, // GL_RGB10_A2UI
+
+ // Depth formats
+ D16 = 0x81A5, // GL_DEPTH_COMPONENT16
+ D24 = 0x81A6, // GL_DEPTH_COMPONENT24
+ D24S8 = 0x88F0, // GL_DEPTH24_STENCIL8
+ D32 = 0x81A7, // GL_DEPTH_COMPONENT32
+ D32F = 0x8CAC, // GL_DEPTH_COMPONENT32F
+ D32FS8X24 = 0x8CAD, // GL_DEPTH32F_STENCIL8
+
+ // Compressed formats
+ RGB_DXT1 = 0x83F0, // GL_COMPRESSED_RGB_S3TC_DXT1_EXT
+ RGBA_DXT1 = 0x83F1, // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
+ RGBA_DXT3 = 0x83F2, // GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
+ RGBA_DXT5 = 0x83F3, // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
+ R_ATI1N_UNorm = 0x8DBB, // GL_COMPRESSED_RED_RGTC1
+ R_ATI1N_SNorm = 0x8DBC, // GL_COMPRESSED_SIGNED_RED_RGTC1
+ RG_ATI2N_UNorm = 0x8DBD, // GL_COMPRESSED_RG_RGTC2
+ RG_ATI2N_SNorm = 0x8DBE, // GL_COMPRESSED_SIGNED_RG_RGTC2
+ RGB_BP_UNSIGNED_FLOAT = 0x8E8F, // GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB
+ RGB_BP_SIGNED_FLOAT = 0x8E8E, // GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB
+ RGB_BP_UNorm = 0x8E8C, // GL_COMPRESSED_RGBA_BPTC_UNORM_ARB
+
+ // sRGB formats
+ SRGB8 = 0x8C41, // GL_SRGB8
+ SRGB8_Alpha8 = 0x8C43, // GL_SRGB8_ALPHA8
+ SRGB_DXT1 = 0x8C4C, // GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
+ SRGB_Alpha_DXT1 = 0x8C4D, // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
+ SRGB_Alpha_DXT3 = 0x8C4E, // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
+ SRGB_Alpha_DXT5 = 0x8C4F, // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
+ SRGB_BP_UNorm = 0x8E8D, // GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB
+
+ // ES 2 formats
+ DepthFormat = 0x1902, // GL_DEPTH_COMPONENT
+ AlphaFormat = 0x1906, // GL_ALPHA
+ RGBFormat = 0x1907, // GL_RGB
+ RGBAFormat = 0x1908, // GL_RGBA
+ LuminanceFormat = 0x1909, // GL_LUMINANCE
+ LuminanceAlphaFormat = 0x190A
+ };
+
+ enum Filter {
+ Nearest = 0x2600, // GL_NEAREST
+ Linear = 0x2601, // GL_LINEAR
+ NearestMipMapNearest = 0x2700, // GL_NEAREST_MIPMAP_NEAREST
+ NearestMipMapLinear = 0x2702, // GL_NEAREST_MIPMAP_LINEAR
+ LinearMipMapNearest = 0x2701, // GL_LINEAR_MIPMAP_NEAREST
+ LinearMipMapLinear = 0x2703 // GL_LINEAR_MIPMAP_LINEAR
+ };
+
+ enum WrapMode {
+ Repeat = 0x2901, // GL_REPEAT
+ MirroredRepeat = 0x8370, // GL_MIRRORED_REPEAT
+ ClampToEdge = 0x812F, // GL_CLAMP_TO_EDGE
+ ClampToBorder = 0x812D // GL_CLAMP_TO_BORDER
+ };
+
+ void copy(const QNode *ref) Q_DECL_OVERRIDE;
+
+ void setTarget(Target target);
+ Target target() const;
+
+ void setFormat(TextureFormat format);
+ TextureFormat format() const;
+
+ Status status() const;
+
+ /**
+ * @brief setFromQImage - set size and image data based upon a QImage
+ * Can optionally generate mip-map levels automatically too. Target
+ * must be Texture2D, Texture2DArray or TextureRectangle.
+ * @param img - valid QImage. If Texture2D is set, should be power-of-2
+ * dimensions.
+ */
+ bool setFromQImage(QImage img, int layer = 0);
+
+ void addImageData(TexImageDataPtr imgData);
+ QList<TexImageDataPtr> imageData() const;
+
+ void setGenerateMipMaps(bool gen);
+ bool generateMipMaps() const;
+
+ // sampler data - in the future proxy to a Sampler helper
+ void setMinificationFilter(Filter f);
+ void setMagnificationFilter(Filter f);
+
+ Filter minificationFilter() const;
+
+ Filter magnificationFilter() const;
+
+ void setWrapMode(WrapMode wrapMode);
+ WrapMode wrapMode() const;
+
+ void setSize(int width, int height=1, int depth=1);
+
+ void setWidth(int width);
+ void setHeight(int height);
+ void setDepth(int depth);
+
+ int width() const;
+ int height() const;
+ int depth() const;
+
+Q_SIGNALS:
+ void targetChanged();
+ void formatChanged();
+ void statusChanged();
+ void generateMipMapsChanged();
+ void wrapModeChanged();
+ void widthChanged();
+ void heightChanged();
+ void depthChanged();
+ void magnificationFilterChanged();
+ void minificationFilterChanged();
+
+protected:
+
+ Q_DECLARE_PRIVATE(QTexture)
+ QTexture(QTexturePrivate &dd, QNode *parent = 0);
+ void setStatus(Status status);
+ QNode *doClone(QNode *clonedParent) const Q_DECL_OVERRIDE;
+};
+
+} // namespace Qt3D
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(Qt3D::QTexture*)
+
+#endif // QT3D_QTEXTURE_H