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
4#ifndef QABSTRACTOPENGLTEXTURE_P_H
5#define QABSTRACTOPENGLTEXTURE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#ifndef QT_NO_OPENGL
19
20#include <QtOpenGL/qtopenglglobal.h>
21#include "private/qobject_p.h"
22#include "qopengltexture.h"
23#include "qopengl.h"
24
25#include <cmath>
26
27namespace {
28inline double qLog2(const double x)
29{
30 return std::log(x) / std::log(2.0);
31}
32}
33
34QT_BEGIN_NAMESPACE
35
36class QOpenGLContext;
38class QOpenGLFunctions;
39
41{
42public:
46
47 Q_DECLARE_PUBLIC(QOpenGLTexture)
48
51
52 bool create();
53 void destroy();
54
55 void bind();
56 void bind(uint unit, QOpenGLTexture::TextureUnitReset reset = QOpenGLTexture::DontResetTextureUnit);
57 void release();
58 void release(uint unit, QOpenGLTexture::TextureUnitReset reset = QOpenGLTexture::DontResetTextureUnit);
59 bool isBound() const;
60 bool isBound(uint unit) const;
61
62 void allocateStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType);
63 void allocateMutableStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType);
65 void setData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace,
66 QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType,
67 const void *data, const QOpenGLPixelTransferOptions * const options);
68 void setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth,
69 int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace,
70 QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType,
71 const void *data, const QOpenGLPixelTransferOptions * const options);
72 void setCompressedData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace,
73 int dataSize, const void *data,
74 const QOpenGLPixelTransferOptions * const options);
75
76
77 void setWrapMode(QOpenGLTexture::WrapMode mode);
78 void setWrapMode(QOpenGLTexture::CoordinateDirection direction, QOpenGLTexture::WrapMode mode);
80
81 QOpenGLTexture *createTextureView(QOpenGLTexture::Target target, QOpenGLTexture::TextureFormat viewFormat,
82 int minimumMipmapLevel, int maximumMipmapLevel,
83 int minimumLayer, int maximumLayer) const;
84
85 int evaluateMipLevels() const;
86
87 inline int maximumMipLevelCount() const
88 {
89 return 1 + std::floor(qLog2(qMax(dimensions[0], qMax(dimensions[1], dimensions[2]))));
90 }
91
92 static inline int mipLevelSize(int mipLevel, int baseLevelSize)
93 {
94 return std::floor(double(qMax(1, baseLevelSize >> mipLevel)));
95 }
96
97 bool isUsingImmutableStorage() const;
98
100 QOpenGLContext *context;
110 int faces;
111
114
117
122
131
135
137 QOpenGLFunctions *functions;
138
140};
141
142QT_END_NAMESPACE
143
144#undef Q_CALL_MEMBER_FUNCTION
145
146#endif // QT_NO_OPENGL
147
148#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
QOpenGLTexture * q_ptr
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)