Warning: That file was not part of the compilation database. It may have many parsing errors.
| 1 | /**************************************************************************** |
|---|---|
| 2 | ** |
| 3 | ** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt3D module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #ifndef QT3DRENDER_QABSTRACTTEXTURE_H |
| 41 | #define QT3DRENDER_QABSTRACTTEXTURE_H |
| 42 | |
| 43 | #include <Qt3DRender/qtextureimagedata.h> |
| 44 | #include <Qt3DRender/qt3drender_global.h> |
| 45 | #include <Qt3DCore/qnode.h> |
| 46 | |
| 47 | QT_BEGIN_NAMESPACE |
| 48 | |
| 49 | namespace Qt3DRender { |
| 50 | |
| 51 | class QAbstractTexturePrivate; |
| 52 | class QTextureWrapMode; |
| 53 | class QAbstractTextureImage; |
| 54 | class QTextureGenerator; |
| 55 | class QTextureDataUpdate; |
| 56 | typedef QSharedPointer<QTextureGenerator> QTextureGeneratorPtr; |
| 57 | |
| 58 | class Q_3DRENDERSHARED_EXPORT QAbstractTexture : public Qt3DCore::QNode |
| 59 | { |
| 60 | Q_OBJECT |
| 61 | Q_PROPERTY(Target target READ target CONSTANT) |
| 62 | Q_PROPERTY(TextureFormat format READ format WRITE setFormat NOTIFY formatChanged) |
| 63 | Q_PROPERTY(bool generateMipMaps READ generateMipMaps WRITE setGenerateMipMaps NOTIFY generateMipMapsChanged) |
| 64 | Q_PROPERTY(Qt3DRender::QTextureWrapMode *wrapMode READ wrapMode CONSTANT) |
| 65 | Q_PROPERTY(Status status READ status NOTIFY statusChanged) |
| 66 | Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) |
| 67 | Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged) |
| 68 | Q_PROPERTY(int depth READ depth WRITE setDepth NOTIFY depthChanged) |
| 69 | Q_PROPERTY(Filter magnificationFilter READ magnificationFilter WRITE setMagnificationFilter NOTIFY magnificationFilterChanged) |
| 70 | Q_PROPERTY(Filter minificationFilter READ minificationFilter WRITE setMinificationFilter NOTIFY minificationFilterChanged) |
| 71 | Q_PROPERTY(float maximumAnisotropy READ maximumAnisotropy WRITE setMaximumAnisotropy NOTIFY maximumAnisotropyChanged) |
| 72 | Q_PROPERTY(ComparisonFunction comparisonFunction READ comparisonFunction WRITE setComparisonFunction NOTIFY comparisonFunctionChanged) |
| 73 | Q_PROPERTY(ComparisonMode comparisonMode READ comparisonMode WRITE setComparisonMode NOTIFY comparisonModeChanged) |
| 74 | Q_PROPERTY(int layers READ layers WRITE setLayers NOTIFY layersChanged) |
| 75 | Q_PROPERTY(int samples READ samples WRITE setSamples NOTIFY samplesChanged) |
| 76 | Q_PROPERTY(HandleType handleType READ handleType NOTIFY handleTypeChanged REVISION 13) |
| 77 | Q_PROPERTY(QVariant handle READ handle NOTIFY handleChanged REVISION 13) |
| 78 | |
| 79 | public: |
| 80 | |
| 81 | enum Status { |
| 82 | None = 0, |
| 83 | Loading, |
| 84 | Ready, |
| 85 | Error |
| 86 | }; |
| 87 | Q_ENUM(Status) // LCOV_EXCL_LINE |
| 88 | |
| 89 | enum Target { |
| 90 | TargetAutomatic = 0, // Target will be determined by the Qt3D engine |
| 91 | Target1D = 0x0DE0, // GL_TEXTURE_1D |
| 92 | Target1DArray = 0x8C18, // GL_TEXTURE_1D_ARRAY |
| 93 | Target2D = 0x0DE1, // GL_TEXTURE_2D |
| 94 | Target2DArray = 0x8C1A, // GL_TEXTURE_2D_ARRAY |
| 95 | Target3D = 0x806F, // GL_TEXTURE_3D |
| 96 | TargetCubeMap = 0x8513, // GL_TEXTURE_CUBE_MAP |
| 97 | TargetCubeMapArray = 0x9009, // GL_TEXTURE_CUBE_MAP_ARRAY |
| 98 | Target2DMultisample = 0x9100, // GL_TEXTURE_2D_MULTISAMPLE |
| 99 | Target2DMultisampleArray = 0x9102, // GL_TEXTURE_2D_MULTISAMPLE_ARRAY |
| 100 | TargetRectangle = 0x84F5, // GL_TEXTURE_RECTANGLE |
| 101 | TargetBuffer = 0x8C2A // GL_TEXTURE_BUFFER |
| 102 | }; |
| 103 | Q_ENUM(Target) // LCOV_EXCL_LINE |
| 104 | |
| 105 | enum TextureFormat { |
| 106 | NoFormat = 0, // GL_NONE |
| 107 | Automatic = 1, // The Qt3D engine automatically determines the best format |
| 108 | |
| 109 | // Unsigned normalized formats |
| 110 | R8_UNorm = 0x8229, // GL_R8 |
| 111 | RG8_UNorm = 0x822B, // GL_RG8 |
| 112 | RGB8_UNorm = 0x8051, // GL_RGB8 |
| 113 | RGBA8_UNorm = 0x8058, // GL_RGBA8 |
| 114 | |
| 115 | R16_UNorm = 0x822A, // GL_R16 |
| 116 | RG16_UNorm = 0x822C, // GL_RG16 |
| 117 | RGB16_UNorm = 0x8054, // GL_RGB16 |
| 118 | RGBA16_UNorm = 0x805B, // GL_RGBA16 |
| 119 | |
| 120 | // Signed normalized formats |
| 121 | R8_SNorm = 0x8F94, // GL_R8_SNORM |
| 122 | RG8_SNorm = 0x8F95, // GL_RG8_SNORM |
| 123 | RGB8_SNorm = 0x8F96, // GL_RGB8_SNORM |
| 124 | RGBA8_SNorm = 0x8F97, // GL_RGBA8_SNORM |
| 125 | |
| 126 | R16_SNorm = 0x8F98, // GL_R16_SNORM |
| 127 | RG16_SNorm = 0x8F99, // GL_RG16_SNORM |
| 128 | RGB16_SNorm = 0x8F9A, // GL_RGB16_SNORM |
| 129 | RGBA16_SNorm = 0x8F9B, // GL_RGBA16_SNORM |
| 130 | |
| 131 | // Unsigned integer formats |
| 132 | R8U = 0x8232, // GL_R8UI |
| 133 | RG8U = 0x8238, // GL_RG8UI |
| 134 | RGB8U = 0x8D7D, // GL_RGB8UI |
| 135 | RGBA8U = 0x8D7C, // GL_RGBA8UI |
| 136 | |
| 137 | R16U = 0x8234, // GL_R16UI |
| 138 | RG16U = 0x823A, // GL_RG16UI |
| 139 | RGB16U = 0x8D77, // GL_RGB16UI |
| 140 | RGBA16U = 0x8D76, // GL_RGBA16UI |
| 141 | |
| 142 | R32U = 0x8236, // GL_R32UI |
| 143 | RG32U = 0x823C, // GL_RG32UI |
| 144 | RGB32U = 0x8D71, // GL_RGB32UI |
| 145 | RGBA32U = 0x8D70, // GL_RGBA32UI |
| 146 | |
| 147 | // Signed integer formats |
| 148 | R8I = 0x8231, // GL_R8I |
| 149 | RG8I = 0x8237, // GL_RG8I |
| 150 | RGB8I = 0x8D8F, // GL_RGB8I |
| 151 | RGBA8I = 0x8D8E, // GL_RGBA8I |
| 152 | |
| 153 | R16I = 0x8233, // GL_R16I |
| 154 | RG16I = 0x8239, // GL_RG16I |
| 155 | RGB16I = 0x8D89, // GL_RGB16I |
| 156 | RGBA16I = 0x8D88, // GL_RGBA16I |
| 157 | |
| 158 | R32I = 0x8235, // GL_R32I |
| 159 | RG32I = 0x823B, // GL_RG32I |
| 160 | RGB32I = 0x8D83, // GL_RGB32I |
| 161 | RGBA32I = 0x8D82, // GL_RGBA32I |
| 162 | |
| 163 | // Floating point formats |
| 164 | R16F = 0x822D, // GL_R16F |
| 165 | RG16F = 0x822F, // GL_RG16F |
| 166 | RGB16F = 0x881B, // GL_RGB16F |
| 167 | RGBA16F = 0x881A, // GL_RGBA16F |
| 168 | |
| 169 | R32F = 0x822E, // GL_R32F |
| 170 | RG32F = 0x8230, // GL_RG32F |
| 171 | RGB32F = 0x8815, // GL_RGB32F |
| 172 | RGBA32F = 0x8814, // GL_RGBA32F |
| 173 | |
| 174 | // Packed formats |
| 175 | RGB9E5 = 0x8C3D, // GL_RGB9_E5 |
| 176 | RG11B10F = 0x8C3A, // GL_R11F_G11F_B10F |
| 177 | RG3B2 = 0x2A10, // GL_R3_G3_B2 |
| 178 | R5G6B5 = 0x8D62, // GL_RGB565 |
| 179 | RGB5A1 = 0x8057, // GL_RGB5_A1 |
| 180 | RGBA4 = 0x8056, // GL_RGBA4 |
| 181 | RGB10A2 = 0x8059, // GL_RGB10_A2 |
| 182 | RGB10A2U = 0x906F, // GL_RGB10_A2UI |
| 183 | |
| 184 | // Depth formats |
| 185 | D16 = 0x81A5, // GL_DEPTH_COMPONENT16 |
| 186 | D24 = 0x81A6, // GL_DEPTH_COMPONENT24 |
| 187 | D24S8 = 0x88F0, // GL_DEPTH24_STENCIL8 |
| 188 | D32 = 0x81A7, // GL_DEPTH_COMPONENT32 |
| 189 | D32F = 0x8CAC, // GL_DEPTH_COMPONENT32F |
| 190 | D32FS8X24 = 0x8CAD, // GL_DEPTH32F_STENCIL8 |
| 191 | |
| 192 | // Compressed formats |
| 193 | RGB_DXT1 = 0x83F0, // GL_COMPRESSED_RGB_S3TC_DXT1_EXT |
| 194 | RGBA_DXT1 = 0x83F1, // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT |
| 195 | RGBA_DXT3 = 0x83F2, // GL_COMPRESSED_RGBA_S3TC_DXT3_EXT |
| 196 | RGBA_DXT5 = 0x83F3, // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT |
| 197 | R_ATI1N_UNorm = 0x8DBB, // GL_COMPRESSED_RED_RGTC1 |
| 198 | R_ATI1N_SNorm = 0x8DBC, // GL_COMPRESSED_SIGNED_RED_RGTC1 |
| 199 | RG_ATI2N_UNorm = 0x8DBD, // GL_COMPRESSED_RG_RGTC2 |
| 200 | RG_ATI2N_SNorm = 0x8DBE, // GL_COMPRESSED_SIGNED_RG_RGTC2 |
| 201 | RGB_BP_UNSIGNED_FLOAT = 0x8E8F, // GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB |
| 202 | RGB_BP_SIGNED_FLOAT = 0x8E8E, // GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB |
| 203 | RGB_BP_UNorm = 0x8E8C, // GL_COMPRESSED_RGBA_BPTC_UNORM_ARB |
| 204 | R11_EAC_UNorm = 0x9270, // GL_COMPRESSED_R11_EAC |
| 205 | R11_EAC_SNorm = 0x9271, // GL_COMPRESSED_SIGNED_R11_EAC |
| 206 | RG11_EAC_UNorm = 0x9272, // GL_COMPRESSED_RG11_EAC |
| 207 | RG11_EAC_SNorm = 0x9273, // GL_COMPRESSED_SIGNED_RG11_EAC |
| 208 | RGB8_ETC2 = 0x9274, // GL_COMPRESSED_RGB8_ETC2 |
| 209 | SRGB8_ETC2 = 0x9275, // GL_COMPRESSED_SRGB8_ETC2 |
| 210 | RGB8_PunchThrough_Alpha1_ETC2 = 0x9276, // GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 |
| 211 | SRGB8_PunchThrough_Alpha1_ETC2 = 0x9277, // GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 |
| 212 | RGBA8_ETC2_EAC = 0x9278, // GL_COMPRESSED_RGBA8_ETC2_EAC |
| 213 | SRGB8_Alpha8_ETC2_EAC = 0x9279, // GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC |
| 214 | RGB8_ETC1 = 0x8D64, // GL_ETC1_RGB8_OES |
| 215 | |
| 216 | // sRGB formats |
| 217 | SRGB8 = 0x8C41, // GL_SRGB8 |
| 218 | SRGB8_Alpha8 = 0x8C43, // GL_SRGB8_ALPHA8 |
| 219 | SRGB_DXT1 = 0x8C4C, // GL_COMPRESSED_SRGB_S3TC_DXT1_EXT |
| 220 | SRGB_Alpha_DXT1 = 0x8C4D, // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT |
| 221 | SRGB_Alpha_DXT3 = 0x8C4E, // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT |
| 222 | SRGB_Alpha_DXT5 = 0x8C4F, // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT |
| 223 | SRGB_BP_UNorm = 0x8E8D, // GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB |
| 224 | |
| 225 | // ES 2 formats |
| 226 | DepthFormat = 0x1902, // GL_DEPTH_COMPONENT |
| 227 | AlphaFormat = 0x1906, // GL_ALPHA |
| 228 | RGBFormat = 0x1907, // GL_RGB |
| 229 | RGBAFormat = 0x1908, // GL_RGBA |
| 230 | LuminanceFormat = 0x1909, // GL_LUMINANCE |
| 231 | LuminanceAlphaFormat = 0x190A |
| 232 | }; |
| 233 | Q_ENUM(TextureFormat) // LCOV_EXCL_LINE |
| 234 | |
| 235 | enum Filter { |
| 236 | Nearest = 0x2600, // GL_NEAREST |
| 237 | Linear = 0x2601, // GL_LINEAR |
| 238 | NearestMipMapNearest = 0x2700, // GL_NEAREST_MIPMAP_NEAREST |
| 239 | NearestMipMapLinear = 0x2702, // GL_NEAREST_MIPMAP_LINEAR |
| 240 | LinearMipMapNearest = 0x2701, // GL_LINEAR_MIPMAP_NEAREST |
| 241 | LinearMipMapLinear = 0x2703 // GL_LINEAR_MIPMAP_LINEAR |
| 242 | }; |
| 243 | Q_ENUM(Filter) // LCOV_EXCL_LINE |
| 244 | |
| 245 | enum CubeMapFace { |
| 246 | CubeMapPositiveX = 0x8515, // GL_TEXTURE_CUBE_MAP_POSITIVE_X |
| 247 | CubeMapNegativeX = 0x8516, // GL_TEXTURE_CUBE_MAP_NEGATIVE_X |
| 248 | CubeMapPositiveY = 0x8517, // GL_TEXTURE_CUBE_MAP_POSITIVE_Y |
| 249 | CubeMapNegativeY = 0x8518, // GL_TEXTURE_CUBE_MAP_NEGATIVE_Y |
| 250 | CubeMapPositiveZ = 0x8519, // GL_TEXTURE_CUBE_MAP_POSITIVE_Z |
| 251 | CubeMapNegativeZ = 0x851A, // GL_TEXTURE_CUBE_MAP_NEGATIVE_Z |
| 252 | AllFaces |
| 253 | }; |
| 254 | Q_ENUM(CubeMapFace) // LCOV_EXCL_LINE |
| 255 | |
| 256 | enum ComparisonFunction { |
| 257 | CompareLessEqual = 0x0203, // GL_LEQUAL |
| 258 | CompareGreaterEqual = 0x0206, // GL_GEQUAL |
| 259 | CompareLess = 0x0201, // GL_LESS |
| 260 | CompareGreater = 0x0204, // GL_GREATER |
| 261 | CompareEqual = 0x0202, // GL_EQUAL |
| 262 | CommpareNotEqual = 0x0205, // GL_NOTEQUAL |
| 263 | CompareAlways = 0x0207, // GL_ALWAYS |
| 264 | CompareNever = 0x0200 // GL_NEVER |
| 265 | }; |
| 266 | Q_ENUM(ComparisonFunction) // LCOV_EXCL_LINE |
| 267 | |
| 268 | enum ComparisonMode { |
| 269 | CompareRefToTexture = 0x884E, // GL_COMPARE_REF_TO_TEXTURE |
| 270 | CompareNone = 0x0000 // GL_NONE |
| 271 | }; |
| 272 | Q_ENUM(ComparisonMode) // LCOV_EXCL_LINE |
| 273 | |
| 274 | enum HandleType { |
| 275 | NoHandle, |
| 276 | OpenGLTextureId |
| 277 | }; |
| 278 | Q_ENUM(HandleType) // LCOV_EXCL_LINE |
| 279 | |
| 280 | ~QAbstractTexture(); |
| 281 | |
| 282 | Target target() const; |
| 283 | |
| 284 | TextureFormat format() const; |
| 285 | bool generateMipMaps() const; |
| 286 | |
| 287 | Status status() const; |
| 288 | |
| 289 | void addTextureImage(QAbstractTextureImage *textureImage); |
| 290 | void removeTextureImage(QAbstractTextureImage *textureImage); |
| 291 | QVector<QAbstractTextureImage *> textureImages() const; |
| 292 | |
| 293 | // sampler data - in the future proxy to a Sampler helper |
| 294 | void setWrapMode(const QTextureWrapMode &wrapMode); |
| 295 | QTextureWrapMode *wrapMode(); |
| 296 | |
| 297 | void setSize(int width, int height=1, int depth=1); |
| 298 | |
| 299 | Filter minificationFilter() const; |
| 300 | Filter magnificationFilter() const; |
| 301 | float maximumAnisotropy() const; |
| 302 | ComparisonFunction comparisonFunction() const; |
| 303 | ComparisonMode comparisonMode() const; |
| 304 | int width() const; |
| 305 | int height() const; |
| 306 | int depth() const; |
| 307 | int layers() const; |
| 308 | int samples() const; |
| 309 | Q3D_DECL_DEPRECATED QTextureGeneratorPtr dataGenerator() const; |
| 310 | HandleType handleType() const; |
| 311 | QVariant handle() const; |
| 312 | |
| 313 | Q_INVOKABLE void updateData(const QTextureDataUpdate &update); |
| 314 | |
| 315 | |
| 316 | public Q_SLOTS: |
| 317 | void setFormat(TextureFormat format); |
| 318 | void setGenerateMipMaps(bool gen); |
| 319 | void setWidth(int width); |
| 320 | void setHeight(int height); |
| 321 | void setDepth(int depth); |
| 322 | void setMinificationFilter(Filter f); |
| 323 | void setMagnificationFilter(Filter f); |
| 324 | void setMaximumAnisotropy(float anisotropy); |
| 325 | void setComparisonFunction(ComparisonFunction function); |
| 326 | void setComparisonMode(ComparisonMode mode); |
| 327 | void setLayers(int layers); |
| 328 | void setSamples(int samples); |
| 329 | |
| 330 | Q_SIGNALS: |
| 331 | void formatChanged(TextureFormat format); |
| 332 | void statusChanged(Status status); |
| 333 | void generateMipMapsChanged(bool generateMipMaps); |
| 334 | void widthChanged(int width); |
| 335 | void heightChanged(int height); |
| 336 | void depthChanged(int depth); |
| 337 | void magnificationFilterChanged(Filter magnificationFilter); |
| 338 | void minificationFilterChanged(Filter minificationFilter); |
| 339 | void maximumAnisotropyChanged(float maximumAnisotropy); |
| 340 | void comparisonFunctionChanged(ComparisonFunction comparisonFunction); |
| 341 | void comparisonModeChanged(ComparisonMode comparisonMode); |
| 342 | void layersChanged(int layers); |
| 343 | void samplesChanged(int samples); |
| 344 | Q_REVISION(13) void handleTypeChanged(HandleType handleType); |
| 345 | Q_REVISION(13) void handleChanged(QVariant handle); |
| 346 | |
| 347 | protected: |
| 348 | explicit QAbstractTexture(Qt3DCore::QNode *parent = nullptr); |
| 349 | explicit QAbstractTexture(Target target, Qt3DCore::QNode *parent = nullptr); |
| 350 | explicit QAbstractTexture(QAbstractTexturePrivate &dd, Qt3DCore::QNode *parent = nullptr); |
| 351 | void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override; |
| 352 | |
| 353 | // TO DO Qt6, should be on private class |
| 354 | void setStatus(Status status); |
| 355 | void setHandle(const QVariant &handle); |
| 356 | void setHandleType(HandleType type); |
| 357 | |
| 358 | private: |
| 359 | Q_DECLARE_PRIVATE(QAbstractTexture) |
| 360 | Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const override; |
| 361 | }; |
| 362 | |
| 363 | } // namespace Qt3DRender |
| 364 | |
| 365 | QT_END_NAMESPACE |
| 366 | |
| 367 | Q_DECLARE_METATYPE(Qt3DRender::QAbstractTexture *) // LCOV_EXCL_LINE |
| 368 | |
| 369 | #endif // QT3DRENDER_QABSTRACTTEXTURE_H |
| 370 |
Warning: That file was not part of the compilation database. It may have many parsing errors.
