Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qopengltexture_p.h
Go to the documentation of this file.
1// Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QABSTRACTOPENGLTEXTURE_P_H
6#define QABSTRACTOPENGLTEXTURE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#ifndef QT_NO_OPENGL
20
21#include <QtOpenGL/qtopenglglobal.h>
22#include "private/qobject_p.h"
23#include "qopengltexture.h"
24#include "qopengl.h"
25
26#include <cmath>
27
28namespace {
29inline double qLog2(const double x)
30{
31 return std::log(x) / std::log(2.0);
32}
33}
34
35QT_BEGIN_NAMESPACE
36
37class QOpenGLContext;
39class QOpenGLFunctions;
40
42{
43public:
47
48 Q_DECLARE_PUBLIC(QOpenGLTexture)
49
52
53 bool create();
54 void destroy();
55
56 void bind();
57 void bind(uint unit, QOpenGLTexture::TextureUnitReset reset = QOpenGLTexture::DontResetTextureUnit);
58 void release();
59 void release(uint unit, QOpenGLTexture::TextureUnitReset reset = QOpenGLTexture::DontResetTextureUnit);
60 bool isBound() const;
61 bool isBound(uint unit) const;
62
63 void allocateStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType);
64 void allocateMutableStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType);
66 void setData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace,
67 QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType,
68 const void *data, const QOpenGLPixelTransferOptions * const options);
69 void setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth,
70 int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace,
71 QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType,
72 const void *data, const QOpenGLPixelTransferOptions * const options);
73 void setCompressedData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace,
74 int dataSize, const void *data,
75 const QOpenGLPixelTransferOptions * const options);
76
77
78 void setWrapMode(QOpenGLTexture::WrapMode mode);
79 void setWrapMode(QOpenGLTexture::CoordinateDirection direction, QOpenGLTexture::WrapMode mode);
81
82 QOpenGLTexture *createTextureView(QOpenGLTexture::Target target, QOpenGLTexture::TextureFormat viewFormat,
83 int minimumMipmapLevel, int maximumMipmapLevel,
84 int minimumLayer, int maximumLayer) const;
85
86 int evaluateMipLevels() const;
87
88 inline int maximumMipLevelCount() const
89 {
90 return 1 + std::floor(qLog2(qMax(dimensions[0], qMax(dimensions[1], dimensions[2]))));
91 }
92
93 static inline int mipLevelSize(int mipLevel, int baseLevelSize)
94 {
95 return std::floor(double(qMax(1, baseLevelSize >> mipLevel)));
96 }
97
98 bool isUsingImmutableStorage() const;
99
101 QOpenGLContext *context;
111 int faces;
112
115
118
123
132
136
138 QOpenGLFunctions *functions;
139
141};
142
143QT_END_NAMESPACE
144
145#undef Q_CALL_MEMBER_FUNCTION
146
147#endif // QT_NO_OPENGL
148
149#endif // QABSTRACTOPENGLTEXTURE_P_H
QOpenGLTextureHelper(QOpenGLContext *context)
void setWrapMode(QOpenGLTexture::CoordinateDirection direction, QOpenGLTexture::WrapMode mode)
void allocateStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType)
void setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options)
void setData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options)
QOpenGLFunctions * functions
bool isUsingImmutableStorage() const
QOpenGLTexturePrivate(QOpenGLTexture::Target textureTarget, QOpenGLTexture *qq)
void allocateMutableStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType)
void setWrapMode(QOpenGLTexture::WrapMode mode)
int maximumMipLevelCount() const
void release(uint unit, QOpenGLTexture::TextureUnitReset reset=QOpenGLTexture::DontResetTextureUnit)
QOpenGLTexture * createTextureView(QOpenGLTexture::Target target, QOpenGLTexture::TextureFormat viewFormat, int minimumMipmapLevel, int maximumMipmapLevel, int minimumLayer, int maximumLayer) const
bool isBound(uint unit) const
void bind(uint unit, QOpenGLTexture::TextureUnitReset reset=QOpenGLTexture::DontResetTextureUnit)
void setCompressedData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, int dataSize, const void *data, const QOpenGLPixelTransferOptions *const options)
static int mipLevelSize(int mipLevel, int baseLevelSize)
QOpenGLTextureHelper * texFuncs
QOpenGLContext * context
\inmodule QtGui
Combined button and popup list for selecting options.
#define GL_TEXTURE_COMPARE_FUNC
Definition qopenglext.h:338
#define GL_TEXTURE0
Definition qopenglext.h:129
#define GL_TEXTURE_WRAP_R
Definition qopenglext.h:87
#define GL_TEXTURE_BASE_LEVEL
Definition qopenglext.h:103
#define GL_TEXTURE_MAX_LEVEL
Definition qopenglext.h:104
#define GL_ACTIVE_TEXTURE
Definition qopenglext.h:161
#define GL_TEXTURE_COMPARE_MODE
Definition qopenglext.h:337
static QOpenGLTexture::PixelFormat pixelFormatCompatibleWithInternalFormat(QOpenGLTexture::TextureFormat internalFormat)
static QOpenGLTexture::PixelType pixelTypeCompatibleWithInternalFormat(QOpenGLTexture::TextureFormat internalFormat)
static bool isNpot(int width, int height=1, int depth=1)
static bool isCompressedFormat(QOpenGLTexture::TextureFormat internalFormat)
static bool isTextureTargetMultisample(QOpenGLTexture::Target target)
static bool isSizedTextureFormat(QOpenGLTexture::TextureFormat internalFormat)