QOpenGLTexture Class
QOpenGLTexture 类封装了一个 OpenGL 纹理对象。更多内容...
| Header: | #include <QOpenGLTexture> |
公共类型
| enum | BindingTarget { BindingTarget1D, BindingTarget1DArray, BindingTarget2D, BindingTarget2DArray, BindingTarget3D, …, BindingTargetBuffer } |
| enum | ComparisonFunction { CompareLessEqual, CompareGreaterEqual, CompareLess, CompareGreater, CompareEqual, …, CompareNever } |
| enum | ComparisonMode { CompareRefToTexture, CompareNone } |
| enum | CoordinateDirection { DirectionS, DirectionT, DirectionR } |
| enum | CubeMapFace { CubeMapPositiveX, CubeMapNegativeX, CubeMapPositiveY, CubeMapNegativeY, CubeMapPositiveZ, CubeMapNegativeZ } |
| enum | DepthStencilMode { DepthMode, StencilMode } |
| enum | Feature { ImmutableStorage, ImmutableMultisampleStorage, TextureRectangle, TextureArrays, Texture3D, …, TextureMipMapLevel } |
| flags | Features |
| enum | Filter { Nearest, Linear, NearestMipMapNearest, NearestMipMapLinear, LinearMipMapNearest, LinearMipMapLinear } |
| enum | MipMapGeneration { GenerateMipMaps, DontGenerateMipMaps } |
| enum | PixelFormat { NoSourceFormat, Red, RG, RGB, BGR, …, LuminanceAlpha } |
| enum | PixelType { NoPixelType, Int8, UInt8, Int16, UInt16, …, Float32_D32_UInt32_S8_X24 } |
| enum | SwizzleComponent { SwizzleRed, SwizzleGreen, SwizzleBlue, SwizzleAlpha } |
| enum | SwizzleValue { RedValue, GreenValue, BlueValue, AlphaValue, ZeroValue, OneValue } |
| enum | Target { Target1D, Target1DArray, Target2D, Target2DArray, Target3D, …, TargetBuffer } |
| enum | TextureFormat { NoFormat, R8_UNorm, RG8_UNorm, RGB8_UNorm, RGBA8_UNorm, …, LuminanceAlphaFormat } |
| enum | TextureUnitReset { ResetTextureUnit, DontResetTextureUnit } |
| enum | WrapMode { Repeat, MirroredRepeat, ClampToEdge, ClampToBorder } |
公共函数
| QOpenGLTexture(QOpenGLTexture::Target target) | |
| QOpenGLTexture(const QImage &image, QOpenGLTexture::MipMapGeneration genMipMaps = GenerateMipMaps) | |
| void | allocateStorage() |
| void | allocateStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType) |
| void | bind() |
| void | bind(uint unit, QOpenGLTexture::TextureUnitReset reset = DontResetTextureUnit) |
| QColor | borderColor() const |
| void | borderColor(float *border) const |
| void | borderColor(int *border) const |
| void | borderColor(unsigned int *border) const |
| QOpenGLTexture::ComparisonFunction | comparisonFunction() const |
| QOpenGLTexture::ComparisonMode | comparisonMode() const |
| bool | create() |
| QOpenGLTexture * | createTextureView(QOpenGLTexture::Target target, QOpenGLTexture::TextureFormat viewFormat, int minimumMipmapLevel, int maximumMipmapLevel, int minimumLayer, int maximumLayer) const |
| int | depth() const |
| QOpenGLTexture::DepthStencilMode | depthStencilMode() const |
| void | destroy() |
| int | faces() const |
| QOpenGLTexture::TextureFormat | format() const |
| void | generateMipMaps() |
| void | generateMipMaps(int baseLevel, bool resetBaseLevel = true) |
| int | height() const |
| bool | isAutoMipMapGenerationEnabled() const |
| bool | isBound() const |
| bool | isBound(uint unit) |
| bool | isCreated() const |
| bool | isFixedSamplePositions() const |
| bool | isStorageAllocated() const |
| bool | isTextureView() const |
| int | layers() const |
| std::pair<float, float> | levelOfDetailRange() const |
| float | levelofDetailBias() const |
| QOpenGLTexture::Filter | magnificationFilter() const |
| float | maximumAnisotropy() const |
| float | maximumLevelOfDetail() const |
| int | maximumMipLevels() const |
| std::pair<QOpenGLTexture::Filter, QOpenGLTexture::Filter> | minMagFilters() const |
| QOpenGLTexture::Filter | minificationFilter() const |
| float | minimumLevelOfDetail() const |
| int | mipBaseLevel() const |
| std::pair<int, int> | mipLevelRange() const |
| int | mipLevels() const |
| int | mipMaxLevel() const |
| void | release() |
| void | release(uint unit, QOpenGLTexture::TextureUnitReset reset = DontResetTextureUnit) |
| int | samples() const |
| void | setAutoMipMapGenerationEnabled(bool enabled) |
| void | setBorderColor(const QColor &color) |
| void | setBorderColor(float r, float g, float b, float a) |
| void | setBorderColor(int r, int g, int b, int a) |
| void | setBorderColor(uint r, uint g, uint b, uint a) |
| void | setComparisonFunction(QOpenGLTexture::ComparisonFunction function) |
| void | setComparisonMode(QOpenGLTexture::ComparisonMode mode) |
| void | setCompressedData(int mipLevel, int layer, QOpenGLTexture::CubeMapFace cubeFace, int dataSize, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setCompressedData(int dataSize, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setCompressedData(int mipLevel, int dataSize, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setCompressedData(int mipLevel, int layer, int dataSize, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setCompressedData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, int dataSize, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setData(int mipLevel, int layer, QOpenGLTexture::CubeMapFace cubeFace, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setData(const QImage &image, QOpenGLTexture::MipMapGeneration genMipMaps = GenerateMipMaps) |
| void | setData(QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setData(int mipLevel, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setData(int mipLevel, int layer, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, int mipLevel, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, int mipLevel, int layer, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, int mipLevel, int layer, QOpenGLTexture::CubeMapFace face, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, int mipLevel, int layer, QOpenGLTexture::CubeMapFace face, int layerCount, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr) |
| void | setDepthStencilMode(QOpenGLTexture::DepthStencilMode mode) |
| void | setFixedSamplePositions(bool fixed) |
| void | setFormat(QOpenGLTexture::TextureFormat format) |
| void | setLayers(int layers) |
| void | setLevelOfDetailRange(float min, float max) |
| void | setLevelofDetailBias(float bias) |
| void | setMagnificationFilter(QOpenGLTexture::Filter filter) |
| void | setMaximumAnisotropy(float anisotropy) |
| void | setMaximumLevelOfDetail(float value) |
| void | setMinMagFilters(QOpenGLTexture::Filter minificationFilter, QOpenGLTexture::Filter magnificationFilter) |
| void | setMinificationFilter(QOpenGLTexture::Filter filter) |
| void | setMinimumLevelOfDetail(float value) |
| void | setMipBaseLevel(int baseLevel) |
| void | setMipLevelRange(int baseLevel, int maxLevel) |
| void | setMipLevels(int levels) |
| void | setMipMaxLevel(int maxLevel) |
| void | setSamples(int samples) |
| void | setSize(int width, int height = 1, int depth = 1) |
| void | setSwizzleMask(QOpenGLTexture::SwizzleComponent component, QOpenGLTexture::SwizzleValue value) |
| void | setSwizzleMask(QOpenGLTexture::SwizzleValue r, QOpenGLTexture::SwizzleValue g, QOpenGLTexture::SwizzleValue b, QOpenGLTexture::SwizzleValue a) |
| void | setWrapMode(QOpenGLTexture::WrapMode mode) |
| void | setWrapMode(QOpenGLTexture::CoordinateDirection direction, QOpenGLTexture::WrapMode mode) |
| QOpenGLTexture::SwizzleValue | swizzleMask(QOpenGLTexture::SwizzleComponent component) const |
| QOpenGLTexture::Target | target() const |
| GLuint | textureId() const |
| int | width() const |
| QOpenGLTexture::WrapMode | wrapMode(QOpenGLTexture::CoordinateDirection direction) const |
静态公共成员
| GLuint | boundTextureId(QOpenGLTexture::BindingTarget target) |
| GLuint | boundTextureId(uint unit, QOpenGLTexture::BindingTarget target) |
| bool | hasFeature(QOpenGLTexture::Feature feature) |
详细说明
QOpenGLTexture 使您能够轻松处理 OpenGL 纹理,以及根据您的 OpenGL 实现能力所提供的各种功能和目标。
QOpenGLTexture 的典型使用模式如下
- 通过指定纹理目标类型来实例化对象
- 设置影响存储要求的属性,例如存储格式、尺寸
- 分配服务器端存储空间
- 可选:上传像素数据
- 可选地设置其他属性,例如过滤和边界选项
- 使用纹理进行渲染或渲染到纹理
在通常情况下,如果仅将QImage 作为纹理像素数据的来源,上述大部分步骤都会自动完成。
// Prepare texture
QOpenGLTexture *texture = new QOpenGLTexture(QImage(fileName).flipped());
texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
texture->setMagnificationFilter(QOpenGLTexture::Linear);
...
// Render with texture
texture->bind();
glDrawArrays(...);请注意,QImage 已进行垂直翻转,以适应 OpenGL 和QImage 中 y 轴方向相反的情况。另一种方法是对纹理坐标进行变换。
警告: QOpenGLTexture 所使用的所有 数据均 应为可信内容。像素和图像数据会被传递给底层的 OpenGL 实现。建议应用程序开发人员在将用户提供的内容传递给setData() 等函数之前,仔细考虑潜在的影响。
成员类型文档
enum QOpenGLTexture::BindingTarget
此枚举定义了纹理单元的可能绑定目标。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::BindingTarget1D | 0x8068 | 等同于 GL_TEXTURE_BINDING_1D |
QOpenGLTexture::BindingTarget1DArray | 0x8C1C | 等同于 GL_TEXTURE_BINDING_1D_ARRAY |
QOpenGLTexture::BindingTarget2D | 0x8069 | 等同于 GL_TEXTURE_BINDING_2D |
QOpenGLTexture::BindingTarget2DArray | 0x8C1D | 等同于 GL_TEXTURE_BINDING_2D_ARRAY |
QOpenGLTexture::BindingTarget3D | 0x806A | 等同于 GL_TEXTURE_BINDING_3D |
QOpenGLTexture::BindingTargetCubeMap | 0x8514 | 等同于 GL_TEXTURE_BINDING_CUBE_MAP |
QOpenGLTexture::BindingTargetCubeMapArray | 0x900A | 等同于 GL_TEXTURE_BINDING_CUBE_MAP_ARRAY |
QOpenGLTexture::BindingTarget2DMultisample | 0x9104 | 等同于 GL_TEXTURE_BINDING_2D_MULTISAMPLE |
QOpenGLTexture::BindingTarget2DMultisampleArray | 0x9105 | 等同于 GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY |
QOpenGLTexture::BindingTargetRectangle | 0x84F6 | 等同于 GL_TEXTURE_BINDING_RECTANGLE |
QOpenGLTexture::BindingTargetBuffer | 0x8C2C | 等同于 GL_TEXTURE_BINDING_BUFFER |
enum QOpenGLTexture::ComparisonFunction
此枚举用于指定当此纹理启用纹理比较时,应使用哪种比较运算符。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::CompareLessEqual | 0x0203 | 等同于 GL_LEQUAL。 |
QOpenGLTexture::CompareGreaterEqual | 0x0206 | 等同于 GL_GEQUAL。 |
QOpenGLTexture::CompareLess | 0x0201 | 等同于 GL_LESS。 |
QOpenGLTexture::CompareGreater | 0x0204 | 等同于 GL_GREATER。 |
QOpenGLTexture::CompareEqual | 0x0202 | 等同于 GL_EQUAL。 |
QOpenGLTexture::CompareNotEqual | 0x0205 | 等同于 GL_NOTEQUAL。 |
QOpenGLTexture::CompareAlways | 0x0207 | 等同于 GL_ALWAYS。 |
QOpenGLTexture::CompareNever | 0x0200 | 等同于 GL_NEVER。 |
enum QOpenGLTexture::ComparisonMode
此枚举指定在采样此纹理时使用的比较模式。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::CompareRefToTexture | 0x884E | 等同于 GL_COMPARE_REF_TO_TEXTURE。 |
QOpenGLTexture::CompareNone | 0x0000 | 等同于 GL_NONE。 |
enum QOpenGLTexture::CoordinateDirection
此枚举定义了可能的纹理坐标方向
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::DirectionS | 0x2802 | 水平方向。等同于 GL_TEXTURE_WRAP_S |
QOpenGLTexture::DirectionT | 0x2803 | 垂直方向。等同于 GL_TEXTURE_WRAP_T |
QOpenGLTexture::DirectionR | 0x8072 | 深度方向。等同于 GL_TEXTURE_WRAP_R |
enum QOpenGLTexture::CubeMapFace
此枚举定义了 CubeMap 的可能面。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::CubeMapPositiveX | 0x8515 | 等同于 GL_TEXTURE_CUBE_MAP_POSITIVE_X |
QOpenGLTexture::CubeMapNegativeX | 0x8516 | 等同于 GL_TEXTURE_CUBE_MAP_NEGATIVE_X |
QOpenGLTexture::CubeMapPositiveY | 0x8517 | 等同于 GL_TEXTURE_CUBE_MAP_POSITIVE_Y |
QOpenGLTexture::CubeMapNegativeY | 0x8518 | 等同于 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y |
QOpenGLTexture::CubeMapPositiveZ | 0x8519 | 等同于 GL_TEXTURE_CUBE_MAP_POSITIVE_Z |
QOpenGLTexture::CubeMapNegativeZ | 0x851A | 等同于 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z |
enum QOpenGLTexture::DepthStencilMode
此枚举指定在采样纹理时访问深度/模板纹理的哪个组件。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::DepthMode | 0x1902 | 等同于 GL_DEPTH_COMPONENT。 |
QOpenGLTexture::StencilMode | 0x1901 | 等同于 GL_STENCIL_INDEX。 |
enum QOpenGLTexture::Feature
flags QOpenGLTexture::Features
此枚举定义了可进行测试的 OpenGL 纹理相关功能。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::ImmutableStorage | 0x00000001 | 对不可变纹理存储的支持 |
QOpenGLTexture::ImmutableMultisampleStorage | 0x00000002 | 支持具有多采样目标的不可变纹理存储 |
QOpenGLTexture::TextureRectangle | 0x00000004 | 支持 GL_TEXTURE_RECTANGLE 目标 |
QOpenGLTexture::TextureArrays | 0x00000008 | 支持具有数组层的纹理目标 |
QOpenGLTexture::Texture3D | 0x00000010 | 支持三维纹理目标 |
QOpenGLTexture::TextureMultisample | 0x00000020 | 支持具有多采样能力的纹理目标 |
QOpenGLTexture::TextureBuffer | 0x00000040 | 支持将 OpenGL 缓冲区对象用作数据源的纹理 |
QOpenGLTexture::TextureCubeMapArrays | 0x00000080 | 支持立方贴图数组纹理目标 |
QOpenGLTexture::Swizzle | 0x00000100 | 支持纹理分量交换掩码 |
QOpenGLTexture::StencilTexturing | 0x00000200 | 支持模板纹理(即在 GLSL 着色器中查询组合深度/模板格式纹理的深度或模板分量)。 |
QOpenGLTexture::AnisotropicFiltering | 0x00000400 | 支持各向异性纹理过滤 |
QOpenGLTexture::NPOTTextures | 0x00000800 | 对非二的幂纹理的基本支持 |
QOpenGLTexture::NPOTTextureRepeat | 0x00001000 | 全面支持非2的幂纹理,包括纹理重复模式 |
QOpenGLTexture::Texture1D | 0x00002000 | 支持一维纹理目标 |
QOpenGLTexture::TextureComparisonOperators | 0x00004000 | 支持纹理比较运算符 |
QOpenGLTexture::TextureMipMapLevel | 0x00008000 | 支持设置基础和最大 Mipmap 级别 |
“Features”类型是QFlags<Feature> 的 typedef 定义。它存储了 Feature 值的按“或”运算组合。
enum QOpenGLTexture::Filter
此枚举定义了QOpenGLTexture 对象的过滤参数。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::Nearest | 0x2600 | 等同于 GL_NEAREST |
QOpenGLTexture::Linear | 0x2601 | 等同于 GL_LINEAR |
QOpenGLTexture::NearestMipMapNearest | 0x2700 | 等同于 GL_NEAREST_MIPMAP_NEAREST |
QOpenGLTexture::NearestMipMapLinear | 0x2702 | 等同于 GL_NEAREST_MIPMAP_LINEAR |
QOpenGLTexture::LinearMipMapNearest | 0x2701 | 等同于 GL_LINEAR_MIPMAP_NEAREST |
QOpenGLTexture::LinearMipMapLinear | 0x2703 | 等同于 GL_LINEAR_MIPMAP_LINEAR |
enum QOpenGLTexture::MipMapGeneration
此枚举定义了用于控制Mipmap生成的选项。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::GenerateMipMaps | 0 | 应生成 Mipmap |
QOpenGLTexture::DontGenerateMipMaps | 1 | 不应生成Mipmap |
enum QOpenGLTexture::PixelFormat
此枚举定义了像素传输操作中客户端可能支持的像素格式。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::NoSourceFormat | 0 | 等同于 GL_NONE |
QOpenGLTexture::Red | 0x1903 | 等同于 GL_RED |
QOpenGLTexture::RG | 0x8227 | 等同于 GL_RG |
QOpenGLTexture::RGB | 0x1907 | 等同于 GL_RGB |
QOpenGLTexture::BGR | 0x80E0 | 等同于 GL_BGR |
QOpenGLTexture::RGBA | 0x1908 | 等同于 GL_RGBA |
QOpenGLTexture::BGRA | 0x80E1 | 等同于 GL_BGRA |
QOpenGLTexture::Red_Integer | 0x8D94 | 等同于 GL_RED_INTEGER |
QOpenGLTexture::RG_Integer | 0x8228 | 等同于 GL_RG_INTEGER |
QOpenGLTexture::RGB_Integer | 0x8D98 | 等同于 GL_RGB_INTEGER |
QOpenGLTexture::BGR_Integer | 0x8D9A | 等同于 GL_BGR_INTEGER |
QOpenGLTexture::RGBA_Integer | 0x8D99 | 等同于 GL_RGBA_INTEGER |
QOpenGLTexture::BGRA_Integer | 0x8D9B | 等同于 GL_BGRA_INTEGER |
QOpenGLTexture::Stencil | 0x1901 | 等同于 GL_STENCIL_INDEX。自 Qt 5.4 起引入 |
QOpenGLTexture::Depth | 0x1902 | 等同于 GL_DEPTH_COMPONENT |
QOpenGLTexture::DepthStencil | 0x84F9 | 等同于 GL_DEPTH_STENCIL |
QOpenGLTexture::Alpha | 0x1906 | 等同于 GL_ALPHA(仅限 OpenGL ES 2) |
QOpenGLTexture::Luminance | 0x1909 | 等同于 GL_LUMINANCE(仅限 OpenGL ES 2) |
QOpenGLTexture::LuminanceAlpha | 0x190A | 等同于 GL_LUMINANCE_ALPHA(仅限 OpenGL ES 2) |
enum QOpenGLTexture::PixelType
此枚举定义了像素传输操作中可能的像素数据类型
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::NoPixelType | 0 | 等同于 GL_NONE |
QOpenGLTexture::Int8 | 0x1400 | 等同于 GL_BYTE |
QOpenGLTexture::UInt8 | 0x1401 | 等同于 GL_UNSIGNED_BYTE |
QOpenGLTexture::Int16 | 0x1402 | 等同于 GL_SHORT |
QOpenGLTexture::UInt16 | 0x1403 | 等同于 GL_UNSIGNED_SHORT |
QOpenGLTexture::Int32 | 0x1404 | 等同于 GL_INT |
QOpenGLTexture::UInt32 | 0x1405 | 等同于 GL_UNSIGNED_INT |
QOpenGLTexture::Float16 | 0x140B | 等同于 GL_HALF_FLOAT |
QOpenGLTexture::Float16OES | 0x8D61 | 等同于 GL_HALF_FLOAT_OES |
QOpenGLTexture::Float32 | 0x1406 | 等同于 GL_FLOAT |
QOpenGLTexture::UInt32_RGB9_E5 | 0x8C3E | 等同于 GL_UNSIGNED_INT_5_9_9_9_REV |
QOpenGLTexture::UInt32_RG11B10F | 0x8C3B | 等同于 GL_UNSIGNED_INT_10F_11F_11F_REV |
QOpenGLTexture::UInt8_RG3B2 | 0x8032 | 等同于 GL_UNSIGNED_BYTE_3_3_2 |
QOpenGLTexture::UInt8_RG3B2_Rev | 0x8362 | 等同于 GL_UNSIGNED_BYTE_2_3_3_REV |
QOpenGLTexture::UInt16_RGB5A1 | 0x8034 | 等同于 GL_UNSIGNED_SHORT_5_5_5_1 |
QOpenGLTexture::UInt16_RGB5A1_Rev | 0x8366 | 等同于 GL_UNSIGNED_SHORT_1_5_5_5_REV |
QOpenGLTexture::UInt16_R5G6B5 | 0x8363 | 等同于 GL_UNSIGNED_SHORT_5_6_5 |
QOpenGLTexture::UInt16_R5G6B5_Rev | 0x8364 | 等同于 GL_UNSIGNED_SHORT_5_6_5_REV |
QOpenGLTexture::UInt16_RGBA4 | 0x8033 | 等同于 GL_UNSIGNED_SHORT_4_4_4_4 |
QOpenGLTexture::UInt16_RGBA4_Rev | 0x8365 | 等同于 GL_UNSIGNED_SHORT_4_4_4_4_REV |
QOpenGLTexture::UInt32_RGBA8 | 0x8035 | 等同于 GL_UNSIGNED_INT_8_8_8_8 |
QOpenGLTexture::UInt32_RGBA8_Rev | 0x8367 | 等同于 GL_UNSIGNED_INT_8_8_8_8_REV |
QOpenGLTexture::UInt32_RGB10A2 | 0x8036 | 等同于 GL_UNSIGNED_INT_10_10_10_2 |
QOpenGLTexture::UInt32_RGB10A2_Rev | 0x8368 | 等同于 GL_UNSIGNED_INT_2_10_10_10_REV |
QOpenGLTexture::UInt32_D24S8 | 0x84FA | 等同于 GL_UNSIGNED_INT_24_8。在 Qt 5.4 中引入 |
QOpenGLTexture::Float32_D32_UInt32_S8_X24 | 0x8DAD | 等同于 GL_FLOAT_32_UNSIGNED_INT_24_8_REV。自 Qt 5.4 起引入 |
enum QOpenGLTexture::SwizzleComponent
此枚举定义了可分配混淆掩码的纹理颜色分量。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::SwizzleRed | 0x8E42 | 红色分量。等同于 GL_TEXTURE_SWIZZLE_R |
QOpenGLTexture::SwizzleGreen | 0x8E43 | 绿色分量。等同于 GL_TEXTURE_SWIZZLE_G |
QOpenGLTexture::SwizzleBlue | 0x8E44 | 蓝色分量。等同于 GL_TEXTURE_SWIZZLE_B |
QOpenGLTexture::SwizzleAlpha | 0x8E45 | Alpha分量。等同于 GL_TEXTURE_SWIZZLE_A |
enum QOpenGLTexture::SwizzleValue
此枚举定义了纹理交换的可能掩码值。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::RedValue | 0x1903 | 将该分量映射到红色通道。等同于 GL_RED |
QOpenGLTexture::GreenValue | 0x1904 | 将该分量映射到绿色通道。等同于 GL_GREEN |
QOpenGLTexture::BlueValue | 0x1905 | 将该分量映射到蓝色通道。等同于 GL_BLUE |
QOpenGLTexture::AlphaValue | 0x1906 | 将该分量映射到透明度通道。等同于 GL_ALPHA |
QOpenGLTexture::ZeroValue | 0 | 将该分量映射到固定值 0。等同于 GL_ZERO |
QOpenGLTexture::OneValue | 1 | 将该分量映射到固定值 1。等同于 GL_ONE |
enum QOpenGLTexture::Target
此枚举定义了QOpenGLTexture 对象的纹理目标。有关创建数组纹理的更多信息,请参阅“数组纹理”。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::Target1D | 0x0DE0 | 一维纹理。等同于 GL_TEXTURE_1D。 |
QOpenGLTexture::Target1DArray | 0x8C18 | 一维纹理的数组。等同于 GL_TEXTURE_1D_ARRAY |
QOpenGLTexture::Target2D | 0x0DE1 | 一个二维纹理。等同于 GL_TEXTURE_2D |
QOpenGLTexture::Target2DArray | 0x8C1A | 二维纹理数组。等同于 GL_TEXTURE_2D_ARRAY |
QOpenGLTexture::Target3D | 0x806F | 一个三维纹理。等同于 GL_TEXTURE_3D |
QOpenGLTexture::TargetCubeMap | 0x8513 | 立方贴图。等同于 GL_TEXTURE_CUBE_MAP |
QOpenGLTexture::TargetCubeMapArray | 0x9009 | 立方贴图纹理数组。等同于 GL_TEXTURE_CUBE_MAP_ARRAY |
QOpenGLTexture::Target2DMultisample | 0x9100 | 支持多采样的二维纹理。等同于 GL_TEXTURE_2D_MULTISAMPLE |
QOpenGLTexture::Target2DMultisampleArray | 0x9102 | 支持多采样的二维纹理数组。等同于 GL_TEXTURE_2D_MULTISAMPLE_ARRAY |
QOpenGLTexture::TargetRectangle | 0x84F5 | 矩形二维纹理。等同于 GL_TEXTURE_RECTANGLE |
QOpenGLTexture::TargetBuffer | 0x8C2A | 数据来自 OpenGL 缓冲区对象的纹理。等同于 GL_TEXTURE_BUFFER |
enum QOpenGLTexture::TextureFormat
此枚举定义了可能的纹理格式。根据您的 OpenGL 实现情况,可能仅支持其中的一部分。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::NoFormat | 0 | 等同于 GL_NONE |
QOpenGLTexture::R8_UNorm | 0x8229 | 等同于 GL_R8 |
QOpenGLTexture::RG8_UNorm | 0x822B | 等同于 GL_RG8 |
QOpenGLTexture::RGB8_UNorm | 0x8051 | 等同于 GL_RGB8 |
QOpenGLTexture::RGBA8_UNorm | 0x8058 | 等同于 GL_RGBA8 |
QOpenGLTexture::R16_UNorm | 0x822A | 等同于 GL_R16 |
QOpenGLTexture::RG16_UNorm | 0x822C | 等同于 GL_RG16 |
QOpenGLTexture::RGB16_UNorm | 0x8054 | 等同于 GL_RGB16 |
QOpenGLTexture::RGBA16_UNorm | 0x805B | 等同于 GL_RGBA16 |
QOpenGLTexture::R8_SNorm | 0x8F94 | 等同于 GL_R8_SNORM |
QOpenGLTexture::RG8_SNorm | 0x8F95 | 等同于 GL_RG8_SNORM |
QOpenGLTexture::RGB8_SNorm | 0x8F96 | 等同于 GL_RGB8_SNORM |
QOpenGLTexture::RGBA8_SNorm | 0x8F97 | 等同于 GL_RGBA8_SNORM |
QOpenGLTexture::R16_SNorm | 0x8F98 | 等同于 GL_R16_SNORM |
QOpenGLTexture::RG16_SNorm | 0x8F99 | 等同于 GL_RG16_SNORM |
QOpenGLTexture::RGB16_SNorm | 0x8F9A | 等同于 GL_RGB16_SNORM |
QOpenGLTexture::RGBA16_SNorm | 0x8F9B | 等同于 GL_RGBA16_SNORM |
QOpenGLTexture::R8U | 0x8232 | 等同于 GL_R8UI |
QOpenGLTexture::RG8U | 0x8238 | 等同于 GL_RG8UI |
QOpenGLTexture::RGB8U | 0x8D7D | 等同于 GL_RGB8UI |
QOpenGLTexture::RGBA8U | 0x8D7C | 等同于 GL_RGBA8UI |
QOpenGLTexture::R16U | 0x8234 | 等同于 GL_R16UI |
QOpenGLTexture::RG16U | 0x823A | 等同于 GL_RG16UI |
QOpenGLTexture::RGB16U | 0x8D77 | 等同于 GL_RGB16UI |
QOpenGLTexture::RGBA16U | 0x8D76 | 等同于 GL_RGBA16UI |
QOpenGLTexture::R32U | 0x8236 | 等同于 GL_R32UI |
QOpenGLTexture::RG32U | 0x823C | 等同于 GL_RG32UI |
QOpenGLTexture::RGB32U | 0x8D71 | 等同于 GL_RGB32UI |
QOpenGLTexture::RGBA32U | 0x8D70 | 等同于 GL_RGBA32UI |
QOpenGLTexture::R8I | 0x8231 | 等同于 GL_R8I |
QOpenGLTexture::RG8I | 0x8237 | 等同于 GL_RG8I |
QOpenGLTexture::RGB8I | 0x8D8F | 等同于 GL_RGB8I |
QOpenGLTexture::RGBA8I | 0x8D8E | 等同于 GL_RGBA8I |
QOpenGLTexture::R16I | 0x8233 | 等同于 GL_R16I |
QOpenGLTexture::RG16I | 0x8239 | 等同于 GL_RG16I |
QOpenGLTexture::RGB16I | 0x8D89 | 等同于 GL_RGB16I |
QOpenGLTexture::RGBA16I | 0x8D88 | 等同于 GL_RGBA16I |
QOpenGLTexture::R32I | 0x8235 | 等同于 GL_R32I |
QOpenGLTexture::RG32I | 0x823B | 等同于 GL_RG32I |
QOpenGLTexture::RGB32I | 0x8D83 | 等同于 GL_RGB32I |
QOpenGLTexture::RGBA32I | 0x8D82 | 等同于 GL_RGBA32I |
QOpenGLTexture::R16F | 0x822D | 等同于 GL_R16F |
QOpenGLTexture::RG16F | 0x822F | 等同于 GL_RG16F |
QOpenGLTexture::RGB16F | 0x881B | 等同于 GL_RGB16F |
QOpenGLTexture::RGBA16F | 0x881A | 等同于 GL_RGBA16F |
QOpenGLTexture::R32F | 0x822E | 等同于 GL_R32F |
QOpenGLTexture::RG32F | 0x8230 | 等同于 GL_RG32F |
QOpenGLTexture::RGB32F | 0x8815 | 等同于 GL_RGB32F |
QOpenGLTexture::RGBA32F | 0x8814 | 等同于 GL_RGBA32F |
QOpenGLTexture::RGB9E5 | 0x8C3D | 等同于 GL_RGB9_E5 |
QOpenGLTexture::RG11B10F | 0x8C3A | 等同于 GL_R11F_G11F_B10F |
QOpenGLTexture::RG3B2 | 0x2A10 | 等同于 GL_R3_G3_B2 |
QOpenGLTexture::R5G6B5 | 0x8D62 | 等同于 GL_RGB565 |
QOpenGLTexture::RGB5A1 | 0x8057 | 等同于 GL_RGB5_A1 |
QOpenGLTexture::RGBA4 | 0x8056 | 等同于 GL_RGBA4 |
QOpenGLTexture::RGB10A2 | 0x906F | 等同于 GL_RGB10_A2UI |
QOpenGLTexture::D16 | 0x81A5 | 等同于 GL_DEPTH_COMPONENT16 |
QOpenGLTexture::D24 | 0x81A6 | 等同于 GL_DEPTH_COMPONENT24 |
QOpenGLTexture::D24S8 | 0x88F0 | 等同于 GL_DEPTH24_STENCIL8 |
QOpenGLTexture::D32 | 0x81A7 | 等同于 GL_DEPTH_COMPONENT32 |
QOpenGLTexture::D32F | 0x8CAC | 等同于 GL_DEPTH_COMPONENT32F |
QOpenGLTexture::D32FS8X24 | 0x8CAD | 等同于 GL_DEPTH32F_STENCIL8 |
QOpenGLTexture::S8 | 0x8D48 | 等同于 GL_STENCIL_INDEX8。自 Qt 5.4 起引入 |
QOpenGLTexture::RGB_DXT1 | 0x83F0 | 等同于 GL_COMPRESSED_RGB_S3TC_DXT1_EXT |
QOpenGLTexture::RGBA_DXT1 | 0x83F1 | 等同于 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT |
QOpenGLTexture::RGBA_DXT3 | 0x83F2 | 等同于 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT |
QOpenGLTexture::RGBA_DXT5 | 0x83F3 | 等同于 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT |
QOpenGLTexture::R_ATI1N_UNorm | 0x8DBB | 等同于 GL_COMPRESSED_RED_RGTC1 |
QOpenGLTexture::R_ATI1N_SNorm | 0x8DBC | 等同于 GL_COMPRESSED_SIGNED_RED_RGTC1 |
QOpenGLTexture::RG_ATI2N_UNorm | 0x8DBD | 等同于 GL_COMPRESSED_RG_RGTC2 |
QOpenGLTexture::RG_ATI2N_SNorm | 0x8DBE | 等同于 GL_COMPRESSED_SIGNED_RG_RGTC2 |
QOpenGLTexture::RGB_BP_UNSIGNED_FLOAT | 0x8E8F | 等同于 GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB |
QOpenGLTexture::RGB_BP_SIGNED_FLOAT | 0x8E8E | 等同于 GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB |
QOpenGLTexture::RGB_BP_UNorm | 0x8E8C | 等同于 GL_COMPRESSED_RGBA_BPTC_UNORM_ARB |
QOpenGLTexture::R11_EAC_UNorm | 0x9270 | 等同于 GL_COMPRESSED_R11_EAC |
QOpenGLTexture::R11_EAC_SNorm | 0x9271 | 等同于 GL_COMPRESSED_SIGNED_R11_EAC |
QOpenGLTexture::RG11_EAC_UNorm | 0x9272 | 等同于 GL_COMPRESSED_RG11_EAC |
QOpenGLTexture::RG11_EAC_SNorm | 0x9273 | 等同于 GL_COMPRESSED_SIGNED_RG11_EAC |
QOpenGLTexture::RGB8_ETC2 | 0x9274 | 等同于 GL_COMPRESSED_RGB8_ETC2 |
QOpenGLTexture::SRGB8_ETC2 | 0x9275 | 等同于 GL_COMPRESSED_SRGB8_ETC2 |
QOpenGLTexture::RGB8_PunchThrough_Alpha1_ETC2 | 0x9276 | 等同于 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 |
QOpenGLTexture::SRGB8_PunchThrough_Alpha1_ETC2 | 0x9277 | 等同于 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 |
QOpenGLTexture::RGBA8_ETC2_EAC | 0x9278 | 等同于 GL_COMPRESSED_RGBA8_ETC2_EAC |
QOpenGLTexture::SRGB8_Alpha8_ETC2_EAC | 0x9279 | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC |
QOpenGLTexture::RGB8_ETC1 | 0x8D64 | 等同于 GL_ETC1_RGB8_OES |
QOpenGLTexture::RGBA_ASTC_4x4 | 0x93B0 | 等同于 GL_COMPRESSED_RGBA_ASTC_4x4_KHR |
QOpenGLTexture::RGBA_ASTC_5x4 | 0x93B1 | 等同于 GL_COMPRESSED_RGBA_ASTC_5x4_KHR |
QOpenGLTexture::RGBA_ASTC_5x5 | 0x93B2 | 等同于 GL_COMPRESSED_RGBA_ASTC_5x5_KHR |
QOpenGLTexture::RGBA_ASTC_6x5 | 0x93B3 | 等同于 GL_COMPRESSED_RGBA_ASTC_6x5_KHR |
QOpenGLTexture::RGBA_ASTC_6x6 | 0x93B4 | 等同于 GL_COMPRESSED_RGBA_ASTC_6x6_KHR |
QOpenGLTexture::RGBA_ASTC_8x5 | 0x93B5 | 等同于 GL_COMPRESSED_RGBA_ASTC_8x5_KHR |
QOpenGLTexture::RGBA_ASTC_8x6 | 0x93B6 | 等同于 GL_COMPRESSED_RGBA_ASTC_8x6_KHR |
QOpenGLTexture::RGBA_ASTC_8x8 | 0x93B7 | 等同于 GL_COMPRESSED_RGBA_ASTC_8x8_KHR |
QOpenGLTexture::RGBA_ASTC_10x5 | 0x93B8 | 等同于 GL_COMPRESSED_RGBA_ASTC_10x5_KHR |
QOpenGLTexture::RGBA_ASTC_10x6 | 0x93B9 | 等同于 GL_COMPRESSED_RGBA_ASTC_10x6_KHR |
QOpenGLTexture::RGBA_ASTC_10x8 | 0x93BA | 等同于 GL_COMPRESSED_RGBA_ASTC_10x8_KHR |
QOpenGLTexture::RGBA_ASTC_10x10 | 0x93BB | 等同于 GL_COMPRESSED_RGBA_ASTC_10x10_KHR |
QOpenGLTexture::RGBA_ASTC_12x10 | 0x93BC | 等同于 GL_COMPRESSED_RGBA_ASTC_12x10_KHR |
QOpenGLTexture::RGBA_ASTC_12x12 | 0x93BD | 等同于 GL_COMPRESSED_RGBA_ASTC_12x12_KHR |
QOpenGLTexture::SRGB8_Alpha8_ASTC_4x4 | 0x93D0 | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR |
QOpenGLTexture::SRGB8_Alpha8_ASTC_5x4 | 0x93D1 | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR |
QOpenGLTexture::SRGB8_Alpha8_ASTC_5x5 | 0x93D2 | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR |
QOpenGLTexture::SRGB8_Alpha8_ASTC_6x5 | 0x93D3 | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR |
QOpenGLTexture::SRGB8_Alpha8_ASTC_6x6 | 0x93D4 | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR |
QOpenGLTexture::SRGB8_Alpha8_ASTC_8x5 | 0x93D5 | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR |
QOpenGLTexture::SRGB8_Alpha8_ASTC_8x6 | 0x93D6 | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR |
QOpenGLTexture::SRGB8_Alpha8_ASTC_8x8 | 0x93D7 | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR |
QOpenGLTexture::SRGB8_Alpha8_ASTC_10x5 | 0x93D8 | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR |
QOpenGLTexture::SRGB8_Alpha8_ASTC_10x6 | 0x93D9 | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR |
QOpenGLTexture::SRGB8_Alpha8_ASTC_10x8 | 0x93DA | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR |
QOpenGLTexture::SRGB8_Alpha8_ASTC_10x10 | 0x93DB | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR |
QOpenGLTexture::SRGB8_Alpha8_ASTC_12x10 | 0x93DC | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR |
QOpenGLTexture::SRGB8_Alpha8_ASTC_12x12 | 0x93DD | 等同于 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR |
QOpenGLTexture::SRGB8 | 0x8C41 | 等同于 GL_SRGB8 |
QOpenGLTexture::SRGB8_Alpha8 | 0x8C43 | 等同于 GL_SRGB8_ALPHA8 |
QOpenGLTexture::SRGB_DXT1 | 0x8C4C | 等同于 GL_COMPRESSED_SRGB_S3TC_DXT1_EXT |
QOpenGLTexture::SRGB_Alpha_DXT1 | 0x8C4D | 等同于 GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT |
QOpenGLTexture::SRGB_Alpha_DXT3 | 0x8C4E | 等同于 GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT |
QOpenGLTexture::SRGB_Alpha_DXT5 | 0x8C4F | 等同于 GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT |
QOpenGLTexture::SRGB_BP_UNorm | 0x8E8D | 等同于 GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB |
QOpenGLTexture::DepthFormat | 0x1902 | 等同于 GL_DEPTH_COMPONENT(仅限 OpenGL ES 3 或带 OES_depth_texture 的 ES 2) |
QOpenGLTexture::AlphaFormat | 0x1906 | 等同于 GL_ALPHA(仅限 OpenGL ES 2) |
QOpenGLTexture::RGBFormat | 0x1907 | 等同于 GL_RGB(仅限 OpenGL ES 2) |
QOpenGLTexture::RGBAFormat | 0x1908 | 等同于 GL_RGBA(仅限 OpenGL ES 2) |
QOpenGLTexture::LuminanceFormat | 0x1909 | 等同于 GL_LUMINANCE(仅限 OpenGL ES 2) |
QOpenGLTexture::LuminanceAlphaFormat | 0x190A | 等同于 GL_LUMINANCE_ALPHA(仅限 OpenGL ES 2) |
enum QOpenGLTexture::TextureUnitReset
此枚举定义了用于控制纹理单元激活的选项。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::ResetTextureUnit | 0 | 将重置上一个活动的纹理单元 |
QOpenGLTexture::DontResetTextureUnit | 1 | 先前处于活动状态的纹理单元不会被重置 |
enum QOpenGLTexture::WrapMode
此枚举定义了可能的纹理坐标环绕模式。
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLTexture::Repeat | 0x2901 | 纹理坐标会重复。等同于 GL_REPEAT |
QOpenGLTexture::MirroredRepeat | 0x8370 | 纹理坐标以 0 和 1 为轴进行镜像重复。等同于 GL_MIRRORED_REPEAT |
QOpenGLTexture::ClampToEdge | 0x812F | 将纹理坐标限制在 [0,1] 范围内。等同于 GL_CLAMP_TO_EDGE |
QOpenGLTexture::ClampToBorder | 0x812D | 与 ClampToEdge 类似,但还会使用固定的边框颜色对 0 和 1 处的采样点进行混合。等同于 GL_CLAMP_TO_BORDER |
成员函数文档
[explicit] QOpenGLTexture::QOpenGLTexture(QOpenGLTexture::Target target)
创建一个 QOpenGLTexture 对象,该对象随后可绑定到target 。
这不会创建底层的 OpenGL 纹理对象。因此,使用此构造函数进行初始化时,无需有效的当前 OpenGL 上下文。
[explicit] QOpenGLTexture::QOpenGLTexture(const QImage &image, QOpenGLTexture::MipMapGeneration genMipMaps = GenerateMipMaps)
创建一个 QOpenGLTexture 对象,该对象稍后可绑定到 2D 纹理目标,并包含image 中的像素数据。如果希望生成一组 Mipmap,请将genMipMaps 设置为true (这是默认值)。
这确实会创建底层的 OpenGL 纹理对象。因此,使用此构造函数进行初始化需要一个有效的当前 OpenGL 上下文。
注意: image 会自动转换为QImage::Format_RGBA8888 ,对于格式不同的大尺寸图像,这可能会影响性能。
void QOpenGLTexture::allocateStorage()
为该纹理对象分配服务器端存储空间,同时考虑其格式、尺寸、Mipmap 级别、数组层和立方体贴图面。
一旦存储空间被分配,就无法再更改这些属性。
如果支持,QOpenGLTexture 将使用不可变纹理存储。
为纹理分配存储空间后,即可通过setData() 的其中一个重载函数上传像素数据。
注意:如果 不可变纹理存储不可用,则将使用默认的像素格式和像素类型来创建可变存储。您可以使用其他 `allocateStorage()` 重载方法来精确指定分配可变存储时要使用的像素格式和像素类型; 这在某些 OpenGL ES 实现(尤其是 OpenGL ES 2)中特别有用,因为在这些实现中,分配时使用的像素格式和像素类型必须与后续任何setData() 调用中传递的格式和类型完全匹配。
另请参阅 isStorageAllocated() 和setData()。
void QOpenGLTexture::allocateStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType)
为该纹理对象分配服务器端存储空间,同时考虑其格式、尺寸、Mipmap 级别、数组层和立方体贴图面。
一旦存储空间被分配,就无法再更改这些属性。
如果支持,QOpenGLTexture 将使用不可变纹理存储。但是,如果不可变纹理存储不可用,则将使用指定的pixelFormat 和pixelType 来分配可变存储;请注意,在某些 OpenGL 实现中(尤其是 OpenGL ES 2),它们必须与传递给任何后续setData() 调用的格式和类型完全匹配。
一旦为纹理分配了存储空间,即可通过其中一个setData()的重载函数上传像素数据。
另请参阅 isStorageAllocated() 和setData()。
void QOpenGLTexture::bind()
将此纹理绑定到当前活动的纹理单元,以便进行渲染。请注意,您无需绑定QOpenGLTexture 对象即可对其进行修改,因为该实现会在支持的情况下使用EXT_direct_state_access扩展,而在不支持时则会模拟该扩展。
另请参阅 release()。
void QOpenGLTexture::bind(uint unit, QOpenGLTexture::TextureUnitReset reset = DontResetTextureUnit)
将此纹理绑定到纹理单元unit ,以便进行渲染。请注意,您无需绑定QOpenGLTexture 对象即可对其进行修改,因为该实现会在可用时使用 EXT_direct_state_access 扩展,而在不可用时则对其进行模拟。
如果参数reset 为true ,则该函数将把当前活动单元恢复为函数调用时的活动纹理单元。
另请参阅 release()。
QColor QOpenGLTexture::borderColor() const
返回此纹理的边框颜色。
另请参阅 ` setBorderColor()`。
void QOpenGLTexture::borderColor(float *border) const
将纹理边框颜色写入由 `border` 指向的数组的前四个元素中。
另请参阅 setBorderColor()。
void QOpenGLTexture::borderColor(int *border) const
将纹理边框颜色写入由border 指针所指向的数组的前四个元素中。
这是一个重载函数。
void QOpenGLTexture::borderColor(unsigned int *border) const
将纹理边框颜色写入由border 所指向的数组的前四个元素中。
这是一个重载函数。
[static] GLuint QOpenGLTexture::boundTextureId(QOpenGLTexture::BindingTarget target)
返回绑定到当前活动纹理单元target 上的纹理的textureId 。
[static] GLuint QOpenGLTexture::boundTextureId(uint unit, QOpenGLTexture::BindingTarget target)
返回绑定到纹理单元unit 的target 上的纹理的textureId 。
QOpenGLTexture::ComparisonFunction QOpenGLTexture::comparisonFunction() const
返回为该纹理设置的纹理比较运算符。默认情况下,纹理使用CompareLessEqual 比较函数。
另请参阅 setComparisonFunction()。
QOpenGLTexture::ComparisonMode QOpenGLTexture::comparisonMode() const
返回此纹理上设置的纹理比较模式。默认情况下,纹理的比较模式为CompareNone (即禁用比较)。
另请参阅 setComparisonMode()。
bool QOpenGLTexture::create()
创建底层的 OpenGL 纹理对象。这需要一个当前有效的 OpenGL 上下文。如果纹理对象已经存在,则该函数不执行任何操作。
纹理对象创建完成后,可通过textureId()函数获取对象名称。若需针对该纹理进行一些原始的OpenGL调用,此功能可能会派上用场。
通常情况下无需直接调用此函数,因为所有用于设置纹理对象属性的函数都会隐式地为您调用 create()。
若创建成功,则返回true ;否则返回false 。
另请参阅 destroy()、isCreated() 和textureId()。
QOpenGLTexture *QOpenGLTexture::createTextureView(QOpenGLTexture::Target target, QOpenGLTexture::TextureFormat viewFormat, int minimumMipmapLevel, int maximumMipmapLevel, int minimumLayer, int maximumLayer) const
尝试在此纹理上创建一个纹理视图。纹理视图与 SQL 中的视图有些类似,它呈现的是原始数据的受限或重新解释的视图。纹理视图不会在服务器端分配额外的存储空间,而是依赖源纹理的存储缓冲区。
纹理视图仅在使用不可变存储时可用。有关纹理视图的更多信息,请参阅 http://www.opengl.org/wiki/Texture_Storage#Texture_views。
target 参数指定了视图所使用的目标。根据原始纹理的目标类型,仅可使用部分目标。例如,针对Target1DArray 纹理的视图可以指定Target1DArray 或Target1D ,但对于后者,通过minimumLayer 和maximumLayer 指定的数组层数必须恰好为1。
对于viewFormat ,同样适用上述约束条件。更多详情请参阅上述链接及规范文档。
参数minimumMipmapLevel 、maximumMipmapLevel 、minimumLayer 和maximumLayer 用于限制纹理视图可访问的纹理部分。
如果纹理视图的创建失败,该函数将返回 0。如果函数成功,它将返回一个指向新QOpenGLTexture 对象的指针,该对象的isTextureView() 函数将返回true 。
另请参阅 isTextureView()。
int QOpenGLTexture::depth() const
返回 3D 纹理的深度。
另请参阅 width()、height() 和setSize()。
QOpenGLTexture::DepthStencilMode QOpenGLTexture::depthStencilMode() const
返回使用组合深度/模板格式的纹理的深度模板模式。
另请参阅 setDepthStencilMode()。
void QOpenGLTexture::destroy()
销毁底层的 OpenGL 纹理对象。此操作需要当前存在有效的 OpenGL 上下文。
另请参阅 create()、isCreated() 和textureId()。
int QOpenGLTexture::faces() const
返回此纹理的面数。对于立方贴图和立方贴图数组类型的目标,该值将为 6。
对于非立方贴图类型的目标,该函数将返回 1。
QOpenGLTexture::TextureFormat QOpenGLTexture::format() const
返回此纹理对象的格式。
另请参阅 setFormat()。
void QOpenGLTexture::generateMipMaps()
根据Mipmap级别0为该纹理对象生成Mipmap。如果您使用的纹理目标和过滤选项需要Mipmap,且已禁用自动生成Mipmap的功能,则需要调用此函数或其重载来创建Mipmap链。
注意: OpenGL ES 不支持对压缩纹理生成Mipmap 。
另请参阅 setAutoMipMapGenerationEnabled()、setMipLevels() 和mipLevels()。
void QOpenGLTexture::generateMipMaps(int baseLevel, bool resetBaseLevel = true)
根据米普贴图级别baseLevel 为该纹理对象生成米普贴图。如果您使用的纹理目标和过滤选项需要米普贴图,但已禁用自动生成米普贴图功能,则需要调用此函数或其重载来创建米普贴图链。
要生成高于baseLevel 的微图,需将微图基级设置为baseLevel ,然后生成微图链。如果resetBaseLevel 的值为true ,则纹理的baseLevel将被重置为其之前的值。
另请参阅 setAutoMipMapGenerationEnabled()、setMipLevels() 和mipLevels()。
[static] bool QOpenGLTexture::hasFeature(QOpenGLTexture::Feature feature)
如果您的 OpenGL 实现和版本支持纹理特性feature ,则返回true 。
int QOpenGLTexture::height() const
返回 2D 或 3D 纹理的高度。
另请参阅 width()、depth() 和setSize()。
bool QOpenGLTexture::isAutoMipMapGenerationEnabled() const
返回此纹理对象是否启用了自动MIP映射生成。
另请参阅 setAutoMipMapGenerationEnabled() 和generateMipMaps()。
bool QOpenGLTexture::isBound() const
如果该纹理已绑定到当前活动纹理单元的相应目标,则返回true 。
bool QOpenGLTexture::isBound(uint unit)
如果该纹理已绑定到纹理单元unit 的对应目标,则返回true 。
bool QOpenGLTexture::isCreated() const
如果底层的 OpenGL 纹理对象已创建,则返回true 。
另请参阅 create()、destroy() 和textureId()。
bool QOpenGLTexture::isFixedSamplePositions() const
返回此纹理是否使用固定模式的多重采样。如果尚未为此纹理分配存储空间,则该函数将返回所请求的固定采样位置设置。
对于不支持多采样的纹理目标,此函数将返回true 。
另请参阅 setFixedSamplePositions() 和isStorageAllocated()。
bool QOpenGLTexture::isStorageAllocated() const
如果已为该纹理分配了服务器端存储空间,则返回true 。
一旦存储空间被分配,纹理格式、尺寸、Mipmap 级别和数组层均无法更改。
另请参阅 allocateStorage()、setSize()、setMipLevels()、setLayers() 以及setFormat()。
bool QOpenGLTexture::isTextureView() const
如果该纹理对象实际上是另一个纹理对象的视图,则返回true 。
另请参阅 createTextureView()。
int QOpenGLTexture::layers() const
返回此纹理的数组层数量。如果尚未为此纹理分配存储空间,则该函数将返回请求的数组层数量。
对于不支持数组层的纹理目标,该函数将返回 1。
另请参阅 setLayers() 和isStorageAllocated()。
std::pair<float, float> QOpenGLTexture::levelOfDetailRange() const
返回细节级别的最小值和最大值参数。
另请参阅 setLevelOfDetailRange()、minimumLevelOfDetail() 和maximumLevelOfDetail()。
float QOpenGLTexture::levelofDetailBias() const
返回细节级别偏差参数。
另请参阅 setLevelofDetailBias()。
QOpenGLTexture::Filter QOpenGLTexture::magnificationFilter() const
返回放大滤镜。
另请参阅 setMagnificationFilter()。
float QOpenGLTexture::maximumAnisotropy() const
返回在执行纹理查找时需考虑的最高各向异性级别。此功能需要 GL_EXT_texture_filter_anisotropic 扩展。
另请参阅 setMaximumAnisotropy()。
float QOpenGLTexture::maximumLevelOfDetail() const
返回最大详细程度参数。
另请参阅 setMaximumLevelOfDetail()、minimumLevelOfDetail(),以及levelOfDetailRange()。
int QOpenGLTexture::maximumMipLevels() const
根据当前尺寸,返回该纹理可拥有的最大Mipmap级别数。
另请参阅 setMipLevels()、mipLevels(),以及setSize()。
std::pair<QOpenGLTexture::Filter, QOpenGLTexture::Filter> QOpenGLTexture::minMagFilters() const
返回当前的压缩和扩展过滤器。
另请参阅 setMinMagFilters()。
QOpenGLTexture::Filter QOpenGLTexture::minificationFilter() const
返回代码压缩过滤器。
另请参阅 setMinificationFilter()。
float QOpenGLTexture::minimumLevelOfDetail() const
返回最低详细程度参数。
另请参阅 setMinimumLevelOfDetail()、maximumLevelOfDetail() 和levelOfDetailRange()。
int QOpenGLTexture::mipBaseLevel() const
返回此纹理所有纹理查找所使用的MIP映射基级。默认值为 0。
另请参阅 setMipBaseLevel()、mipMaxLevel() 以及mipLevelRange()。
std::pair<int, int> QOpenGLTexture::mipLevelRange() const
返回可用于对该纹理进行纹理查找的Mipmap级别范围。
另请参阅 setMipLevelRange()、mipBaseLevel() 和mipMaxLevel()。
int QOpenGLTexture::mipLevels() const
返回此纹理的Mipmap层数。如果尚未为此纹理分配存储空间,则返回请求的Mipmap层数。
另请参阅 setMipLevels()、maximumMipLevels() 和isStorageAllocated()。
int QOpenGLTexture::mipMaxLevel() const
返回此纹理所有纹理查找所使用的Mipmap最大级别。
另请参阅 setMipMaxLevel()、mipBaseLevel()、以及mipLevelRange()。
void QOpenGLTexture::release()
将该纹理从当前活动的纹理单元中解除绑定。
另请参阅 bind()。
void QOpenGLTexture::release(uint unit, QOpenGLTexture::TextureUnitReset reset = DontResetTextureUnit)
将此纹理从纹理单元unit 中解除绑定。
如果参数reset 的值为true ,则本函数将把活动单元恢复为调用时处于活动状态的纹理单元。
int QOpenGLTexture::samples() const
返回此纹理的多采样采样点数量。如果尚未为此纹理分配存储空间,则该函数返回请求的采样点数量。
对于不支持多采样的纹理目标,该函数将返回 0。
另请参阅 setSamples() 和isStorageAllocated()。
void QOpenGLTexture::setAutoMipMapGenerationEnabled(bool enabled)
如果 `enabled ` 的值为 `true`,则当通过 `setData()` 设置第 0 级 Mipmap 数据时,将启用该纹理对象的自动 Mipmap 生成功能。
默认情况下,自动 Mipmap 生成功能处于启用状态。
注意: OpenGL ES 2.0 不支持对压缩纹理进行Mipmap 生成。
另请参阅 isAutoMipMapGenerationEnabled() 和generateMipMaps()。
void QOpenGLTexture::setBorderColor(const QColor &color)
将纹理的边框颜色设置为color 。
注意:此 函数在 Mac 以及针对 OpenGL ES 2 构建的 Qt OpenGL 上无效。
另请参阅 borderColor()。
void QOpenGLTexture::setBorderColor(float r, float g, float b, float a)
将红色设置为r ,绿色设置为g ,蓝色设置为b ,并将a 设为透明度值。
这是一个重载函数。
void QOpenGLTexture::setBorderColor(int r, int g, int b, int a)
将红色设置为r ,绿色设置为g ,蓝色设置为b ,透明度设置为a 。
这是一个重载函数。
void QOpenGLTexture::setBorderColor(uint r, uint g, uint b, uint a)
将红色设置为r ,绿色设置为g ,蓝色设置为b ,透明度设置为a 。
这是一个重载函数。
void QOpenGLTexture::setComparisonFunction(QOpenGLTexture::ComparisonFunction function)
将此纹理的纹理比较函数设置为function 。阴影采样器在采样深度纹理时会使用该纹理比较函数。
另请参阅 comparisonFunction()。
void QOpenGLTexture::setComparisonMode(QOpenGLTexture::ComparisonMode mode)
将此纹理的纹理比较模式设置为mode 。阴影采样器在采样深度纹理时会使用该纹理比较模式。
另请参阅 comparisonMode()。
void QOpenGLTexture::setCompressedData(int mipLevel, int layer, QOpenGLTexture::CubeMapFace cubeFace, int dataSize, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
将压缩的像素数据data 上传至mipLevel 、数组layer 以及cubeFace 。像素传输可通过options 进行可选控制。dataSize 参数应指定data 所指向的数据的大小。
如果不使用压缩的format(),则应使用setData() 代替此函数。
void QOpenGLTexture::setCompressedData(int dataSize, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
这是一个重载函数。
void QOpenGLTexture::setCompressedData(int mipLevel, int dataSize, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
这是一个重载函数。
void QOpenGLTexture::setCompressedData(int mipLevel, int layer, int dataSize, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
这是一个重载函数。
void QOpenGLTexture::setCompressedData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, int dataSize, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
参数layerCount 表示通过此调用上传/填充的纹理数组中的图层数量。
这是一个重载函数。
void QOpenGLTexture::setData(int mipLevel, int layer, QOpenGLTexture::CubeMapFace cubeFace, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
上传该纹理对象mipLevel 的像素数据data 、数组layer 以及cubeFace 。在上传像素数据之前,必须已分配好存储空间。某些 setData() 的重载方法会在具备足够信息的情况下,自动设置适当的尺寸、Mipmap 级别和数组层,并为您分配存储空间。相关说明将在函数文档中注明。
由data 指向的像素数据结构由sourceFormat 和sourceType 指定。像素数据的上传可选地通过options 进行控制。
如果使用压缩的format(),则应使用setCompressedData() 代替此函数。
另请参阅 setCompressedData()。
void QOpenGLTexture::setData(const QImage &image, QOpenGLTexture::MipMapGeneration genMipMaps = GenerateMipMaps)
setData() 的此重载会为您分配存储空间。像素数据存储在image 中。默认情况下会生成 Mipmap。将genMipMaps 设置为DontGenerateMipMaps 可关闭 Mipmap 的生成。
注意: image 会自动转换为QImage::Format_RGBA8888 ,对于格式不同的较大图像,这可能会影响性能。
这是一个重载函数。
void QOpenGLTexture::setData(QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
这是一个重载函数。
void QOpenGLTexture::setData(int mipLevel, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
这是一个重载函数。
void QOpenGLTexture::setData(int mipLevel, int layer, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
这是一个重载函数。
void QOpenGLTexture::setData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
参数layerCount 表示由该调用上传/填充的纹理数组中的图层数量。
这是一个重载函数。
void QOpenGLTexture::setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
此重载用于更新纹理的一部分。参数xOffset 、yOffset 和zOffset 指定纹理内的纹素偏移量。参数width 、height 和depth 指定子图像的尺寸。
由data 所指向的像素数据结构由sourceFormat 和sourceType 指定。像素数据的上传可通过options 进行可选控制。
这是一个重载函数。
void QOpenGLTexture::setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, int mipLevel, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
此重载用于更新纹理的一部分。参数xOffset 、yOffset 、zOffset 指定纹理内的纹素偏移量。参数width 、height 和depth 指定子图像的尺寸。要更新的子图像的 MIP 贴图级别通过mipLevel 指定。
由data 所指向的像素数据结构由sourceFormat 和sourceType 指定。像素数据的上传可通过options 进行可选控制。
这是一个重载函数。
void QOpenGLTexture::setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, int mipLevel, int layer, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
此重载用于更新纹理的一部分。参数xOffset 、yOffset 、zOffset 指定纹理内的纹素偏移量。参数width 、height 和depth 指定子图像的尺寸。要更新的子图像的 MIP 贴图级别和图层分别通过mipLevel 和layer 指定。
data 所指向的像素数据结构由sourceFormat 和sourceType 指定。像素数据的上传可通过options 进行可选控制。
这是一个重载函数。
void QOpenGLTexture::setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, int mipLevel, int layer, QOpenGLTexture::CubeMapFace face, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
此重载用于更新纹理的一部分。参数xOffset 、yOffset 、zOffset 指定纹理内的纹素偏移量。参数width 、height 和depth 指定子图像的尺寸。要更新的子图像的 MIP 地图级别、图层和立方体贴图面分别由mipLevel 、layer 和face 指定。
由data 指向的像素数据结构由sourceFormat 和sourceType 指定。像素数据的上传可通过options 可选地进行控制。
这是一个重载函数。
void QOpenGLTexture::setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, int mipLevel, int layer, QOpenGLTexture::CubeMapFace face, int layerCount, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)
此重载用于更新纹理的一部分。参数xOffset 、yOffset 、zOffset 指定纹理内的纹素偏移量。参数width 、height 和depth 指定子图像的尺寸。要更新的子图像的 MIP 贴图级别、起始层、立方贴图面以及层数分别由mipLevel 、layer 、face 和layerCount 指定。
由data 指向的像素数据结构由sourceFormat 和sourceType 指定。像素数据的上传可通过options 进行可选控制。
这是一个重载函数。
void QOpenGLTexture::setDepthStencilMode(QOpenGLTexture::DepthStencilMode mode)
如果使用的是采用深度/模板合并格式的纹理,此函数将决定从纹理中访问的哪个分量,该分量被设置为mode 。
当该参数设置为DepthMode 时,着色器访问该纹理时将像往常一样以单个浮点数的形式访问深度分量。但当该参数设置为StencilMode 时,着色器将访问模板分量。
注意:此 函数对 Mac 以及针对 OpenGL ES 2 构建的 Qt OpenGL 版本无效。
另请参阅 depthStencilMode()。
void QOpenGLTexture::setFixedSamplePositions(bool fixed)
用于将支持多采样的纹理目标所使用的采样位置和采样数设置为fixed 。如果设置为true ,则图像中所有纹素使用的采样位置和采样数均相同,且不依赖于图像大小或内部格式。应在为纹理分配存储空间之前调用此函数。
对于不支持多采样的纹理目标,此函数无效。
默认值为true 。
另请参阅 isFixedSamplePositions() 和isStorageAllocated()。
void QOpenGLTexture::setFormat(QOpenGLTexture::TextureFormat format)
将此纹理对象的格式设置为format 。必须在分配纹理存储空间之前调用此函数。
请注意,并非所有格式都受支持。具体支持的格式取决于您的 OpenGL 实现和版本。
另请参阅 format() 和allocateStorage()。
void QOpenGLTexture::setLayers(int layers)
设置要为数组layers 分配存储空间的数量。应在为纹理分配存储空间之前调用此函数。
对于不支持数组图层的目标,此函数无效。
另请参阅 layers() 和isStorageAllocated()。
void QOpenGLTexture::setLevelOfDetailRange(float min, float max)
将细节等级的最小值设置为min ,最大值设置为max 。
注意:此 函数对针对 OpenGL ES 2 构建的 Qt OpenGL 没有影响。
另请参阅 levelOfDetailRange()、setMinimumLevelOfDetail() 和setMaximumLevelOfDetail()。
void QOpenGLTexture::setLevelofDetailBias(float bias)
将细节级别偏移量设置为bias 。细节级别偏移量会影响米普映射级别的切换点。增大细节级别偏移量的数值会使整体图像变得更模糊或更平滑;减小该数值则会使整体图像更锐利。
注意:此 函数对针对 OpenGL ES 2 构建的 Qt OpenGL 没有影响。
另请参阅 levelofDetailBias()。
void QOpenGLTexture::setMagnificationFilter(QOpenGLTexture::Filter filter)
将缩放过滤器设置为filter 。
另请参阅 magnificationFilter()、setMinificationFilter() 和setMinMagFilters()。
void QOpenGLTexture::setMaximumAnisotropy(float anisotropy)
如果您的 OpenGL 实现支持 GL_EXT_texture_filter_anisotropic 扩展,则该函数将最大各向异性级别设置为anisotropy 。
另请参阅 maximumAnisotropy()。
void QOpenGLTexture::setMaximumLevelOfDetail(float value)
将最大细节级别设置为value 。这会限制最低分辨率Mipmap(最高Mipmap级别)的选择。默认值为1000。
注意:此 函数对针对 OpenGL ES 2 构建的 Qt OpenGL 无效。
另请参阅 maximumLevelOfDetail()、setMinimumLevelOfDetail() 和setLevelOfDetailRange()。
void QOpenGLTexture::setMinMagFilters(QOpenGLTexture::Filter minificationFilter, QOpenGLTexture::Filter magnificationFilter)
将缩小过滤器设置为minificationFilter ,将放大过滤器设置为magnificationFilter 。
另请参阅 minMagFilters()、setMinificationFilter() 和setMagnificationFilter()。
void QOpenGLTexture::setMinificationFilter(QOpenGLTexture::Filter filter)
将用于代码压缩的过滤器设置为filter 。
另请参阅 minificationFilter()、setMagnificationFilter() 和setMinMagFilters()。
void QOpenGLTexture::setMinimumLevelOfDetail(float value)
将最低细节级别设置为value 。这会限制最高分辨率米普图(最低米普图级别)的选择。默认值为-1000。
注意:此 函数对针对 OpenGL ES 2 构建的 Qt OpenGL 没有影响。
另请参阅 minimumLevelOfDetail()、setMaximumLevelOfDetail() 和setLevelOfDetailRange()。
void QOpenGLTexture::setMipBaseLevel(int baseLevel)
将此纹理的所有纹理查找所使用的基米普图级别设置为baseLevel 。
注意:此 函数对针对 OpenGL ES 2 构建的 Qt OpenGL 没有影响。
另请参阅 mipBaseLevel()、setMipMaxLevel() 和setMipLevelRange()。
void QOpenGLTexture::setMipLevelRange(int baseLevel, int maxLevel)
将可用于此纹理的纹理查找的微贴图级别范围设置为baseLevel 至maxLevel 。
注意:此 函数对为 OpenGL ES 2 构建的 Qt OpenGL 没有影响。
另请参阅 setMipBaseLevel()、setMipMaxLevel() 和mipLevelRange()。
void QOpenGLTexture::setMipLevels(int levels)
对于支持米普图的纹理目标,此函数用于设置需要为其分配存储空间的米普图levels 的数量。应在为纹理分配存储空间之前调用此函数。
如果纹理目标不支持米普图,则此函数无效。
另请参阅 mipLevels()、maximumMipLevels() 和isStorageAllocated()。
void QOpenGLTexture::setMipMaxLevel(int maxLevel)
将使用该纹理进行所有纹理查找时所用的最大Mipmap级别设置为maxLevel 。
注意:此 函数对为 OpenGL ES 2 构建的 Qt OpenGL 没有影响。
另请参阅 mipMaxLevel()、setMipBaseLevel() 和setMipLevelRange()。
void QOpenGLTexture::setSamples(int samples)
设置在渲染到支持多采样的纹理目标时,为samples 分配存储空间的数量。应在为纹理分配存储空间之前调用此函数。
对于不支持多采样的目标,此函数无效。
另请参阅 samples() 和isStorageAllocated()。
void QOpenGLTexture::setSize(int width, int height = 1, int depth = 1)
将此纹理对象的尺寸设置为width 、height 和depth 。每个维度的默认值为 1。纹理的最大允许尺寸取决于您的 OpenGL 实现。即使为小于最大尺寸的纹理分配存储空间,如果系统资源不足,仍可能失败。
如果提供的width 、height 或depth 不是 2 的幂,且您的 OpenGL 实现不支持重复非 2 的幂纹理,则循环模式将自动设置为ClampToEdge 。
另请参阅 width()、height() 和depth()。
void QOpenGLTexture::setSwizzleMask(QOpenGLTexture::SwizzleComponent component, QOpenGLTexture::SwizzleValue value)
GLSL 着色器能够重新排列纹理函数返回的 vec4 的分量顺序。此外,能够从 CPU 端代码控制这种重新排列也是非常理想的。自 OpenGL 3.3 起,通过 swizzle 掩码可以实现这一点。
纹理的每个分量都可以映射到SwizzleValue 选项之一。
该函数将component 映射到输出value 。
注意:此 函数对 Mac 以及为 OpenGL ES 2 构建的 Qt OpenGL 没有影响。
另请参阅 swizzleMask()。
void QOpenGLTexture::setSwizzleMask(QOpenGLTexture::SwizzleValue r, QOpenGLTexture::SwizzleValue g, QOpenGLTexture::SwizzleValue b, QOpenGLTexture::SwizzleValue a)
参数r 、g 、b 和a 分别用于设置红色、绿色、蓝色以及透明度值。
这是一个重载函数。
void QOpenGLTexture::setWrapMode(QOpenGLTexture::WrapMode mode)
将所有纹理尺寸的环绕(或重复)模式设置为mode 。
另请参阅 wrapMode()。
void QOpenGLTexture::setWrapMode(QOpenGLTexture::CoordinateDirection direction, QOpenGLTexture::WrapMode mode)
将纹理维度direction 的环绕(或重复)模式设置为mode 。
这是一个重载函数。
QOpenGLTexture::SwizzleValue QOpenGLTexture::swizzleMask(QOpenGLTexture::SwizzleComponent component) const
返回纹理component 的混色掩码。
另请参阅 setSwizzleMask()。
QOpenGLTexture::Target QOpenGLTexture::target() const
返回该纹理的绑定目标。
GLuint QOpenGLTexture::textureId() const
返回底层 OpenGL 纹理对象的名称;如果该对象尚未创建,则返回 0。
另请参阅 create()、destroy() 和isCreated()。
int QOpenGLTexture::width() const
返回 1D、2D 或 3D 纹理的宽度。
另请参阅 height()、depth() 和setSize()。
QOpenGLTexture::WrapMode QOpenGLTexture::wrapMode(QOpenGLTexture::CoordinateDirection direction) const
返回纹理维度direction 的包围模式。
另请参阅 setWrapMode()。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.