QOpenGLTexture¶

PyQt5.QtGui.QOpenGLTexture

Description¶

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(...);

Note that the 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.

Classes¶

Features

Enums¶

BindingTarget

TODO

Member

Value

Description

BindingTarget1D

TODO

TODO

BindingTarget1DArray

TODO

TODO

BindingTarget2D

TODO

TODO

BindingTarget2DArray

TODO

TODO

BindingTarget2DMultisample

TODO

TODO

BindingTarget2DMultisampleArray

TODO

TODO

BindingTarget3D

TODO

TODO

BindingTargetBuffer

TODO

TODO

BindingTargetCubeMap

TODO

TODO

BindingTargetCubeMapArray

TODO

TODO

BindingTargetRectangle

TODO

TODO


ComparisonFunction

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

Member

Value

Description

CommpareNotEqual

0x0205

Equivalent to GL_NOTEQUAL.

CompareAlways

0x0207

Equivalent to GL_ALWAYS.

CompareEqual

0x0202

Equivalent to GL_EQUAL.

CompareGreater

0x0204

Equivalent to GL_GREATER.

CompareGreaterEqual

0x0206

Equivalent to GL_GEQUAL.

CompareLess

0x0201

Equivalent to GL_LESS.

CompareLessEqual

0x0203

Equivalent to GL_LEQUAL.

CompareNever

0x0200

Equivalent to GL_NEVER.


ComparisonMode

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

Member

Value

Description

CompareNone

0x0000

Equivalent to GL_NONE.

CompareRefToTexture

0x884E

Equivalent to GL_COMPARE_REF_TO_TEXTURE.


CoordinateDirection

TODO

Member

Value

Description

DirectionR

TODO

TODO

DirectionS

TODO

TODO

DirectionT

TODO

TODO


CubeMapFace

TODO

Member

Value

Description

CubeMapNegativeX

TODO

TODO

CubeMapNegativeY

TODO

TODO

CubeMapNegativeZ

TODO

TODO

CubeMapPositiveX

TODO

TODO

CubeMapPositiveY

TODO

TODO

CubeMapPositiveZ

TODO

TODO


DepthStencilMode

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

Member

Value

Description

DepthMode

0x1902

Equivalent to GL_DEPTH_COMPONENT.

StencilMode

0x1901

Equivalent to GL_STENCIL_INDEX.


Feature

TODO

Member

Value

Description

AnisotropicFiltering

TODO

TODO

ImmutableMultisampleStorage

TODO

TODO

ImmutableStorage

TODO

TODO

NPOTTextureRepeat

TODO

TODO

NPOTTextures

TODO

TODO

StencilTexturing

TODO

TODO

Swizzle

TODO

TODO

Texture1D

TODO

TODO

Texture3D

TODO

TODO

TextureArrays

TODO

TODO

TextureBuffer

TODO

TODO

TextureComparisonOperators

TODO

TODO

TextureCubeMapArrays

TODO

TODO

TextureMipMapLevel

TODO

TODO

TextureMultisample

TODO

TODO

TextureRectangle

TODO

TODO


Filter

This enum defines the filtering parameters for a QOpenGLTexture object.

Member

Value

Description

Linear

0x2601

Equivalent to GL_LINEAR

LinearMipMapLinear

0x2703

Equivalent to GL_LINEAR_MIPMAP_LINEAR

LinearMipMapNearest

0x2701

Equivalent to GL_LINEAR_MIPMAP_NEAREST

Nearest

0x2600

Equivalent to GL_NEAREST

NearestMipMapLinear

0x2702

Equivalent to GL_NEAREST_MIPMAP_LINEAR

NearestMipMapNearest

0x2700

Equivalent to GL_NEAREST_MIPMAP_NEAREST


MipMapGeneration

TODO

Member

Value

Description

DontGenerateMipMaps

TODO

TODO

GenerateMipMaps

TODO

TODO


PixelFormat

TODO

Member

Value

Description

Alpha

TODO

TODO

BGR

TODO

TODO

BGR_Integer

TODO

TODO

BGRA

TODO

TODO

BGRA_Integer

TODO

TODO

Depth

TODO

TODO

DepthStencil

TODO

TODO

Luminance

TODO

TODO

LuminanceAlpha

TODO

TODO

NoSourceFormat

TODO

TODO

Red

TODO

TODO

Red_Integer

TODO

TODO

RG

TODO

TODO

RG_Integer

TODO

TODO

RGB

TODO

TODO

RGB_Integer

TODO

TODO

RGBA

TODO

TODO

RGBA_Integer

TODO

TODO

Stencil

TODO

TODO


PixelType

TODO

Member

Value

Description

Float16

TODO

TODO

Float16OES

TODO

TODO

Float32

TODO

TODO

Float32_D32_UInt32_S8_X24

TODO

TODO

Int16

TODO

TODO

Int32

TODO

TODO

Int8

TODO

TODO

NoPixelType

TODO

TODO

UInt16

TODO

TODO

UInt16_R5G6B5

TODO

TODO

UInt16_R5G6B5_Rev

TODO

TODO

UInt16_RGB5A1

TODO

TODO

UInt16_RGB5A1_Rev

TODO

TODO

UInt16_RGBA4

TODO

TODO

UInt16_RGBA4_Rev

TODO

TODO

UInt32

TODO

TODO

UInt32_D24S8

TODO

TODO

UInt32_RG11B10F

TODO

TODO

UInt32_RGB10A2

TODO

TODO

UInt32_RGB10A2_Rev

TODO

TODO

UInt32_RGB9_E5

TODO

TODO

UInt32_RGBA8

TODO

TODO

UInt32_RGBA8_Rev

TODO

TODO

UInt8

TODO

TODO

UInt8_RG3B2

TODO

TODO

UInt8_RG3B2_Rev

TODO

TODO


SwizzleComponent

TODO

Member

Value

Description

SwizzleAlpha

TODO

TODO

SwizzleBlue

TODO

TODO

SwizzleGreen

TODO

TODO

SwizzleRed

TODO

TODO


SwizzleValue

TODO

Member

Value

Description

AlphaValue

TODO

TODO

BlueValue

TODO

TODO

GreenValue

TODO

TODO

OneValue

TODO

TODO

RedValue

TODO

TODO

ZeroValue

TODO

TODO


Target

This enum defines the texture target of a QOpenGLTexture object.

Member

Value

Description

Target1D

0x0DE0

A 1-dimensional texture. Equivalent to GL_TEXTURE_1D.

Target1DArray

0x8C18

An array of 1-dimensional textures. Equivalent to GL_TEXTURE_1D_ARRAY

Target2D

0x0DE1

A 2-dimensional texture. Equivalent to GL_TEXTURE_2D

Target2DArray

0x8C1A

An array of 1-dimensional textures. Equivalent to GL_TEXTURE_2D_ARRAY

Target2DMultisample

0x9100

A 2-dimensional texture with multisample support. Equivalent to GL_TEXTURE_2D_MULTISAMPLE

Target2DMultisampleArray

0x9102

An array of 2-dimensional textures with multisample support. Equivalent to GL_TEXTURE_2D_MULTISAMPLE_ARRAY

Target3D

0x806F

A 3-dimensional texture. Equivalent to GL_TEXTURE_3D

TargetBuffer

0x8C2A

A texture with data from an OpenGL buffer object. Equivalent to GL_TEXTURE_BUFFER

TargetCubeMap

0x8513

A cubemap texture. Equivalent to GL_TEXTURE_CUBE_MAP

TargetCubeMapArray

0x9009

An array of cubemap textures. Equivalent to GL_TEXTURE_CUBE_MAP_ARRAY

TargetRectangle

0x84F5

A rectangular 2-dimensional texture. Equivalent to GL_TEXTURE_RECTANGLE


TextureFormat

TODO

Member

Value

Description

AlphaFormat

TODO

TODO

D16

TODO

TODO

D24

TODO

TODO

D24S8

TODO

TODO

D32

TODO

TODO

D32F

TODO

TODO

D32FS8X24

TODO

TODO

DepthFormat

TODO

TODO

LuminanceAlphaFormat

TODO

TODO

LuminanceFormat

TODO

TODO

NoFormat

TODO

TODO

R11_EAC_SNorm

TODO

TODO

R11_EAC_UNorm

TODO

TODO

R16_SNorm

TODO

TODO

R16_UNorm

TODO

TODO

R16F

TODO

TODO

R16I

TODO

TODO

R16U

TODO

TODO

R32F

TODO

TODO

R32I

TODO

TODO

R32U

TODO

TODO

R5G6B5

TODO

TODO

R8_SNorm

TODO

TODO

R8_UNorm

TODO

TODO

R8I

TODO

TODO

R8U

TODO

TODO

R_ATI1N_SNorm

TODO

TODO

R_ATI1N_UNorm

TODO

TODO

RG11_EAC_SNorm

TODO

TODO

RG11_EAC_UNorm

TODO

TODO

RG11B10F

TODO

TODO

RG16_SNorm

TODO

TODO

RG16_UNorm

TODO

TODO

RG16F

TODO

TODO

RG16I

TODO

TODO

RG16U

TODO

TODO

RG32F

TODO

TODO

RG32I

TODO

TODO

RG32U

TODO

TODO

RG3B2

TODO

TODO

RG8_SNorm

TODO

TODO

RG8_UNorm

TODO

TODO

RG8I

TODO

TODO

RG8U

TODO

TODO

RG_ATI2N_SNorm

TODO

TODO

RG_ATI2N_UNorm

TODO

TODO

RGB10A2

TODO

TODO

RGB16_SNorm

TODO

TODO

RGB16_UNorm

TODO

TODO

RGB16F

TODO

TODO

RGB16I

TODO

TODO

RGB16U

TODO

TODO

RGB32F

TODO

TODO

RGB32I

TODO

TODO

RGB32U

TODO

TODO

RGB5A1

TODO

TODO

RGB8_ETC1

TODO

TODO

RGB8_ETC2

TODO

TODO

RGB8_PunchThrough_Alpha1_ETC2

TODO

TODO

RGB8_SNorm

TODO

TODO

RGB8_UNorm

TODO

TODO

RGB8I

TODO

TODO

RGB8U

TODO

TODO

RGB9E5

TODO

TODO

RGB_BP_SIGNED_FLOAT

TODO

TODO

RGB_BP_UNorm

TODO

TODO

RGB_BP_UNSIGNED_FLOAT

TODO

TODO

RGB_DXT1

TODO

TODO

RGBA16_SNorm

TODO

TODO

RGBA16_UNorm

TODO

TODO

RGBA16F

TODO

TODO

RGBA16I

TODO

TODO

RGBA16U

TODO

TODO

RGBA32F

TODO

TODO

RGBA32I

TODO

TODO

RGBA32U

TODO

TODO

RGBA4

TODO

TODO

RGBA8_ETC2_EAC

TODO

TODO

RGBA8_SNorm

TODO

TODO

RGBA8_UNorm

TODO

TODO

RGBA8I

TODO

TODO

RGBA8U

TODO

TODO

RGBA_ASTC_10x10

TODO

TODO

RGBA_ASTC_10x5

TODO

TODO

RGBA_ASTC_10x6

TODO

TODO

RGBA_ASTC_10x8

TODO

TODO

RGBA_ASTC_12x10

TODO

TODO

RGBA_ASTC_12x12

TODO

TODO

RGBA_ASTC_4x4

TODO

TODO

RGBA_ASTC_5x4

TODO

TODO

RGBA_ASTC_5x5

TODO

TODO

RGBA_ASTC_6x5

TODO

TODO

RGBA_ASTC_6x6

TODO

TODO

RGBA_ASTC_8x5

TODO

TODO

RGBA_ASTC_8x6

TODO

TODO

RGBA_ASTC_8x8

TODO

TODO

RGBA_DXT1

TODO

TODO

RGBA_DXT3

TODO

TODO

RGBA_DXT5

TODO

TODO

RGBAFormat

TODO

TODO

RGBFormat

TODO

TODO

S8

TODO

TODO

SRGB8

TODO

TODO

SRGB8_Alpha8

TODO

TODO

SRGB8_Alpha8_ASTC_10x10

TODO

TODO

SRGB8_Alpha8_ASTC_10x5

TODO

TODO

SRGB8_Alpha8_ASTC_10x6

TODO

TODO

SRGB8_Alpha8_ASTC_10x8

TODO

TODO

SRGB8_Alpha8_ASTC_12x10

TODO

TODO

SRGB8_Alpha8_ASTC_12x12

TODO

TODO

SRGB8_Alpha8_ASTC_4x4

TODO

TODO

SRGB8_Alpha8_ASTC_5x4

TODO

TODO

SRGB8_Alpha8_ASTC_5x5

TODO

TODO

SRGB8_Alpha8_ASTC_6x5

TODO

TODO

SRGB8_Alpha8_ASTC_6x6

TODO

TODO

SRGB8_Alpha8_ASTC_8x5

TODO

TODO

SRGB8_Alpha8_ASTC_8x6

TODO

TODO

SRGB8_Alpha8_ASTC_8x8

TODO

TODO

SRGB8_Alpha8_ETC2_EAC

TODO

TODO

SRGB8_ETC2

TODO

TODO

SRGB8_PunchThrough_Alpha1_ETC2

TODO

TODO

SRGB_Alpha_DXT1

TODO

TODO

SRGB_Alpha_DXT3

TODO

TODO

SRGB_Alpha_DXT5

TODO

TODO

SRGB_BP_UNorm

TODO

TODO

SRGB_DXT1

TODO

TODO


TextureUnitReset

TODO

Member

Value

Description

DontResetTextureUnit

TODO

TODO

ResetTextureUnit

TODO

TODO


WrapMode

TODO

Member

Value

Description

ClampToBorder

TODO

TODO

ClampToEdge

TODO

TODO

MirroredRepeat

TODO

TODO

Repeat

TODO

TODO

Methods¶

__init__(Target)

TODO


__init__(QImage, genMipMaps: MipMapGeneration = GenerateMipMaps)

TODO


allocateStorage()

TODO


allocateStorage(PixelFormat, PixelType)

TODO


bind()

TODO


bind(int, reset: TextureUnitReset = DontResetTextureUnit)

TODO


borderColor() → QColor

See also

setBorderColor().


@staticmethod
boundTextureId(BindingTarget) → int

TODO


@staticmethod
boundTextureId(int, BindingTarget) → int

TODO


comparisonFunction() → ComparisonFunction

TODO


comparisonMode() → ComparisonMode

create() → bool

TODO


createTextureView(Target, TextureFormat, int, int, int, int) → QOpenGLTexture

TODO


depth() → int

TODO


depthStencilMode() → DepthStencilMode

TODO


destroy()

TODO


faces() → int

TODO


format() → TextureFormat

See also

setFormat().


generateMipMaps()

TODO


generateMipMaps(int, resetBaseLevel: bool = True)

TODO


@staticmethod
hasFeature(Feature) → bool

TODO


height() → int

TODO


isAutoMipMapGenerationEnabled() → bool

TODO


isBound() → bool

TODO


isBound(int) → bool

TODO


isCreated() → bool

TODO


isFixedSamplePositions() → bool

TODO


isStorageAllocated() → bool

TODO


isTextureView() → bool

TODO


layers() → int

See also

setLayers().


levelofDetailBias() → float

levelOfDetailRange() → Tuple[float, float]

magnificationFilter() → Filter

maximumAnisotropy() → float

maximumLevelOfDetail() → float

maximumMipLevels() → int

TODO


minificationFilter() → Filter

TODO


minimumLevelOfDetail() → float

minMagFilters() → Tuple[Filter, Filter]

See also

setMinMagFilters().


mipBaseLevel() → int

See also

setMipBaseLevel().


mipLevelRange() → Tuple[int, int]

See also

setMipLevelRange().


mipLevels() → int

See also

setMipLevels().


mipMaxLevel() → int

See also

setMipMaxLevel().


release()

TODO


release(int, reset: TextureUnitReset = DontResetTextureUnit)

TODO


samples() → int

See also

setSamples().


setAutoMipMapGenerationEnabled(bool)

setBorderColor(Union[QColor, GlobalColor, QGradient])

See also

borderColor().


setComparisonFunction(ComparisonFunction)

TODO


setComparisonMode(ComparisonMode)

See also

comparisonMode().


setCompressedData(int, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setCompressedData(int, int, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setCompressedData(int, int, int, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setCompressedData(int, int, CubeMapFace, int, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setCompressedData(int, int, int, CubeMapFace, int, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setData(QImage, genMipMaps: MipMapGeneration = GenerateMipMaps)

TODO


setData(PixelFormat, PixelType, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setData(int, PixelFormat, PixelType, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setData(int, int, PixelFormat, PixelType, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setData(int, int, CubeMapFace, PixelFormat, PixelType, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setData(int, int, int, CubeMapFace, PixelFormat, PixelType, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setData(int, int, int, int, int, int, PixelFormat, PixelType, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setData(int, int, int, int, int, int, int, PixelFormat, PixelType, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setData(int, int, int, int, int, int, int, int, PixelFormat, PixelType, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setData(int, int, int, int, int, int, int, int, CubeMapFace, PixelFormat, PixelType, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setData(int, int, int, int, int, int, int, int, CubeMapFace, int, PixelFormat, PixelType, sip.voidptr, options: QOpenGLPixelTransferOptions = None)

TODO


setDepthStencilMode(DepthStencilMode)

TODO


setFixedSamplePositions(bool)

setFormat(TextureFormat)

TODO


setLayers(int)

See also

layers().


setLevelofDetailBias(float)

setLevelOfDetailRange(float, float)

setMagnificationFilter(Filter)

setMaximumAnisotropy(float)

setMaximumLevelOfDetail(float)

setMinificationFilter(Filter)

TODO


setMinimumLevelOfDetail(float)

setMinMagFilters(Filter, Filter)

See also

minMagFilters().


setMipBaseLevel(int)

See also

mipBaseLevel().


setMipLevelRange(int, int)

See also

mipLevelRange().


setMipLevels(int)

See also

mipLevels().


setMipMaxLevel(int)

See also

mipMaxLevel().


setSamples(int)

See also

samples().


setSize(int, height: int = 1, depth: int = 1)

TODO


setSwizzleMask(SwizzleComponent, SwizzleValue)

TODO


setSwizzleMask(SwizzleValue, SwizzleValue, SwizzleValue, SwizzleValue)

TODO


setWrapMode(WrapMode)

TODO


setWrapMode(CoordinateDirection, WrapMode)

TODO


swizzleMask(SwizzleComponent) → SwizzleValue

TODO


target() → Target

TODO


textureId() → int

TODO


width() → int

TODO


wrapMode(CoordinateDirection) → WrapMode

TODO