内容表

上一话题

QSurface

下一话题

QSyntaxHighlighter

QSurfaceFormat

QSurfaceFormat class represents the format of a QSurface . 更多

Inheritance diagram of PySide2.QtGui.QSurfaceFormat

概要

函数

静态函数

详细描述

The format includes the size of the color buffers, red, green, and blue; the size of the alpha buffer; the size of the depth and stencil buffers; and number of samples per pixel for multisampling. In addition, the format contains surface configuration parameters such as OpenGL profile and version for rendering, whether or not to enable stereo buffers, and swap behaviour.

注意

When troubleshooting context or window format issues, it can be helpful to enable the logging category qt.qpa.gl . Depending on the platform, this may print useful debug information when it comes to OpenGL initialization and the native visual or framebuffer configurations which QSurfaceFormat gets mapped to.

class QSurfaceFormat

QSurfaceFormat(options)

QSurfaceFormat(other)

param other

QSurfaceFormat

param options

FormatOptions

Constructs a default initialized QSurfaceFormat .

注意

By default OpenGL 2.0 is requested since this provides the highest grade of portability between platforms and OpenGL implementations.

构造 QSurfaceFormat with the given format options .

PySide2.QtGui.QSurfaceFormat. FormatOption

This enum contains format options for use with QSurfaceFormat .

常量

描述

QSurfaceFormat.StereoBuffers

Used to request stereo buffers in the surface format.

QSurfaceFormat.DebugContext

Used to request a debug context with extra debugging information.

QSurfaceFormat.DeprecatedFunctions

Used to request that deprecated functions be included in the OpenGL context profile. If not specified, you should get a forward compatible context without support functionality marked as deprecated. This requires OpenGL version 3.0 or higher.

QSurfaceFormat.ResetNotification

Enables notifications about resets of the OpenGL context. The status is then queryable via the context’s isValid() function. Note that not setting this flag does not guarantee that context state loss never occurs. Additionally, some implementations may choose to report context loss regardless of this flag.

PySide2.QtGui.QSurfaceFormat. SwapBehavior

此枚举用于 QSurfaceFormat to specify the swap behaviour of a surface. The swap behaviour is mostly transparent to the application, but it affects factors such as rendering latency and throughput.

常量

描述

QSurfaceFormat.DefaultSwapBehavior

The default, unspecified swap behaviour of the platform.

QSurfaceFormat.SingleBuffer

Used to request single buffering, which might result in flickering when OpenGL rendering is done directly to screen without an intermediate offscreen buffer.

QSurfaceFormat.DoubleBuffer

This is typically the default swap behaviour on desktop platforms, consisting of one back buffer and one front buffer. Rendering is done to the back buffer, and then the back buffer and front buffer are swapped, or the contents of the back buffer are copied to the front buffer, depending on the implementation.

QSurfaceFormat.TripleBuffer

This swap behaviour is sometimes used in order to decrease the risk of skipping a frame when the rendering rate is just barely keeping up with the screen refresh rate. Depending on the platform it might also lead to slightly more efficient use of the GPU due to improved pipelining behaviour. Triple buffering comes at the cost of an extra frame of memory usage and latency, and might not be supported depending on the underlying platform.

PySide2.QtGui.QSurfaceFormat. RenderableType

This enum specifies the rendering backend for the surface.

常量

描述

QSurfaceFormat.DefaultRenderableType

The default, unspecified rendering method

QSurfaceFormat.OpenGL

Desktop OpenGL rendering

QSurfaceFormat.OpenGLES

OpenGL ES 2.0 rendering

QSurfaceFormat.OpenVG

Open Vector Graphics rendering

PySide2.QtGui.QSurfaceFormat. OpenGLContextProfile

This enum is used to specify the OpenGL context profile, in conjunction with setMajorVersion() and setMinorVersion() .

Profiles are exposed in OpenGL 3.2 and above, and are used to choose between a restricted core profile, and a compatibility profile which might contain deprecated support functionality.

Note that the core profile might still contain functionality that is deprecated and scheduled for removal in a higher version. To get access to the deprecated functionality for the core profile in the set OpenGL version you can use the QSurfaceFormat format option DeprecatedFunctions .

常量

描述

QSurfaceFormat.NoProfile

OpenGL version is lower than 3.2. For 3.2 and newer this is same as .

QSurfaceFormat.CoreProfile

Functionality deprecated in OpenGL version 3.0 is not available.

QSurfaceFormat.CompatibilityProfile

Functionality from earlier OpenGL versions is available.

PySide2.QtGui.QSurfaceFormat. ColorSpace

This enum is used to specify the preferred color space, controlling if the window’s associated default framebuffer is able to do updates and blending in a given encoding instead of the standard linear operations.

常量

描述

QSurfaceFormat.DefaultColorSpace

The default, unspecified color space.

QSurfaceFormat.sRGBColorSpace

GL_ARB_framebuffer_sRGB or GL_EXT_framebuffer_sRGB is supported by the platform and this value is set, the window will be created with an sRGB-capable default framebuffer. Note that some platforms may return windows with a sRGB-capable default framebuffer even when not requested explicitly.

New in version 5.10.

PySide2.QtGui.QSurfaceFormat. alphaBufferSize ( )
返回类型

int

Get the size in bits of the alpha channel of the color buffer.

PySide2.QtGui.QSurfaceFormat. blueBufferSize ( )
返回类型

int

Get the size in bits of the blue channel of the color buffer.

PySide2.QtGui.QSurfaceFormat. colorSpace ( )
返回类型

ColorSpace

Returns the color space.

另请参阅

setColorSpace()

static PySide2.QtGui.QSurfaceFormat. defaultFormat ( )
返回类型

QSurfaceFormat

Returns the global default surface format.

setDefaultFormat() is not called, this is a default-constructed QSurfaceFormat .

PySide2.QtGui.QSurfaceFormat. depthBufferSize ( )
返回类型

int

Returns the depth buffer size.

PySide2.QtGui.QSurfaceFormat. greenBufferSize ( )
返回类型

int

Get the size in bits of the green channel of the color buffer.

PySide2.QtGui.QSurfaceFormat. hasAlpha ( )
返回类型

bool

返回 true if the alpha buffer size is greater than zero.

This means that the surface might be used with per pixel translucency effects.

PySide2.QtGui.QSurfaceFormat. majorVersion ( )
返回类型

int

Returns the major OpenGL version.

The default version is 2.0.

另请参阅

setMajorVersion()

PySide2.QtGui.QSurfaceFormat. minorVersion ( )
返回类型

int

Returns the minor OpenGL version.

另请参阅

setMinorVersion()

PySide2.QtGui.QSurfaceFormat. __ne__ ( arg__2 )
参数

arg__2 QSurfaceFormat

返回类型

bool

PySide2.QtGui.QSurfaceFormat. __eq__ ( arg__2 )
参数

arg__2 QSurfaceFormat

返回类型

bool

PySide2.QtGui.QSurfaceFormat. options ( )
返回类型

FormatOptions

Returns the currently set format options.

PySide2.QtGui.QSurfaceFormat. profile ( )
返回类型

OpenGLContextProfile

Get the configured OpenGL context profile.

This setting is ignored if the requested OpenGL version is less than 3.2.

另请参阅

setProfile()

PySide2.QtGui.QSurfaceFormat. redBufferSize ( )
返回类型

int

Get the size in bits of the red channel of the color buffer.

PySide2.QtGui.QSurfaceFormat. renderableType ( )
返回类型

RenderableType

Gets the renderable type.

Chooses between desktop OpenGL, OpenGL ES, and OpenVG .

PySide2.QtGui.QSurfaceFormat. samples ( )
返回类型

int

Returns the number of samples per pixel when multisampling is enabled, or -1 when multisampling is disabled. The default return value is -1 .

另请参阅

setSamples()

PySide2.QtGui.QSurfaceFormat. setAlphaBufferSize ( size )
参数

size int

Set the desired size in bits of the alpha channel of the color buffer.

另请参阅

alphaBufferSize()

PySide2.QtGui.QSurfaceFormat. setBlueBufferSize ( size )
参数

size int

Set the desired size in bits of the blue channel of the color buffer.

另请参阅

blueBufferSize()

PySide2.QtGui.QSurfaceFormat. setColorSpace ( colorSpace )
参数

colorSpace ColorSpace

Sets the preferred colorSpace .

For example, this allows requesting windows with default framebuffers that are sRGB-capable on platforms that support it.

注意

When the requested color space is not supported by the platform, the request is ignored. Query the QSurfaceFormat after window creation to verify if the color space request could be honored or not.

注意

This setting controls if the default framebuffer of the window is capable of updates and blending in a given color space. It does not change applications’ output by itself. The applications’ rendering code will still have to opt in via the appropriate OpenGL calls to enable updates and blending to be performed in the given color space instead of using the standard linear operations.

另请参阅

colorSpace()

static PySide2.QtGui.QSurfaceFormat. setDefaultFormat ( format )
参数

format QSurfaceFormat

Sets the global default surface format .

This format is used by default in QOpenGLContext , QWindow , QOpenGLWidget and similar classes.

It can always be overridden on a per-instance basis by using the class in question’s own setFormat() function. However, it is often more convenient to set the format for all windows once at the start of the application. It also guarantees proper behavior in cases where shared contexts are required, because settings the format via this function guarantees that all contexts and surfaces, even the ones created internally by Qt, will use the same format.

注意

When setting AA_ShareOpenGLContexts , it is strongly recommended to place the call to this function before the construction of the QGuiApplication or QApplication . Otherwise format will not be applied to the global share context and therefore issues may arise with context sharing afterwards.

另请参阅

defaultFormat()

PySide2.QtGui.QSurfaceFormat. setDepthBufferSize ( size )
参数

size int

Set the minimum depth buffer size to size .

另请参阅

depthBufferSize()

PySide2.QtGui.QSurfaceFormat. setGreenBufferSize ( size )
参数

size int

Set the desired size in bits of the green channel of the color buffer.

另请参阅

greenBufferSize()

PySide2.QtGui.QSurfaceFormat. setMajorVersion ( majorVersion )
参数

majorVersion int

Sets the desired major OpenGL version.

另请参阅

majorVersion()

PySide2.QtGui.QSurfaceFormat. setMinorVersion ( minorVersion )
参数

minorVersion int

Sets the desired minor OpenGL version.

The default version is 2.0.

另请参阅

minorVersion()

PySide2.QtGui.QSurfaceFormat. setOption ( opt )
参数

opt FormatOptions

注意

此函数被弃用。

这是重载函数。

使用 setOption ( FormatOption , bool) or setOptions() 代替。

Sets the format options to the OR combination of opt and the current format options.

PySide2.QtGui.QSurfaceFormat. setOption ( option [ , on=true ] )
参数

Sets the format option option if on is true; otherwise, clears the option.

PySide2.QtGui.QSurfaceFormat. setOptions ( options )
参数

options FormatOptions

Sets the format options to options .

PySide2.QtGui.QSurfaceFormat. setProfile ( profile )
参数

profile OpenGLContextProfile

Sets the desired OpenGL context profile .

This setting is ignored if the requested OpenGL version is less than 3.2.

另请参阅

profile()

PySide2.QtGui.QSurfaceFormat. setRedBufferSize ( size )
参数

size int

Set the desired size in bits of the red channel of the color buffer.

另请参阅

redBufferSize()

PySide2.QtGui.QSurfaceFormat. setRenderableType ( type )
参数

type RenderableType

Sets the desired renderable type .

Chooses between desktop OpenGL, OpenGL ES, and OpenVG .

另请参阅

renderableType()

PySide2.QtGui.QSurfaceFormat. setSamples ( numSamples )
参数

numSamples int

Set the preferred number of samples per pixel when multisampling is enabled to numSamples . By default, multisampling is disabled.

另请参阅

samples()

PySide2.QtGui.QSurfaceFormat. setStencilBufferSize ( size )
参数

size int

Set the preferred stencil buffer size to size bits.

PySide2.QtGui.QSurfaceFormat. setStereo ( enable )
参数

enable bool

enable is true enables stereo buffering; otherwise disables stereo buffering.

Stereo buffering is disabled by default.

Stereo buffering provides extra color buffers to generate left-eye and right-eye images.

另请参阅

stereo()

PySide2.QtGui.QSurfaceFormat. setSwapBehavior ( behavior )
参数

behavior SwapBehavior

Set the swap behavior of the surface.

The swap behavior specifies whether single, double, or triple buffering is desired. The default, DefaultSwapBehavior , gives the default swap behavior of the platform.

另请参阅

swapBehavior()

PySide2.QtGui.QSurfaceFormat. setSwapInterval ( interval )
参数

interval int

Sets the preferred swap interval. The swap interval specifies the minimum number of video frames that are displayed before a buffer swap occurs. This can be used to sync the GL drawing into a window to the vertical refresh of the screen.

Setting an interval value of 0 will turn the vertical refresh syncing off, any value higher than 0 will turn the vertical syncing on. Setting interval to a higher value, for example 10, results in having 10 vertical retraces between every buffer swap.

The default interval is 1.

Changing the swap interval may not be supported by the underlying platform. In this case, the request will be silently ignored.

另请参阅

swapInterval()

PySide2.QtGui.QSurfaceFormat. setVersion ( major , minor )
参数
  • major int

  • minor int

Sets the desired major and minor OpenGL versions.

The default version is 2.0.

另请参阅

version()

PySide2.QtGui.QSurfaceFormat. stencilBufferSize ( )
返回类型

int

Returns the stencil buffer size in bits.

PySide2.QtGui.QSurfaceFormat. stereo ( )
返回类型

bool

返回 true if stereo buffering is enabled; otherwise returns false. Stereo buffering is disabled by default.

另请参阅

setStereo()

PySide2.QtGui.QSurfaceFormat. swapBehavior ( )
返回类型

SwapBehavior

Returns the configured swap behaviour.

另请参阅

setSwapBehavior()

PySide2.QtGui.QSurfaceFormat. swapInterval ( )
返回类型

int

Returns the swap interval.

另请参阅

setSwapInterval()

PySide2.QtGui.QSurfaceFormat. testOption ( opt )
参数

opt FormatOptions

返回类型

bool

注意

此函数被弃用。

这是重载函数。

使用 testOption ( FormatOption ) 取而代之。

返回 true if any of the options in opt is currently set on this object; otherwise returns false.

另请参阅

setOption()

PySide2.QtGui.QSurfaceFormat. testOption ( option )
参数

option FormatOption

返回类型

bool

Returns true if the format option option is set; otherwise returns false.

另请参阅

options()

PySide2.QtGui.QSurfaceFormat. version ( )
返回类型

返回 QPair <int, int> representing the OpenGL version.

Useful for version checks, for example format. >= qMakePair (3, 2)

另请参阅

setVersion()