QOpenGLTexture 类

The QOpenGLTexture class encapsulates an OpenGL texture object. 更多...

头: #include <QOpenGLTexture>
qmake: QT += gui
Since: Qt 5.2

公共类型

enum BindingTarget { BindingTarget1D, BindingTarget1DArray, BindingTarget2D, BindingTarget2DArray, ..., BindingTargetBuffer }
enum ComparisonFunction { CompareLessEqual, CompareGreaterEqual, CompareLess, CompareGreater, ..., 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, ..., TextureMipMapLevel }
flags 特征
enum Filter { Nearest, Linear, NearestMipMapNearest, NearestMipMapLinear, LinearMipMapNearest, LinearMipMapLinear }
enum MipMapGeneration { GenerateMipMaps, DontGenerateMipMaps }
enum PixelFormat { NoSourceFormat, Red, RG, RGB, ..., LuminanceAlpha }
enum PixelType { NoPixelType, Int8, UInt8, Int16, ..., 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, ..., TargetBuffer }
enum TextureFormat { NoFormat, R8_UNorm, RG8_UNorm, RGB8_UNorm, ..., LuminanceAlphaFormat }
enum TextureUnitReset { ResetTextureUnit, DontResetTextureUnit }
enum WrapMode { Repeat, MirroredRepeat, ClampToEdge, ClampToBorder }

公共函数

QOpenGLTexture (Target target )
QOpenGLTexture (const QImage & image , MipMapGeneration genMipMaps = GenerateMipMaps)
~QOpenGLTexture ()
void allocateStorage ()
void allocateStorage (PixelFormat pixelFormat , PixelType pixelType )
void bind ()
void bind (uint unit , TextureUnitReset reset = DontResetTextureUnit)
QColor borderColor () const
void borderColor (float * border ) const
void borderColor (int * border ) const
void borderColor (unsigned int * border ) const
ComparisonFunction comparisonFunction () const
ComparisonMode comparisonMode () const
bool create ()
QOpenGLTexture * createTextureView (Target target , TextureFormat viewFormat , int minimumMipmapLevel , int maximumMipmapLevel , int minimumLayer , int maximumLayer ) const
int depth () const
DepthStencilMode depthStencilMode () const
void destroy ()
int faces () const
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
QPair<float, float> levelOfDetailRange () const
float levelofDetailBias () const
Filter magnificationFilter () const
float maximumAnisotropy () const
float maximumLevelOfDetail () const
int maximumMipLevels () const
QPair<Filter, Filter> minMagFilters () const
Filter minificationFilter () const
float minimumLevelOfDetail () const
int mipBaseLevel () const
QPair<int, int> mipLevelRange () const
int mipLevels () const
int mipMaxLevel () const
void release ()
void release (uint unit , TextureUnitReset reset = DontResetTextureUnit)
int samples () const
void setAutoMipMapGenerationEnabled (bool enabled )
void setBorderColor (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 (ComparisonFunction function )
void setComparisonMode (ComparisonMode mode )
void setCompressedData (int mipLevel , int layer , CubeMapFace cubeFace , int dataSize , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)
void setCompressedData (int mipLevel , int layer , int layerCount , CubeMapFace cubeFace , int dataSize , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)
void setCompressedData (int mipLevel , int layer , int dataSize , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)
void setCompressedData (int mipLevel , int dataSize , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)
void setCompressedData (int dataSize , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)
void setData (int mipLevel , int layer , CubeMapFace cubeFace , PixelFormat sourceFormat , PixelType sourceType , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)
void setData (int mipLevel , int layer , int layerCount , CubeMapFace cubeFace , PixelFormat sourceFormat , PixelType sourceType , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)
void setData (int mipLevel , int layer , PixelFormat sourceFormat , PixelType sourceType , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)
void setData (int mipLevel , PixelFormat sourceFormat , PixelType sourceType , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)
void setData (PixelFormat sourceFormat , PixelType sourceType , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)
void setData (const QImage & image , MipMapGeneration genMipMaps = GenerateMipMaps)
void setDepthStencilMode (DepthStencilMode mode )
void setFixedSamplePositions (bool fixed )
void setFormat (TextureFormat format )
void setLayers (int layers )
void setLevelOfDetailRange (float min , float max )
void setLevelofDetailBias (float bias )
void setMagnificationFilter (Filter filter )
void setMaximumAnisotropy (float anisotropy )
void setMaximumLevelOfDetail (float value )
void setMinMagFilters (Filter minificationFilter , Filter magnificationFilter )
void setMinificationFilter (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 (SwizzleComponent component , SwizzleValue value )
void setSwizzleMask (SwizzleValue r , SwizzleValue g , SwizzleValue b , SwizzleValue a )
void setWrapMode (WrapMode mode )
void setWrapMode (CoordinateDirection direction , WrapMode mode )
SwizzleValue swizzleMask (SwizzleComponent component ) const
Target target () const
GLuint textureId () const
int width () const
WrapMode wrapMode (CoordinateDirection direction ) const

静态公共成员

GLuint boundTextureId (BindingTarget target )
GLuint boundTextureId (uint unit , BindingTarget target )
bool hasFeature (Feature feature )

详细描述

The QOpenGLTexture class encapsulates an OpenGL texture object.

QOpenGLTexture makes it easy to work with OpenGL textures and the myriad features and targets that they offer depending upon the capabilities of your OpenGL implementation.

The typical usage pattern for QOpenGLTexture is

  • Instantiate the object specifying the texture target type
  • Set properties that affect the storage requirements e.g. storage format, dimensions
  • Allocate the server-side storage
  • Optionally upload pixel data
  • Optionally set any additional properties e.g. filtering and border options
  • Render with texture or render to texture

In the common case of simply using a QImage as the source of texture pixel data most of the above steps are performed automatically.

// Prepare texture
QOpenGLTexture *texture = new QOpenGLTexture(QImage(fileName).mirrored());
texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
texture->setMagnificationFilter(QOpenGLTexture::Linear);
...
// Render with texture
texture->bind();
glDrawArrays(...);
					

注意, QImage is mirrored vertically to account for the fact that OpenGL and QImage use opposite directions for the y axis. Another option would be to transform your texture coordinates.

成员类型文档编制

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

This enum specifies which comparison operator is used when texture comparison is enabled on this texture.

常量 描述
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::CommpareNotEqual 0x0205 相当于 GL_NOTEQUAL。
QOpenGLTexture::CompareAlways 0x0207 相当于 GL_ALWAYS。
QOpenGLTexture::CompareNever 0x0200 相当于 GL_NEVER。

该枚举在 Qt 5.5 引入或被修改。

enum QOpenGLTexture:: ComparisonMode

This enum specifies which comparison mode is used when sampling this texture.

常量 描述
QOpenGLTexture::CompareRefToTexture 0x884E 相当于 GL_COMPARE_REF_TO_TEXTURE。
QOpenGLTexture::CompareNone 0x0000 相当于 GL_NONE。

该枚举在 Qt 5.5 引入或被修改。

enum QOpenGLTexture:: CoordinateDirection

此枚举定义可能的纹理坐标方向

常量 描述
QOpenGLTexture::DirectionS 0x2802 The horizontal direction. Equivalent to GL_TEXTURE_WRAP_S
QOpenGLTexture::DirectionT 0x2803 The vertical direction. Equivalent to GL_TEXTURE_WRAP_T
QOpenGLTexture::DirectionR 0x8072 The depth direction. Equivalent to GL_TEXTURE_WRAP_R

enum QOpenGLTexture:: CubeMapFace

This enum defines the possible CubeMap faces.

常量 描述
QOpenGLTexture::CubeMapPositiveX 0x8515 Equivalent to GL_TEXTURE_CUBE_MAP_POSITIVE_X
QOpenGLTexture::CubeMapNegativeX 0x8516 Equivalent to GL_TEXTURE_CUBE_MAP_NEGATIVE_X
QOpenGLTexture::CubeMapPositiveY 0x8517 Equivalent to GL_TEXTURE_CUBE_MAP_POSITIVE_Y
QOpenGLTexture::CubeMapNegativeY 0x8518 Equivalent to GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
QOpenGLTexture::CubeMapPositiveZ 0x8519 Equivalent to GL_TEXTURE_CUBE_MAP_POSITIVE_Z
QOpenGLTexture::CubeMapNegativeZ 0x851A Equivalent to GL_TEXTURE_CUBE_MAP_NEGATIVE_Z

enum QOpenGLTexture:: DepthStencilMode

This enum specifies which component of a depth/stencil texture is accessed when the texture is sampled.

常量 描述
QOpenGLTexture::DepthMode 0x1902 Equivalent to GL_DEPTH_COMPONENT.
QOpenGLTexture::StencilMode 0x1901 Equivalent to GL_STENCIL_INDEX.

该枚举在 Qt 5.4 引入或被修改。

enum QOpenGLTexture:: Feature
flags QOpenGLTexture:: 特征

This enum defines the OpenGL texture-related features that can be tested for.

常量 描述
QOpenGLTexture::ImmutableStorage 0x00000001 Support for immutable texture storage
QOpenGLTexture::ImmutableMultisampleStorage 0x00000002 Support for immutable texture storage with multisample targets
QOpenGLTexture::TextureRectangle 0x00000004 Support for the GL_TEXTURE_RECTANGLE target
QOpenGLTexture::TextureArrays 0x00000008 Support for texture targets with array layers
QOpenGLTexture::Texture3D 0x00000010 Support for the 3 dimensional texture target
QOpenGLTexture::TextureMultisample 0x00000020 Support for texture targets that have multisample capabilities
QOpenGLTexture::TextureBuffer 0x00000040 Support for textures that use OpenGL buffer objects as their data source
QOpenGLTexture::TextureCubeMapArrays 0x00000080 Support for cubemap array texture target
QOpenGLTexture::Swizzle 0x00000100 Support for texture component swizzle masks
QOpenGLTexture::StencilTexturing 0x00000200 Support for stencil texturing (i.e. looking up depth or stencil components of a combined depth/stencil format texture in GLSL shaders).
QOpenGLTexture::AnisotropicFiltering 0x00000400 Support for anisotropic texture filtering
QOpenGLTexture::NPOTTextures 0x00000800 Basic support for non-power-of-two textures
QOpenGLTexture::NPOTTextureRepeat 0x00001000 Full support for non-power-of-two textures including texture repeat modes
QOpenGLTexture::Texture1D 0x00002000 Support for the 1 dimensional texture target
QOpenGLTexture::TextureComparisonOperators 0x00004000 Support for texture comparison operators
QOpenGLTexture::TextureMipMapLevel 0x00008000 Support for setting the base and maximum mipmap levels

The Features type is a typedef for QFlags <Feature>. It stores an OR combination of Feature values.

enum QOpenGLTexture:: Filter

This enum defines the filtering parameters for a QOpenGLTexture 对象。

常量 描述
QOpenGLTexture::Nearest 0x2600 Equivalent to GL_NEAREST
QOpenGLTexture::Linear 0x2601 Equivalent to GL_LINEAR
QOpenGLTexture::NearestMipMapNearest 0x2700 Equivalent to GL_NEAREST_MIPMAP_NEAREST
QOpenGLTexture::NearestMipMapLinear 0x2702 Equivalent to GL_NEAREST_MIPMAP_LINEAR
QOpenGLTexture::LinearMipMapNearest 0x2701 Equivalent to GL_LINEAR_MIPMAP_NEAREST
QOpenGLTexture::LinearMipMapLinear 0x2703 Equivalent to GL_LINEAR_MIPMAP_LINEAR

enum QOpenGLTexture:: MipMapGeneration

This enum defines the options to control mipmap generation.

常量 描述
QOpenGLTexture::GenerateMipMaps 0 Mipmaps should be generated
QOpenGLTexture::DontGenerateMipMaps 1 Mipmaps should not be generated

enum QOpenGLTexture:: PixelFormat

This enum defines the possible client-side pixel formats for a pixel transfer operation.

常量 描述
QOpenGLTexture::NoSourceFormat 0 Equivalent to GL_NONE
QOpenGLTexture::Red 0x1903 Equivalent to GL_RED
QOpenGLTexture::RG 0x8227 Equivalent to GL_RG
QOpenGLTexture::RGB 0x1907 Equivalent to GL_RGB
QOpenGLTexture::BGR 0x80E0 Equivalent to GL_BGR
QOpenGLTexture::RGBA 0x1908 Equivalent to GL_RGBA
QOpenGLTexture::BGRA 0x80E1 Equivalent to GL_BGRA
QOpenGLTexture::Red_Integer 0x8D94 Equivalent to GL_RED_INTEGER
QOpenGLTexture::RG_Integer 0x8228 Equivalent to GL_RG_INTEGER
QOpenGLTexture::RGB_Integer 0x8D98 Equivalent to GL_RGB_INTEGER
QOpenGLTexture::BGR_Integer 0x8D9A Equivalent to GL_BGR_INTEGER
QOpenGLTexture::RGBA_Integer 0x8D99 Equivalent to GL_RGBA_INTEGER
QOpenGLTexture::BGRA_Integer 0x8D9B Equivalent to GL_BGRA_INTEGER
QOpenGLTexture::Stencil 0x1901 Equivalent to GL_STENCIL_INDEX. Introduced in Qt 5.4
QOpenGLTexture::Depth 0x1902 Equivalent to GL_DEPTH_COMPONENT
QOpenGLTexture::DepthStencil 0x84F9 Equivalent to GL_DEPTH_STENCIL
QOpenGLTexture::Alpha 0x1906 Equivalent to GL_ALPHA (OpenGL ES 2 only)
QOpenGLTexture::Luminance 0x1909 Equivalent to GL_LUMINANCE (OpenGL ES 2 only)
QOpenGLTexture::LuminanceAlpha 0x190A Equivalent to GL_LUMINANCE_ALPHA (OpenGL ES 2 only)

enum QOpenGLTexture:: PixelType

This enum defines the possible pixel data types for a pixel transfer operation

常量 描述
QOpenGLTexture::NoPixelType 0 Equivalent to GL_NONE
QOpenGLTexture::Int8 0x1400 Equivalent to GL_BYTE
QOpenGLTexture::UInt8 0x1401 Equivalent to GL_UNSIGNED_BYTE
QOpenGLTexture::Int16 0x1402 Equivalent to GL_SHORT
QOpenGLTexture::UInt16 0x1403 Equivalent to GL_UNSIGNED_SHORT
QOpenGLTexture::Int32 0x1404 Equivalent to GL_INT
QOpenGLTexture::UInt32 0x1405 Equivalent to GL_UNSIGNED_INT
QOpenGLTexture::Float16 0x140B Equivalent to GL_HALF_FLOAT
QOpenGLTexture::Float16OES 0x8D61 Equivalent to GL_HALF_FLOAT_OES
QOpenGLTexture::Float32 0x1406 Equivalent to GL_FLOAT
QOpenGLTexture::UInt32_RGB9_E5 0x8C3E Equivalent to GL_UNSIGNED_INT_5_9_9_9_REV
QOpenGLTexture::UInt32_RG11B10F 0x8C3B Equivalent to GL_UNSIGNED_INT_10F_11F_11F_REV
QOpenGLTexture::UInt8_RG3B2 0x8032 Equivalent to GL_UNSIGNED_BYTE_3_3_2
QOpenGLTexture::UInt8_RG3B2_Rev 0x8362 Equivalent to GL_UNSIGNED_BYTE_2_3_3_REV
QOpenGLTexture::UInt16_RGB5A1 0x8034 Equivalent to GL_UNSIGNED_SHORT_5_5_5_1
QOpenGLTexture::UInt16_RGB5A1_Rev 0x8366 Equivalent to GL_UNSIGNED_SHORT_1_5_5_5_REV
QOpenGLTexture::UInt16_R5G6B5 0x8363 Equivalent to GL_UNSIGNED_SHORT_5_6_5
QOpenGLTexture::UInt16_R5G6B5_Rev 0x8364 Equivalent to GL_UNSIGNED_SHORT_5_6_5_REV
QOpenGLTexture::UInt16_RGBA4 0x8033 Equivalent to GL_UNSIGNED_SHORT_4_4_4_4
QOpenGLTexture::UInt16_RGBA4_Rev 0x8365 Equivalent to GL_UNSIGNED_SHORT_4_4_4_4_REV
QOpenGLTexture::UInt32_RGBA8 0x8035 Equivalent to GL_UNSIGNED_INT_8_8_8_8
QOpenGLTexture::UInt32_RGBA8_Rev 0x8367 Equivalent to GL_UNSIGNED_INT_8_8_8_8_REV
QOpenGLTexture::UInt32_RGB10A2 0x8036 Equivalent to GL_UNSIGNED_INT_10_10_10_2
QOpenGLTexture::UInt32_RGB10A2_Rev 0x8368 Equivalent to GL_UNSIGNED_INT_2_10_10_10_REV
QOpenGLTexture::UInt32_D24S8 0x84FA Equivalent to GL_UNSIGNED_INT_24_8. Introduced in Qt 5.4
QOpenGLTexture::Float32_D32_UInt32_S8_X24 0x8DAD Equivalent to GL_FLOAT_32_UNSIGNED_INT_24_8_REV. Introduced in Qt 5.4

enum QOpenGLTexture:: SwizzleComponent

This enum defines the texture color components that can be assigned a swizzle mask.

常量 描述
QOpenGLTexture::SwizzleRed 0x8E42 The red component. Equivalent to GL_TEXTURE_SWIZZLE_R
QOpenGLTexture::SwizzleGreen 0x8E43 The green component. Equivalent to GL_TEXTURE_SWIZZLE_G
QOpenGLTexture::SwizzleBlue 0x8E44 The blue component. Equivalent to GL_TEXTURE_SWIZZLE_B
QOpenGLTexture::SwizzleAlpha 0x8E45 The alpha component. Equivalent to GL_TEXTURE_SWIZZLE_A

enum QOpenGLTexture:: SwizzleValue

This enum defines the possible mask values for texture swizzling.

常量 描述
QOpenGLTexture::RedValue 0x1903 Maps the component to the red channel. Equivalent to GL_RED
QOpenGLTexture::GreenValue 0x1904 Maps the component to the green channel. Equivalent to GL_GREEN
QOpenGLTexture::BlueValue 0x1905 Maps the component to the blue channel. Equivalent to GL_BLUE
QOpenGLTexture::AlphaValue 0x1906 Maps the component to the alpha channel. Equivalent to GL_ALPHA
QOpenGLTexture::ZeroValue 0 Maps the component to a fixed value of 0. Equivalent to GL_ZERO
QOpenGLTexture::OneValue 1 Maps the component to a fixed value of 1. Equivalent to GL_ONE

enum QOpenGLTexture:: Target

This enum defines the texture target of a QOpenGLTexture 对象。

常量 描述
QOpenGLTexture::Target1D 0x0DE0 A 1-dimensional texture. Equivalent to GL_TEXTURE_1D.
QOpenGLTexture::Target1DArray 0x8C18 An array of 1-dimensional textures. Equivalent to GL_TEXTURE_1D_ARRAY
QOpenGLTexture::Target2D 0x0DE1 A 2-dimensional texture. Equivalent to GL_TEXTURE_2D
QOpenGLTexture::Target2DArray 0x8C1A An array of 1-dimensional textures. Equivalent to GL_TEXTURE_2D_ARRAY
QOpenGLTexture::Target3D 0x806F A 3-dimensional texture. Equivalent to GL_TEXTURE_3D
QOpenGLTexture::TargetCubeMap 0x8513 A cubemap texture. Equivalent to GL_TEXTURE_CUBE_MAP
QOpenGLTexture::TargetCubeMapArray 0x9009 An array of cubemap textures. Equivalent to GL_TEXTURE_CUBE_MAP_ARRAY
QOpenGLTexture::Target2DMultisample 0x9100 A 2-dimensional texture with multisample support. Equivalent to GL_TEXTURE_2D_MULTISAMPLE
QOpenGLTexture::Target2DMultisampleArray 0x9102 An array of 2-dimensional textures with multisample support. Equivalent to GL_TEXTURE_2D_MULTISAMPLE_ARRAY
QOpenGLTexture::TargetRectangle 0x84F5 A rectangular 2-dimensional texture. Equivalent to GL_TEXTURE_RECTANGLE
QOpenGLTexture::TargetBuffer 0x8C2A A texture with data from an OpenGL buffer object. Equivalent to GL_TEXTURE_BUFFER

enum QOpenGLTexture:: TextureFormat

This enum defines the possible texture formats. Depending upon your OpenGL implementation only a subset of these may be supported.

常量 描述
QOpenGLTexture::NoFormat 0 Equivalent to GL_NONE
QOpenGLTexture::R8_UNorm 0x8229 Equivalent to GL_R8
QOpenGLTexture::RG8_UNorm 0x822B Equivalent to GL_RG8
QOpenGLTexture::RGB8_UNorm 0x8051 Equivalent to GL_RGB8
QOpenGLTexture::RGBA8_UNorm 0x8058 Equivalent to GL_RGBA8
QOpenGLTexture::R16_UNorm 0x822A Equivalent to GL_R16
QOpenGLTexture::RG16_UNorm 0x822C Equivalent to GL_RG16
QOpenGLTexture::RGB16_UNorm 0x8054 Equivalent to GL_RGB16
QOpenGLTexture::RGBA16_UNorm 0x805B Equivalent to GL_RGBA16
QOpenGLTexture::R8_SNorm 0x8F94 Equivalent to GL_R8_SNORM
QOpenGLTexture::RG8_SNorm 0x8F95 Equivalent to GL_RG8_SNORM
QOpenGLTexture::RGB8_SNorm 0x8F96 Equivalent to GL_RGB8_SNORM
QOpenGLTexture::RGBA8_SNorm 0x8F97 Equivalent to GL_RGBA8_SNORM
QOpenGLTexture::R16_SNorm 0x8F98 Equivalent to GL_R16_SNORM
QOpenGLTexture::RG16_SNorm 0x8F99 Equivalent to GL_RG16_SNORM
QOpenGLTexture::RGB16_SNorm 0x8F9A Equivalent to GL_RGB16_SNORM
QOpenGLTexture::RGBA16_SNorm 0x8F9B Equivalent to GL_RGBA16_SNORM
QOpenGLTexture::R8U 0x8232 Equivalent to GL_R8UI
QOpenGLTexture::RG8U 0x8238 Equivalent to GL_RG8UI
QOpenGLTexture::RGB8U 0x8D7D Equivalent to GL_RGB8UI
QOpenGLTexture::RGBA8U 0x8D7C Equivalent to GL_RGBA8UI
QOpenGLTexture::R16U 0x8234 Equivalent to GL_R16UI
QOpenGLTexture::RG16U 0x823A Equivalent to GL_RG16UI
QOpenGLTexture::RGB16U 0x8D77 Equivalent to GL_RGB16UI
QOpenGLTexture::RGBA16U 0x8D76 Equivalent to GL_RGBA16UI
QOpenGLTexture::R32U 0x8236 Equivalent to GL_R32UI
QOpenGLTexture::RG32U 0x823C Equivalent to GL_RG32UI
QOpenGLTexture::RGB32U 0x8D71 Equivalent to GL_RGB32UI
QOpenGLTexture::RGBA32U 0x8D70 Equivalent to GL_RGBA32UI
QOpenGLTexture::R8I 0x8231 Equivalent to GL_R8I
QOpenGLTexture::RG8I 0x8237 Equivalent to GL_RG8I
QOpenGLTexture::RGB8I 0x8D8F Equivalent to GL_RGB8I
QOpenGLTexture::RGBA8I 0x8D8E Equivalent to GL_RGBA8I
QOpenGLTexture::R16I 0x8233 Equivalent to GL_R16I
QOpenGLTexture::RG16I 0x8239 Equivalent to GL_RG16I
QOpenGLTexture::RGB16I 0x8D89 Equivalent to GL_RGB16I
QOpenGLTexture::RGBA16I 0x8D88 Equivalent to GL_RGBA16I
QOpenGLTexture::R32I 0x8235 Equivalent to GL_R32I
QOpenGLTexture::RG32I 0x823B Equivalent to GL_RG32I
QOpenGLTexture::RGB32I 0x8D83 Equivalent to GL_RGB32I
QOpenGLTexture::RGBA32I 0x8D82 Equivalent to GL_RGBA32I
QOpenGLTexture::R16F 0x822D Equivalent to GL_R16F
QOpenGLTexture::RG16F 0x822F Equivalent to GL_RG16F
QOpenGLTexture::RGB16F 0x881B Equivalent to GL_RGB16F
QOpenGLTexture::RGBA16F 0x881A Equivalent to GL_RGBA16F
QOpenGLTexture::R32F 0x822E Equivalent to GL_R32F
QOpenGLTexture::RG32F 0x8230 Equivalent to GL_RG32F
QOpenGLTexture::RGB32F 0x8815 Equivalent to GL_RGB32F
QOpenGLTexture::RGBA32F 0x8814 Equivalent to GL_RGBA32F
QOpenGLTexture::RGB9E5 0x8C3D Equivalent to GL_RGB9_E5
QOpenGLTexture::RG11B10F 0x8C3A Equivalent to GL_R11F_G11F_B10F
QOpenGLTexture::RG3B2 0x2A10 Equivalent to GL_R3_G3_B2
QOpenGLTexture::R5G6B5 0x8D62 Equivalent to GL_RGB565
QOpenGLTexture::RGB5A1 0x8057 Equivalent to GL_RGB5_A1
QOpenGLTexture::RGBA4 0x8056 Equivalent to GL_RGBA4
QOpenGLTexture::RGB10A2 0x906F Equivalent to GL_RGB10_A2UI
QOpenGLTexture::D16 0x81A5 Equivalent to GL_DEPTH_COMPONENT16
QOpenGLTexture::D24 0x81A6 Equivalent to GL_DEPTH_COMPONENT24
QOpenGLTexture::D24S8 0x88F0 Equivalent to GL_DEPTH24_STENCIL8
QOpenGLTexture::D32 0x81A7 Equivalent to GL_DEPTH_COMPONENT32
QOpenGLTexture::D32F 0x8CAC Equivalent to GL_DEPTH_COMPONENT32F
QOpenGLTexture::D32FS8X24 0x8CAD Equivalent to GL_DEPTH32F_STENCIL8
QOpenGLTexture::S8 0x8D48 Equivalent to GL_STENCIL_INDEX8. Introduced in Qt 5.4
QOpenGLTexture::RGB_DXT1 0x83F0 Equivalent to GL_COMPRESSED_RGB_S3TC_DXT1_EXT
QOpenGLTexture::RGBA_DXT1 0x83F1 Equivalent to GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
QOpenGLTexture::RGBA_DXT3 0x83F2 Equivalent to GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
QOpenGLTexture::RGBA_DXT5 0x83F3 Equivalent to GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
QOpenGLTexture::R_ATI1N_UNorm 0x8DBB Equivalent to GL_COMPRESSED_RED_RGTC1
QOpenGLTexture::R_ATI1N_SNorm 0x8DBC Equivalent to GL_COMPRESSED_SIGNED_RED_RGTC1
QOpenGLTexture::RG_ATI2N_UNorm 0x8DBD Equivalent to GL_COMPRESSED_RG_RGTC2
QOpenGLTexture::RG_ATI2N_SNorm 0x8DBE Equivalent to GL_COMPRESSED_SIGNED_RG_RGTC2
QOpenGLTexture::RGB_BP_UNSIGNED_FLOAT 0x8E8F Equivalent to GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB
QOpenGLTexture::RGB_BP_SIGNED_FLOAT 0x8E8E Equivalent to GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB
QOpenGLTexture::RGB_BP_UNorm 0x8E8C Equivalent to GL_COMPRESSED_RGBA_BPTC_UNORM_ARB
QOpenGLTexture::R11_EAC_UNorm 0x9270 Equivalent to GL_COMPRESSED_R11_EAC
QOpenGLTexture::R11_EAC_SNorm 0x9271 Equivalent to GL_COMPRESSED_SIGNED_R11_EAC
QOpenGLTexture::RG11_EAC_UNorm 0x9272 Equivalent to GL_COMPRESSED_RG11_EAC
QOpenGLTexture::RG11_EAC_SNorm 0x9273 Equivalent to GL_COMPRESSED_SIGNED_RG11_EAC
QOpenGLTexture::RGB8_ETC2 0x9274 Equivalent to GL_COMPRESSED_RGB8_ETC2
QOpenGLTexture::SRGB8_ETC2 0x9275 Equivalent to GL_COMPRESSED_SRGB8_ETC2
QOpenGLTexture::RGB8_PunchThrough_Alpha1_ETC2 0x9276 Equivalent to GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
QOpenGLTexture::SRGB8_PunchThrough_Alpha1_ETC2 0x9277 Equivalent to GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2
QOpenGLTexture::RGBA8_ETC2_EAC 0x9278 Equivalent to GL_COMPRESSED_RGBA8_ETC2_EAC
QOpenGLTexture::SRGB8_Alpha8_ETC2_EAC 0x9279 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
QOpenGLTexture::RGB8_ETC1 0x8D64 Equivalent to GL_ETC1_RGB8_OES
QOpenGLTexture::RGBA_ASTC_4x4 0x93B0 Equivalent to GL_COMPRESSED_RGBA_ASTC_4x4_KHR
QOpenGLTexture::RGBA_ASTC_5x4 0x93B1 Equivalent to GL_COMPRESSED_RGBA_ASTC_5x4_KHR
QOpenGLTexture::RGBA_ASTC_5x5 0x93B2 Equivalent to GL_COMPRESSED_RGBA_ASTC_5x5_KHR
QOpenGLTexture::RGBA_ASTC_6x5 0x93B3 Equivalent to GL_COMPRESSED_RGBA_ASTC_6x5_KHR
QOpenGLTexture::RGBA_ASTC_6x6 0x93B4 Equivalent to GL_COMPRESSED_RGBA_ASTC_6x6_KHR
QOpenGLTexture::RGBA_ASTC_8x5 0x93B5 Equivalent to GL_COMPRESSED_RGBA_ASTC_8x5_KHR
QOpenGLTexture::RGBA_ASTC_8x6 0x93B6 Equivalent to GL_COMPRESSED_RGBA_ASTC_8x6_KHR
QOpenGLTexture::RGBA_ASTC_8x8 0x93B7 Equivalent to GL_COMPRESSED_RGBA_ASTC_8x8_KHR
QOpenGLTexture::RGBA_ASTC_10x5 0x93B8 Equivalent to GL_COMPRESSED_RGBA_ASTC_10x5_KHR
QOpenGLTexture::RGBA_ASTC_10x6 0x93B9 Equivalent to GL_COMPRESSED_RGBA_ASTC_10x6_KHR
QOpenGLTexture::RGBA_ASTC_10x8 0x93BA Equivalent to GL_COMPRESSED_RGBA_ASTC_10x8_KHR
QOpenGLTexture::RGBA_ASTC_10x10 0x93BB Equivalent to GL_COMPRESSED_RGBA_ASTC_10x10_KHR
QOpenGLTexture::RGBA_ASTC_12x10 0x93BC Equivalent to GL_COMPRESSED_RGBA_ASTC_12x10_KHR
QOpenGLTexture::RGBA_ASTC_12x12 0x93BD Equivalent to GL_COMPRESSED_RGBA_ASTC_12x12_KHR
QOpenGLTexture::SRGB8_Alpha8_ASTC_4x4 0x93D0 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR
QOpenGLTexture::SRGB8_Alpha8_ASTC_5x4 0x93D1 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR
QOpenGLTexture::SRGB8_Alpha8_ASTC_5x5 0x93D2 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR
QOpenGLTexture::SRGB8_Alpha8_ASTC_6x5 0x93D3 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR
QOpenGLTexture::SRGB8_Alpha8_ASTC_6x6 0x93D4 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR
QOpenGLTexture::SRGB8_Alpha8_ASTC_8x5 0x93D5 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR
QOpenGLTexture::SRGB8_Alpha8_ASTC_8x6 0x93D6 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR
QOpenGLTexture::SRGB8_Alpha8_ASTC_8x8 0x93D7 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR
QOpenGLTexture::SRGB8_Alpha8_ASTC_10x5 0x93D8 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR
QOpenGLTexture::SRGB8_Alpha8_ASTC_10x6 0x93D9 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR
QOpenGLTexture::SRGB8_Alpha8_ASTC_10x8 0x93DA Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR
QOpenGLTexture::SRGB8_Alpha8_ASTC_10x10 0x93DB Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR
QOpenGLTexture::SRGB8_Alpha8_ASTC_12x10 0x93DC Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR
QOpenGLTexture::SRGB8_Alpha8_ASTC_12x12 0x93DD Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
QOpenGLTexture::SRGB8 0x8C41 Equivalent to GL_SRGB8
QOpenGLTexture::SRGB8_Alpha8 0x8C43 Equivalent to GL_SRGB8_ALPHA8
QOpenGLTexture::SRGB_DXT1 0x8C4C Equivalent to GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
QOpenGLTexture::SRGB_Alpha_DXT1 0x8C4D Equivalent to GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
QOpenGLTexture::SRGB_Alpha_DXT3 0x8C4E Equivalent to GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
QOpenGLTexture::SRGB_Alpha_DXT5 0x8C4F Equivalent to GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
QOpenGLTexture::SRGB_BP_UNorm 0x8E8D Equivalent to GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB
QOpenGLTexture::DepthFormat 0x1902 Equivalent to GL_DEPTH_COMPONENT (only OpenGL ES 3 or ES 2 with OES_depth_texture)
QOpenGLTexture::AlphaFormat 0x1906 Equivalent to GL_ALPHA (OpenGL ES 2 only)
QOpenGLTexture::RGBFormat 0x1907 Equivalent to GL_RGB (OpenGL ES 2 only)
QOpenGLTexture::RGBAFormat 0x1908 Equivalent to GL_RGBA (OpenGL ES 2 only)
QOpenGLTexture::LuminanceFormat 0x1909 Equivalent to GL_LUMINANCE (OpenGL ES 2 only)
QOpenGLTexture::LuminanceAlphaFormat 0x190A Equivalent to GL_LUMINANCE_ALPHA (OpenGL ES 2 only)

enum QOpenGLTexture:: TextureUnitReset

This enum defines options ot control texture unit activation.

常量 描述
QOpenGLTexture::ResetTextureUnit 0 The previous active texture unit will be reset
QOpenGLTexture::DontResetTextureUnit 1 The previous active texture unit will not be rest

enum QOpenGLTexture:: WrapMode

This enum defines the possible texture coordinate wrapping modes.

常量 描述
QOpenGLTexture::Repeat 0x2901 Texture coordinate is repeated. Equivalent to GL_REPEAT
QOpenGLTexture::MirroredRepeat 0x8370 Texture coordinate is reflected about 0 and 1. Equivalent to GL_MIRRORED_REPEAT
QOpenGLTexture::ClampToEdge 0x812F Clamps the texture coordinates to [0,1]. Equivalent to GL_CLAMP_TO_EDGE
QOpenGLTexture::ClampToBorder 0x812D As for ClampToEdge but also blends samples at 0 and 1 with a fixed border color. Equivalent to GL_CLAMP_TO_BORDER

成员函数文档编制

QOpenGLTexture:: QOpenGLTexture ( Target target )

创建 QOpenGLTexture object that can later be bound to target .

This does not create the underlying OpenGL texture object. Therefore, construction using this constructor does not require a valid current OpenGL context.

QOpenGLTexture:: QOpenGLTexture (const QImage & image , MipMapGeneration genMipMaps = GenerateMipMaps)

创建 QOpenGLTexture object that can later be bound to the 2D texture target and contains the pixel data contained in image . If you wish to have a chain of mipmaps generated then set genMipMaps to true (this is the default).

This does create the underlying OpenGL texture object. Therefore, construction using this constructor does require a valid current OpenGL context.

QOpenGLTexture:: ~QOpenGLTexture ()

Destroys the instance of QOpenGLTexture.

void QOpenGLTexture:: allocateStorage ()

Allocates server-side storage for this texture object taking into account, the format, dimensions, mipmap levels, array layers and cubemap faces.

Once storage has been allocated it is no longer possible to change these properties.

If supported QOpenGLTexture makes use of immutable texture storage.

Once storage has been allocated for the texture then pixel data can be uploaded via one of the setData () overloads.

注意: If immutable texture storage is not available, then a default pixel format and pixel type will be used to create the mutable storage. You can use the other allocateStorage() overload to specify exactly the pixel format and the pixel type to use when allocating mutable storage; this is particulary useful under certain OpenGL ES implementations (notably, OpenGL ES 2), where the pixel format and the pixel type used at allocation time must perfectly match the format and the type passed to any subsequent setData () 调用。

另请参阅 isStorageAllocated () 和 setData ().

void QOpenGLTexture:: allocateStorage ( PixelFormat pixelFormat , PixelType pixelType )

Allocates server-side storage for this texture object taking into account, the format, dimensions, mipmap levels, array layers and cubemap faces.

Once storage has been allocated it is no longer possible to change these properties.

If supported QOpenGLTexture makes use of immutable texture storage. However, if immutable texture storage is not available, then the specified pixelFormat and pixelType will be used to allocate mutable storage; note that in certain OpenGL implementations (notably, OpenGL ES 2) they must perfectly match the format and the type passed to any subsequent setData () 调用。

Once storage has been allocated for the texture then pixel data can be uploaded via one of the setData () overloads.

该函数在 Qt 5.5 引入。

另请参阅 isStorageAllocated () 和 setData ().

void QOpenGLTexture:: bind ()

Binds this texture to the currently active texture unit ready for rendering. Note that you do not need to bind QOpenGLTexture objects in order to modify them as the implementation makes use of the EXT_direct_state_access extension where available and simulates it where it is not.

另请参阅 release ().

void QOpenGLTexture:: bind ( uint unit , TextureUnitReset reset = DontResetTextureUnit)

Binds this texture to texture unit unit ready for rendering. Note that you do not need to bind QOpenGLTexture objects in order to modify them as the implementation makes use of the EXT_direct_state_access extension where available and simulates it where it is not.

If parameter reset is true then this function will restore the active unit to the texture unit that was active upon entry.

另请参阅 release ().

QColor QOpenGLTexture:: borderColor () const

Returns the borderColor of this texture.

另请参阅 setBorderColor ().

void QOpenGLTexture:: borderColor ( float * border ) const

Writes the texture border color into the first four elements of the array pointed to by border .

另请参阅 setBorderColor ().

void QOpenGLTexture:: borderColor ( int * border ) const

Writes the texture border color into the first four elements of the array pointed to by border .

这是重载函数。

void QOpenGLTexture:: borderColor ( unsigned int * border ) const

Writes the texture border color into the first four elements of the array pointed to by border .

这是重载函数。

[static] GLuint QOpenGLTexture:: boundTextureId ( BindingTarget target )

返回 textureId of the texture that is bound to the target of the currently active texture unit.

[static] GLuint QOpenGLTexture:: boundTextureId ( uint unit , BindingTarget target )

返回 textureId of the texture that is bound to the target of the texture unit unit .

ComparisonFunction QOpenGLTexture:: comparisonFunction () const

Returns the texture comparison operator set on this texture. By default, a texture has a CompareLessEqual comparison function.

该函数在 Qt 5.5 引入。

另请参阅 setComparisonFunction ().

ComparisonMode QOpenGLTexture:: comparisonMode () const

Returns the texture comparison mode set on this texture. By default, a texture has a CompareNone comparison mode (i.e. comparisons are disabled).

该函数在 Qt 5.5 引入。

另请参阅 setComparisonMode ().

bool QOpenGLTexture:: create ()

Creates the underlying OpenGL texture object. This requires a current valid OpenGL context. If the texture object already exists, this function does nothing.

Once the texture object is created you can obtain the object name from the textureId () function. This may be useful if you wish to make some raw OpenGL calls related to this texture.

Normally it should not be necessary to call this function directly as all functions that set properties of the texture object implicitly call create() on your behalf.

返回 true if the creation succeeded, otherwise returns false .

另请参阅 destroy (), isCreated (),和 textureId ().

QOpenGLTexture *QOpenGLTexture:: createTextureView ( Target target , TextureFormat viewFormat , int minimumMipmapLevel , int maximumMipmapLevel , int minimumLayer , int maximumLayer ) const

Attempts to create a texture view onto this texture. A texture view is somewhat analogous to a view in SQL in that it presents a restricted or reinterpreted view of the original data. Texture views do not allocate any more server-side storage, insted relying on the storage buffer of the source texture.

Texture views are only available when using immutable storage. For more information on texture views see http://www.opengl.org/wiki/Texture_Storage#Texture_views.

The target argument specifies the target to use for the view. Only some targets can be used depending upon the target of the original target. For e.g. a view onto a Target1DArray texture can specify either Target1DArray or Target1D but for the latter the number of array layers specified with minimumLayer and maximumLayer must be exactly 1.

Simpliar constraints apply for the viewFormat . See the above link and the specification for more details.

The minimumMipmapLevel , maximumMipmapLevel , minimumLayer ,和 maximumLayer arguments serve to restrict the parts of the texture accessible by the texture view.

If creation of the texture view fails this function will return 0. If the function succeeds it will return a pointer to a new QOpenGLTexture object that will return true 从其 isTextureView () 函数。

另请参阅 isTextureView ().

int QOpenGLTexture:: depth () const

Returns the depth of a 3D texture.

另请参阅 width (), height (),和 setSize ().

DepthStencilMode QOpenGLTexture:: depthStencilMode () const

Returns the depth stencil mode for textures using a combined depth/stencil format.

该函数在 Qt 5.4 引入。

另请参阅 setDepthStencilMode ().

void QOpenGLTexture:: destroy ()

Destroys the underlying OpenGL texture object. This requires a current valid OpenGL context.

另请参阅 create (), isCreated (),和 textureId ().

int QOpenGLTexture:: faces () const

Returns the number of faces for this texture. For cubemap and cubemap array type targets this will be 6.

For non-cubemap type targets this will return 1.

TextureFormat QOpenGLTexture:: format () const

Returns the format of this texture object.

另请参阅 setFormat ().

void QOpenGLTexture:: generateMipMaps ()

Generates mipmaps for this texture object from mipmap level 0. If you are using a texture target and filtering option that requires mipmaps and you have disabled automatic mipmap generation then you need to call this function or the overload to create the mipmap chain.

注意: Mipmap generation is not supported for compressed textures with OpenGL ES 2.0.

另请参阅 setAutoMipMapGenerationEnabled (), setMipLevels (),和 mipLevels ().

void QOpenGLTexture:: generateMipMaps ( int baseLevel , bool resetBaseLevel = true)

Generates mipmaps for this texture object from mipmap level baseLevel . If you are using a texture target and filtering option that requires mipmaps and you have disabled automatic mipmap generation then you need to call this function or the overload to create the mipmap chain.

The generation of mipmaps to above baseLevel is achieved by setting the mipmap base level to baseLevel and then generating the mipmap chain. If resetBaseLevel is true , then the baseLevel of the texture will be reset to its previous value.

另请参阅 setAutoMipMapGenerationEnabled (), setMipLevels (),和 mipLevels ().

[static] bool QOpenGLTexture:: hasFeature ( Feature feature )

返回 true if your OpenGL implementation and version supports the texture feature feature .

int QOpenGLTexture:: height () const

Returns the height of a 2D or 3D texture.

另请参阅 width (), depth (),和 setSize ().

bool QOpenGLTexture:: isAutoMipMapGenerationEnabled () const

Returns whether auto mipmap generation is enabled for this texture object.

另请参阅 setAutoMipMapGenerationEnabled () 和 generateMipMaps ().

bool QOpenGLTexture:: isBound () const

返回 true if this texture is bound to the corresponding target of the currently active texture unit.

另请参阅 bind () 和 release ().

bool QOpenGLTexture:: isBound ( uint unit )

返回 true if this texture is bound to the corresponding target of texture unit unit .

另请参阅 bind () 和 release ().

bool QOpenGLTexture:: isCreated () const

返回 true if the underlying OpenGL texture object has been created.

另请参阅 create (), destroy (),和 textureId ().

bool QOpenGLTexture:: isFixedSamplePositions () const

Returns whether this texture uses a fixed pattern of multisample samples. If storage has not yet been allocated for this texture then this function returns the requested fixed sample position setting.

For texture targets that do not support multisampling this will return true .

另请参阅 setFixedSamplePositions () 和 isStorageAllocated ().

bool QOpenGLTexture:: isStorageAllocated () const

返回 true if server-side storage for this texture as been allocated.

The texture format, dimensions, mipmap levels and array layers cannot be altered once storage ihas been allocated.

另请参阅 allocateStorage (), setSize (), setMipLevels (), setLayers (),和 setFormat ().

bool QOpenGLTexture:: isTextureView () const

返回 true if this texture object is actually a view onto another texture object.

另请参阅 createTextureView ().

int QOpenGLTexture:: layers () const

Returns the number of array layers for this texture. If storage has not yet been allocated for this texture then this function returns the requested number of array layers.

For texture targets that do not support array layers this will return 1.

另请参阅 setLayers () 和 isStorageAllocated ().

QPair < float , float > QOpenGLTexture:: levelOfDetailRange () const

Returns the minimum and maximum level of detail parameters.

另请参阅 setLevelOfDetailRange (), minimumLevelOfDetail (),和 maximumLevelOfDetail ().

float QOpenGLTexture:: levelofDetailBias () const

Returns the level of detail bias parameter.

另请参阅 setLevelofDetailBias ().

Filter QOpenGLTexture:: magnificationFilter () const

Returns the magnification filter.

另请参阅 setMagnificationFilter ().

float QOpenGLTexture:: maximumAnisotropy () const

Returns the maximum level of anisotropy to be accounted for when performing texture lookups. This requires the GL_EXT_texture_filter_anisotropic extension.

另请参阅 setMaximumAnisotropy ().

float QOpenGLTexture:: maximumLevelOfDetail () const

Returns the maximum level of detail parameter.

另请参阅 setMaximumLevelOfDetail (), minimumLevelOfDetail (),和 levelOfDetailRange ().

int QOpenGLTexture:: maximumMipLevels () const

Returns the maximum number of mipmap levels that this texture can have given the current dimensions.

另请参阅 setMipLevels (), mipLevels (),和 setSize ().

QPair < Filter , Filter > QOpenGLTexture:: minMagFilters () const

Returns the current minification and magnification filters.

另请参阅 setMinMagFilters ().

Filter QOpenGLTexture:: minificationFilter () const

Returns the minification filter.

另请参阅 setMinificationFilter ().

float QOpenGLTexture:: minimumLevelOfDetail () const

Returns the minimum level of detail parameter.

另请参阅 setMinimumLevelOfDetail (), maximumLevelOfDetail (),和 levelOfDetailRange ().

int QOpenGLTexture:: mipBaseLevel () const

Returns the mipmap base level used for all texture lookups with this texture. The default is 0.

另请参阅 setMipBaseLevel (), mipMaxLevel (),和 mipLevelRange ().

QPair < int , int > QOpenGLTexture:: mipLevelRange () const

Returns the range of mipmap levels that can be used for texture lookups with this texture.

另请参阅 setMipLevelRange (), mipBaseLevel (),和 mipMaxLevel ().

int QOpenGLTexture:: mipLevels () const

Returns the number of mipmap levels for this texture. If storage has not yet been allocated for this texture it returns the requested number of mipmap levels.

另请参阅 setMipLevels (), maximumMipLevels (),和 isStorageAllocated ().

int QOpenGLTexture:: mipMaxLevel () const

Returns the mipmap maximum level used for all texture lookups with this texture.

另请参阅 setMipMaxLevel (), mipBaseLevel (),和 mipLevelRange ().

void QOpenGLTexture:: release ()

Unbinds this texture from the currently active texture unit.

另请参阅 bind ().

void QOpenGLTexture:: release ( uint unit , TextureUnitReset reset = DontResetTextureUnit)

Unbinds this texture from texture unit unit .

If parameter reset is true then this function will restore the active unit to the texture unit that was active upon entry.

int QOpenGLTexture:: samples () const

Returns the number of multisample sample points for this texture. If storage has not yet been allocated for this texture then this function returns the requested number of samples.

For texture targets that do not support multisampling this will return 0.

另请参阅 setSamples () 和 isStorageAllocated ().

void QOpenGLTexture:: setAutoMipMapGenerationEnabled ( bool enabled )

enabled is true , enables automatic mipmap generation for this texture object to occur whenever the level 0 mipmap data is set via setData ().

The automatic mipmap generation is enabled by default.

注意: Mipmap generation is not supported for compressed textures with OpenGL ES 2.0.

另请参阅 isAutoMipMapGenerationEnabled () 和 generateMipMaps ().

void QOpenGLTexture:: setBorderColor ( QColor color )

Sets the border color of the texture to color .

注意: This function has no effect on Mac and Qt built for OpenGL ES 2.

另请参阅 borderColor ().

void QOpenGLTexture:: setBorderColor ( float r , float g , float b , float a )

Sets the color red to r , green to g , blue to b ,和 a to the alpha value.

这是重载函数。

void QOpenGLTexture:: setBorderColor ( int r , int g , int b , int a )

Sets the color red to r , green to g , blue to b , and the alpha value to a .

这是重载函数。

void QOpenGLTexture:: setBorderColor ( uint r , uint g , uint b , uint a )

Sets the color red to r , green to g , blue to b , and the alpha value to a .

这是重载函数。

void QOpenGLTexture:: setComparisonFunction ( ComparisonFunction function )

另请参阅 comparisonFunction ().

void QOpenGLTexture:: setComparisonMode ( ComparisonMode mode )

Sets the texture comparison mode on this texture to mode . The texture comparison mode is used by shadow samplers when sampling a depth texture.

该函数在 Qt 5.5 引入。

另请参阅 comparisonMode ().

void QOpenGLTexture:: setCompressedData ( int mipLevel , int layer , CubeMapFace cubeFace , int dataSize , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)

Uploads compressed pixel data to mipLevel , array layer ,和 cubeFace . The pixel transfer can optionally be controlled with options dataSize argument should specify the size of the data pointed to by data .

If not using a compressed format () then you should use setData () 而不是此函数。

该函数在 Qt 5.3 引入。

void QOpenGLTexture:: setCompressedData ( int mipLevel , int layer , int layerCount , CubeMapFace cubeFace , int dataSize , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)

这是重载函数。

参数 layerCount is the number of layers in a texture array that are being uploaded/populated by this call.

该函数在 Qt 5.9 引入。

void QOpenGLTexture:: setCompressedData ( int mipLevel , int layer , int dataSize , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)

这是重载函数。

void QOpenGLTexture:: setCompressedData ( int mipLevel , int dataSize , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)

这是重载函数。

void QOpenGLTexture:: setCompressedData ( int dataSize , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)

这是重载函数。

void QOpenGLTexture:: setData ( int mipLevel , int layer , CubeMapFace cubeFace , PixelFormat sourceFormat , PixelType sourceType , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)

Uploads pixel data for this texture object mipLevel , array layer ,和 cubeFace . Storage must have been allocated before uploading pixel data. Some overloads of setData() will set appropriate dimensions, mipmap levels, and array layers and then allocate storage for you if they have enough information to do so. This will be noted in the function documentation.

The structure of the pixel data pointed to by data is specified by sourceFormat and sourceType . The pixel data upload can optionally be controlled by options .

If using a compressed format () then you should use setCompressedData () 而不是此函数。

该函数在 Qt 5.3 引入。

另请参阅 setCompressedData ().

void QOpenGLTexture:: setData ( int mipLevel , int layer , int layerCount , CubeMapFace cubeFace , PixelFormat sourceFormat , PixelType sourceType , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)

这是重载函数。

参数 layerCount is the number of layers in a texture array that are being uploaded/populated by this call.

该函数在 Qt 5.9 引入。

void QOpenGLTexture:: setData ( int mipLevel , int layer , PixelFormat sourceFormat , PixelType sourceType , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)

这是重载函数。

该函数在 Qt 5.3 引入。

void QOpenGLTexture:: setData ( int mipLevel , PixelFormat sourceFormat , PixelType sourceType , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)

这是重载函数。

该函数在 Qt 5.3 引入。

void QOpenGLTexture:: setData ( PixelFormat sourceFormat , PixelType sourceType , const void * data , const QOpenGLPixelTransferOptions * const options = Q_NULLPTR)

这是重载函数。

该函数在 Qt 5.3 引入。

void QOpenGLTexture:: setData (const QImage & image , MipMapGeneration genMipMaps = GenerateMipMaps)

This overload of setData () will allocate storage for you. The pixel data is contained in image . Mipmaps are generated by default. Set genMipMaps to DontGenerateMipMaps to turn off mipmap generation.

这是重载函数。

void QOpenGLTexture:: setDepthStencilMode ( DepthStencilMode mode )

If using a texture that has a combined depth/stencil format this function sets which component of the texture is accessed to mode .

When the parameter is set to DepthMode , then accessing it from the shader will access the depth component as a single float, as normal. But when the parameter is set to StencilMode , the shader will access the stencil component.

注意: This function has no effect on Mac and Qt built for OpenGL ES 2.

该函数在 Qt 5.4 引入。

另请参阅 depthStencilMode ().

void QOpenGLTexture:: setFixedSamplePositions ( bool fixed )

Sets whether the sample positions and number of samples used with a multisample capable texture target to fixed 。若设为 true the sample positions and number of samples used are the same for all texels in the image and will not depend upon the image size or internal format. This function should be called before storage is allocated for the texture.

For targets that do not support multisampling this function has no effect.

默认值为 true .

另请参阅 isFixedSamplePositions () 和 isStorageAllocated ().

void QOpenGLTexture:: setFormat ( TextureFormat format )

Sets the format of this texture object to format . This function must be called before texture storage is allocated.

Note that all formats may not be supported. The exact set of supported formats is dependent upon your OpenGL implementation and version.

另请参阅 format () 和 allocateStorage ().

void QOpenGLTexture:: setLayers ( int layers )

Sets the number of array layers to allocate storage for. This function should be called before storage is allocated for the texture.

For targets that do not support array layers this function has no effect.

另请参阅 layers () 和 isStorageAllocated ().

void QOpenGLTexture:: setLevelOfDetailRange ( float min , float max )

Sets the minimum level of detail parameters to min and the maximum level to max .

注意: This function has no effect on Qt built for OpenGL ES 2.

另请参阅 levelOfDetailRange (), setMinimumLevelOfDetail (),和 setMaximumLevelOfDetail ().

void QOpenGLTexture:: setLevelofDetailBias ( float bias )

Sets the level of detail bias to bias . Level of detail bias affects the point at which mipmapping levels change. Increasing values for level of detail bias makes the overall images blurrier or smoother. Decreasing values make the overall images sharper.

注意: This function has no effect on Qt built for OpenGL ES 2.

另请参阅 levelofDetailBias ().

void QOpenGLTexture:: setMagnificationFilter ( Filter filter )

Sets the magnification filter to filter .

另请参阅 magnificationFilter (), setMinificationFilter (),和 setMinMagFilters ().

void QOpenGLTexture:: setMaximumAnisotropy ( float anisotropy )

If your OpenGL implementation supports the GL_EXT_texture_filter_anisotropic extension this function sets the maximum anisotropy level to anisotropy .

另请参阅 maximumAnisotropy ().

void QOpenGLTexture:: setMaximumLevelOfDetail ( float value )

Sets the maximum level of detail to value . This limits the selection of lowest resolution mipmap (highest mipmap level). The default value is 1000.

注意: This function has no effect on Qt built for OpenGL ES 2.

另请参阅 maximumLevelOfDetail (), setMinimumLevelOfDetail (),和 setLevelOfDetailRange ().

void QOpenGLTexture:: setMinMagFilters ( Filter minificationFilter , Filter magnificationFilter )

Sets the minification filter to minificationFilter and the magnification filter to magnificationFilter .

另请参阅 minMagFilters (), setMinificationFilter (),和 setMagnificationFilter ().

void QOpenGLTexture:: setMinificationFilter ( Filter filter )

Sets the filter used for minification to filter .

另请参阅 minificationFilter (), setMagnificationFilter (),和 setMinMagFilters ().

void QOpenGLTexture:: setMinimumLevelOfDetail ( float value )

Sets the minimum level of detail to value . This limits the selection of highest resolution mipmap (lowest mipmap level). The default value is -1000.

注意: This function has no effect on Qt built for OpenGL ES 2.

另请参阅 minimumLevelOfDetail (), setMaximumLevelOfDetail (),和 setLevelOfDetailRange ().

void QOpenGLTexture:: setMipBaseLevel ( int baseLevel )

Sets the base mipmap level used for all texture lookups with this texture to baseLevel .

注意: This function has no effect on Qt built for OpenGL ES 2.

另请参阅 mipBaseLevel (), setMipMaxLevel (),和 setMipLevelRange ().

void QOpenGLTexture:: setMipLevelRange ( int baseLevel , int maxLevel )

Sets the range of mipmap levels that can be used for texture lookups with this texture to range from baseLevel to maxLevel .

注意: This function has no effect on Qt built for OpenGL ES 2.

另请参阅 setMipBaseLevel (), setMipMaxLevel (),和 mipLevelRange ().

void QOpenGLTexture:: setMipLevels ( int levels )

For texture targets that support mipmaps, this function sets the requested number of mipmap levels to allocate storage for. This function should be called before storage is allocated for the texture.

If the texture target does not support mipmaps this function has no effect.

另请参阅 mipLevels (), maximumMipLevels (),和 isStorageAllocated ().

void QOpenGLTexture:: setMipMaxLevel ( int maxLevel )

Sets the maximum mipmap level used for all texture lookups with this texture to maxLevel .

注意: This function has no effect on Qt built for OpenGL ES 2.

另请参阅 mipMaxLevel (), setMipBaseLevel (),和 setMipLevelRange ().

void QOpenGLTexture:: setSamples ( int samples )

Sets the number of samples to allocate storage for when rendering to a multisample capable texture target. This function should be called before storage is allocated for the texture.

For targets that do not support multisampling this function has no effect.

另请参阅 samples () 和 isStorageAllocated ().

void QOpenGLTexture:: setSize ( int width , int height = 1, int depth = 1)

Sets the dimensions of this texture object to width , height ,和 depth . The default for each dimension is 1. The maximum allowable texture size is dependent upon your OpenGL implementation. Allocating storage for a texture less than the maximum size can still fail if your system is low on resources.

另请参阅 width (), height (),和 depth ().

void QOpenGLTexture:: setSwizzleMask ( SwizzleComponent component , SwizzleValue value )

GLSL shaders are able to reorder the components of the vec4 returned by texture functions. It is also desirable to be able to control this reordering from CPU side code. This is made possible by swizzle masks since OpenGL 3.3.

Each component of the texture can be mapped to one of the SwizzleValue 选项。

This function maps component to the output value .

注意: This function has no effect on Mac and Qt built for OpenGL ES 2.

另请参阅 swizzleMask ().

void QOpenGLTexture:: setSwizzleMask ( SwizzleValue r , SwizzleValue g , SwizzleValue b , SwizzleValue a )

参数 r , g , b ,和 a are values used for setting the colors red, green, blue, and the alpha value.

这是重载函数。

void QOpenGLTexture:: setWrapMode ( WrapMode mode )

Sets the wrap (or repeat mode) for all texture dimentions to mode .

另请参阅 wrapMode ().

void QOpenGLTexture:: setWrapMode ( CoordinateDirection direction , WrapMode mode )

Holds the texture dimension direction .

这是重载函数。

SwizzleValue QOpenGLTexture:: swizzleMask ( SwizzleComponent component ) const

Returns the swizzle mask for texture component .

另请参阅 setSwizzleMask ().

Target QOpenGLTexture:: target () const

Returns the binding target of this texture.

该函数在 Qt 5.4 引入。

GLuint QOpenGLTexture:: textureId () const

Returns the name of the underlying OpenGL texture object or 0 if it has not yet been created.

另请参阅 create (), destroy (),和 isCreated ().

int QOpenGLTexture:: width () const

Returns the width of a 1D, 2D or 3D texture.

另请参阅 height (), depth (),和 setSize ().

WrapMode QOpenGLTexture:: wrapMode ( CoordinateDirection direction ) const

Returns the wrap mode for the texture dimension direction .

另请参阅 setWrapMode ().