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 轴上使用相反的方向。另一种方法是转换纹理坐标。
成员类型文档
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_ALLWAYS。 |
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。 |
枚举 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 | 完全支持非二倍幂纹理,包括纹理重复模式 |
QOpenGLTexture::Texture1D | 0x00002000 | 支持 1 维纹理目标 |
QOpenGLTexture::TextureComparisonOperators | 0x00004000 | 支持纹理比较运算符 |
QOpenGLTexture::TextureMipMapLevel | 0x00008000 | 支持设置基本和最大 mipmap 级别 |
特征类型是QFlags<Feature> 的类型定义。它存储特征值的 OR 组合。
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 | 应生成贴图 |
QOpenGLTexture::DontGenerateMipMaps | 1 | 不应生成贴图 |
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_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 |
QOpenGLTexture::UInt16_RGBA4_Rev | 0x8365 | 等价于 GL_UNSIGNED_SHORT_4_4_4_REV |
QOpenGLTexture::UInt32_RGBA8 | 0x8035 | 等价于 GL_UNSIGNED_INT_8_8_8 |
QOpenGLTexture::UInt32_RGBA8_Rev | 0x8367 | 等价于 GL_UNSIGNED_INT_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 | 阿尔法分量。等价于 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 | 将组件映射到 alpha 通道。等同于 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_SIGNED_RGB8_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(仅适用于带有 OES_depth_texture 的 OpenGL ES 3 或 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 中的像素数据。如果希望生成一连串的 mipmaps,可将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 扩展,在不可用的地方模拟 EXT_direct_state_access 扩展。
另请参见 release().
void QOpenGLTexture::bind(uint unit, QOpenGLTexture::TextureUnitReset reset = DontResetTextureUnit)
将此纹理绑定到纹理单元unit ,以便进行渲染。请注意,您不需要绑定QOpenGLTexture 对象就可以修改它们,因为在可用的情况下会使用 EXT_direct_state_access 扩展,而在不可用的情况下则会模拟 EXT_direct_state_access 扩展。
如果参数reset 为true
,则此函数将把活动单元恢复为进入时的纹理单元。
另请参见 release()。
QColor QOpenGLTexture::borderColor() const
返回此纹理的 borderColor。
另请参阅 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)
返回绑定到纹理单元target 的纹理textureId unit 。
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
返回三维纹理的深度。
另请参阅 width()、height() 和setSize()。
QOpenGLTexture::DepthStencilMode QOpenGLTexture::depthStencilMode() const
返回使用深度/模版组合格式的纹理的深度模版模式。
另请参见 setDepthStencilMode()。
void QOpenGLTexture::destroy()
销毁底层 OpenGL 纹理对象。这需要当前有效的 OpenGL 上下文。
另请参阅 create()、isCreated() 和textureId()。
int QOpenGLTexture::faces() const
返回此纹理的面数。对于 cubemap 和 cubemap 阵列类型的目标,返回值为 6。
对于非 cubemap 类型的目标,将返回 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 生成此纹理对象的贴图。如果您使用的纹理目标和过滤选项需要 mipmaps,而且您已禁用自动 mipmap 生成功能,则需要调用此函数或重载函数来创建 mipmap 链。
通过将 mipmap 基本级别设置为baseLevel ,然后生成 mipmap 链,就可以生成baseLevel 以上的 mipmap。如果resetBaseLevel 是true
,那么纹理的 baseLevel 将重置为之前的值。
另请参阅 setAutoMipMapGenerationEnabled()、setMipLevels() 和mipLevels()。
[static]
bool QOpenGLTexture::hasFeature(QOpenGLTexture::Feature feature)
如果您的 OpenGL 实现和版本支持纹理功能,则返回true
feature 。
int QOpenGLTexture::height() const
返回二维或三维纹理的高度。
另请参阅 width()、depth() 和setSize()。
bool QOpenGLTexture::isAutoMipMapGenerationEnabled() const
返回此纹理对象是否已启用自动 mipmap 生成。
另请参阅 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
返回使用此纹理进行所有纹理查找时使用的 mipmap 基本级别。默认值为 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 没有影响。
另请参阅 borderColor() 。
void QOpenGLTexture::setBorderColor(float r, float g, float b, float a)
将红色设置为r ,将绿色设置为g ,将蓝色设置为b ,将a 设置为 alpha 值。
这是一个重载函数。
void QOpenGLTexture::setBorderColor(int r, int g, int b, int a)
将红色设置为r ,将绿色设置为g ,将蓝色设置为b ,将 alpha 值设置为a 。
这是一个重载函数。
void QOpenGLTexture::setBorderColor(uint r, uint g, uint b, uint a)
将红色设置为r ,将绿色设置为g ,将蓝色设置为b ,将 alpha 值设置为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)
上传此纹理对象的像素data mipLevel 、数组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 指定子图像的尺寸。mipLevel 指定了要更新的子图像的 mip 地图级别。
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 指定子图像的尺寸。mipLevel 和layer 指定了要更新的子图像的 mip 地图级别和层数。
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 没有影响。
另请参见 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 没有影响。
另请参阅 levelOfDetailRange()、setMinimumLevelOfDetail() 和setMaximumLevelOfDetail()。
void QOpenGLTexture::setLevelofDetailBias(float bias)
将详细程度偏差设置为bias 。细节层次偏差会影响贴图层次的变化点。增加细节偏差值会使整体图像更模糊或更平滑。降低数值则会使整体图像更清晰。
注意: 此函数对为 OpenGL ES 2 构建的 Qt 没有影响。
另请参阅 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 没有影响。
另请参阅 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 。这将限制选择最高分辨率的 mipmap(最低 mipmap 级别)。默认值为-1000。
注意: 此函数对为 OpenGL ES 2 构建的 Qt 没有影响。
另请参阅 minimumLevelOfDetail()、setMaximumLevelOfDetail() 和setLevelOfDetailRange()。
void QOpenGLTexture::setMipBaseLevel(int baseLevel)
将用于此纹理的所有纹理查找的基本 mipmap 级别设置为baseLevel 。
注意: 此函数对为 OpenGL ES 2 构建的 Qt 无效。
另请参阅 mipBaseLevel()、setMipMaxLevel() 和setMipLevelRange()。
void QOpenGLTexture::setMipLevelRange(int baseLevel, int maxLevel)
设置可用于此纹理查找的 mipmap 级别范围,从baseLevel 到maxLevel 。
注意: 此函数对为 OpenGL ES 2 构建的 Qt 无效。
另请参阅 setMipBaseLevel()、setMipMaxLevel() 和mipLevelRange()。
void QOpenGLTexture::setMipLevels(int levels)
对于支持 mipmap 的纹理目标,该函数会设置请求分配存储空间的 mipmaplevels 数量。此函数应在为纹理分配存储空间之前调用。
如果纹理目标不支持 mipmaps,则此函数不起作用。
另请参阅 mipLevels()、maximumMipLevels() 和isStorageAllocated()。
void QOpenGLTexture::setMipMaxLevel(int maxLevel)
将此纹理的所有纹理查找所使用的最大 mipmap 级别设置为maxLevel 。
注意: 此函数对为 OpenGL ES 2 构建的 Qt 没有影响。
另请参阅 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 ,而您的 OpenGL 实现不支持重复非幂次的纹理,那么包模式将自动设置为ClampToEdge 。
另请参阅 width()、height() 和depth()。
void QOpenGLTexture::setSwizzleMask(QOpenGLTexture::SwizzleComponent component, QOpenGLTexture::SwizzleValue value)
GLSL 着色器可以对纹理函数返回的 vec4 分量重新排序。最好还能通过 CPU 端代码控制这种重新排序。从 OpenGL 3.3 开始,swizzle masks 就可以实现这一点。
纹理的每个组件都可以映射到SwizzleValue 选项之一。
此函数将component 映射到输出value 。
注意: 此函数对 Mac 和为 OpenGL ES 2 构建的 Qt 没有影响。
另请参阅 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
返回一维、二维或三维纹理的宽度。
另请参阅 height()、depth() 和setSize()。
QOpenGLTexture::WrapMode QOpenGLTexture::wrapMode(QOpenGLTexture::CoordinateDirection direction) const
返回纹理维度direction 的换行模式。
另请参阅 setWrapMode() 。
© 2025 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.