QSurfaceFormat 类表示格式为 QSurface . 更多...
头: | #include <QSurfaceFormat> |
CMake: |
find_package(Qt6 COMPONENTS Gui REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
Since: | Qt 5.0 |
enum | ColorSpace { DefaultColorSpace, sRGBColorSpace } |
enum | FormatOption { StereoBuffers, DebugContext, DeprecatedFunctions, ResetNotification, ProtectedContent } |
flags | FormatOptions |
enum | OpenGLContextProfile { NoProfile, CoreProfile, CompatibilityProfile } |
enum | RenderableType { DefaultRenderableType, OpenGL, OpenGLES, OpenVG } |
enum | SwapBehavior { DefaultSwapBehavior, SingleBuffer, DoubleBuffer, TripleBuffer } |
QSurfaceFormat (const QSurfaceFormat & other ) | |
QSurfaceFormat (QSurfaceFormat::FormatOptions options ) | |
QSurfaceFormat () | |
QSurfaceFormat & | operator= (const QSurfaceFormat & other ) |
~QSurfaceFormat () | |
int | alphaBufferSize () const |
int | blueBufferSize () const |
const QColorSpace & | colorSpace () const |
int | depthBufferSize () const |
int | greenBufferSize () const |
bool | hasAlpha () const |
int | majorVersion () const |
int | minorVersion () const |
QSurfaceFormat::FormatOptions | options () const |
QSurfaceFormat::OpenGLContextProfile | profile () const |
int | redBufferSize () const |
QSurfaceFormat::RenderableType | renderableType () const |
int | samples () const |
void | setAlphaBufferSize (int size ) |
void | setBlueBufferSize (int size ) |
void | setColorSpace (const QColorSpace & colorSpace ) |
void | setColorSpace (QSurfaceFormat::ColorSpace colorSpace ) |
void | setDepthBufferSize (int size ) |
void | setGreenBufferSize (int size ) |
void | setMajorVersion (int major ) |
void | setMinorVersion (int minor ) |
void | setOption (QSurfaceFormat::FormatOption option , bool on = true) |
void | setOptions (QSurfaceFormat::FormatOptions options ) |
void | setProfile (QSurfaceFormat::OpenGLContextProfile profile ) |
void | setRedBufferSize (int size ) |
void | setRenderableType (QSurfaceFormat::RenderableType type ) |
void | setSamples (int numSamples ) |
void | setStencilBufferSize (int size ) |
void | setStereo (bool enable ) |
void | setSwapBehavior (QSurfaceFormat::SwapBehavior behavior ) |
void | setSwapInterval (int interval ) |
void | setVersion (int major , int minor ) |
int | stencilBufferSize () const |
bool | stereo () const |
QSurfaceFormat::SwapBehavior | swapBehavior () const |
int | swapInterval () const |
bool | testOption (QSurfaceFormat::FormatOption option ) const |
QPair<int, int> | version () const |
QSurfaceFormat | defaultFormat () |
void | setDefaultFormat (const QSurfaceFormat & format ) |
bool | operator!= (const QSurfaceFormat & lhs , const QSurfaceFormat & rhs ) |
bool | operator== (const QSurfaceFormat & lhs , const QSurfaceFormat & rhs ) |
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.
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
|
0
|
默认,未指定色彩空间。 |
QSurfaceFormat::sRGBColorSpace
|
1
|
当
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.
|
此枚举包含的格式选项用于 QSurfaceFormat .
常量 | 值 | 描述 |
---|---|---|
QSurfaceFormat::StereoBuffers
|
0x0001
|
用于请求表面格式的立体缓冲。 |
QSurfaceFormat::DebugContext
|
0x0002
|
Used to request a debug context with extra debugging information. |
QSurfaceFormat::DeprecatedFunctions
|
0x0004
|
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
|
0x0008
|
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. Platforms that support dynamically enabling the monitoring of the loss of context, such as, Windows with WGL, or Linux/X11 (xcb) with GLX, will monitor the status in every call to makeCurrent() 。见 isValid() 了解有关这的更多信息。 |
QSurfaceFormat::ProtectedContent
|
0x0010
|
Enables access to protected content. This allows the GPU to operate on protected resources (surfaces, buffers, textures), for example DRM-protected video content. Currently only implemented for EGL. |
FormatOptions 类型是 typedef 对于 QFlags <FormatOption>。它存储 FormatOption 值的 OR 组合。
This enum is used to specify the OpenGL context profile, in conjunction with QSurfaceFormat::setMajorVersion () 和 QSurfaceFormat::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 QSurfaceFormat::DeprecatedFunctions .
常量 | 值 | 描述 |
---|---|---|
QSurfaceFormat::NoProfile
|
0
|
OpenGL version is lower than 3.2. For 3.2 and newer this is same as CoreProfile. |
QSurfaceFormat::CoreProfile
|
1
|
Functionality deprecated in OpenGL version 3.0 is not available. |
QSurfaceFormat::CompatibilityProfile
|
2
|
Functionality from earlier OpenGL versions is available. |
此枚举指定表面的渲染后端。
常量 | 值 | 描述 |
---|---|---|
QSurfaceFormat::DefaultRenderableType
|
0x0
|
默认,未指定渲染方法 |
QSurfaceFormat::OpenGL
|
0x1
|
桌面 OpenGL 渲染 |
QSurfaceFormat::OpenGLES
|
0x2
|
OpenGL ES 2.0 渲染 |
QSurfaceFormat::OpenVG
|
0x4
|
开放向量图形渲染 |
此枚举用于 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
|
0
|
默认,平台未指定交换行为。 |
QSurfaceFormat::SingleBuffer
|
1
|
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
|
2
|
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
|
3
|
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. |
构造副本为 other .
Constructs a QSurfaceFormat with the given format options .
构造默认初始化 QSurfaceFormat。
注意: By default OpenGL 2.0 is requested since this provides the highest grade of portability between platforms and OpenGL implementations.
赋值 other 到此对象。
销毁 QSurfaceFormat .
Get the size in bits of the alpha channel of the color buffer.
另请参阅 setAlphaBufferSize ().
Get the size in bits of the blue channel of the color buffer.
另请参阅 setBlueBufferSize ().
[since 5.10]
const
QColorSpace
&QSurfaceFormat::
colorSpace
() const
返回色彩空间。
该函数在 Qt 5.10 引入。
另请参阅 setColorSpace ().
[static, since 5.4]
QSurfaceFormat
QSurfaceFormat::
defaultFormat
()
返回全局默认表面格式。
当 setDefaultFormat () 未被调用,这是默认构造的 QSurfaceFormat .
该函数在 Qt 5.4 引入。
另请参阅 setDefaultFormat ().
返回深度缓冲大小。
另请参阅 setDepthBufferSize ().
Get the size in bits of the green channel of the color buffer.
另请参阅 setGreenBufferSize ().
返回
true
if the alpha buffer size is greater than zero.
This means that the surface might be used with per pixel translucency effects.
Returns the major OpenGL version.
默认版本为 2.0。
另请参阅 setMajorVersion ().
Returns the minor OpenGL version.
另请参阅 setMinorVersion ().
[since 5.3]
QSurfaceFormat::FormatOptions
QSurfaceFormat::
options
() const
返回目前设置的格式选项。
该函数在 Qt 5.3 引入。
另请参阅 setOption (), setOptions (),和 testOption ().
Get the configured OpenGL context profile.
This setting is ignored if the requested OpenGL version is less than 3.2.
另请参阅 setProfile ().
Get the size in bits of the red channel of the color buffer.
另请参阅 setRedBufferSize ().
获取可渲染类型。
Chooses between desktop OpenGL, OpenGL ES, and OpenVG .
另请参阅 setRenderableType ().
Returns the number of samples per pixel when multisampling is enabled, or
-1
when multisampling is disabled. The default return value is
-1
.
另请参阅 setSamples ().
设置期望 size in bits of the alpha channel of the color buffer.
另请参阅 alphaBufferSize ().
设置期望 size in bits of the blue channel of the color buffer.
另请参阅 blueBufferSize ().
[since 6.0]
void
QSurfaceFormat::
setColorSpace
(const
QColorSpace
&
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.
该函数在 Qt 6.0 引入。
另请参阅 colorSpace ().
[since 5.10]
void
QSurfaceFormat::
setColorSpace
(
QSurfaceFormat::ColorSpace
colorSpace
)
这是重载函数。
Sets the colorspace to one of the predefined values.
该函数在 Qt 5.10 引入。
另请参阅 colorSpace ().
[static, since 5.4]
void
QSurfaceFormat::
setDefaultFormat
(const
QSurfaceFormat
&
format
)
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 Qt::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.
该函数在 Qt 5.4 引入。
另请参阅 defaultFormat ().
Set the minimum depth buffer size to size .
另请参阅 depthBufferSize ().
设置期望 size in bits of the green channel of the color buffer.
另请参阅 greenBufferSize ().
设置期望 major OpenGL version.
另请参阅 majorVersion ().
设置期望 minor OpenGL version.
默认版本为 2.0。
另请参阅 minorVersion ().
[since 5.3]
void
QSurfaceFormat::
setOption
(
QSurfaceFormat::FormatOption
option
,
bool
on
= true)
Sets the format option option if on is true; otherwise, clears the option.
To verify that an option was respected, compare the actual format to the requested format after surface/context creation.
该函数在 Qt 5.3 引入。
另请参阅 setOptions (), options (),和 testOption ().
[since 5.3]
void
QSurfaceFormat::
setOptions
(
QSurfaceFormat::FormatOptions
options
)
Sets the format options to options .
To verify that an option was respected, compare the actual format to the requested format after surface/context creation.
该函数在 Qt 5.3 引入。
另请参阅 options () 和 testOption ().
Sets the desired OpenGL context profile .
This setting is ignored if the requested OpenGL version is less than 3.2.
另请参阅 profile ().
设置期望 size in bits of the red channel of the color buffer.
另请参阅 redBufferSize ().
设置期望可渲染 type .
Chooses between desktop OpenGL, OpenGL ES, and OpenVG .
另请参阅 renderableType ().
Set the preferred number of samples per pixel when multisampling is enabled to numSamples . By default, multisampling is disabled.
另请参阅 samples ().
将首选蜡纸缓冲大小设为 size 位。
另请参阅 stencilBufferSize ().
若 enable is true enables stereo buffering; otherwise disables stereo buffering.
默认情况下,立体缓冲是禁用的。
Stereo buffering provides extra color buffers to generate left-eye and right-eye images.
另请参阅 stereo ().
设置交换 behavior 为表面。
The swap behavior specifies whether single, double, or triple buffering is desired. The default, DefaultSwapBehavior , gives the default swap behavior of the platform.
另请参阅 swapBehavior ().
[since 5.3]
void
QSurfaceFormat::
setSwapInterval
(
int
interval
)
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.
默认间隔为 1。
Changing the swap interval may not be supported by the underlying platform. In this case, the request will be silently ignored.
该函数在 Qt 5.3 引入。
另请参阅 swapInterval ().
设置期望 major and minor OpenGL 版本。
默认版本为 2.0。
另请参阅 version ().
返回蜡纸缓冲大小 (以位为单位)。
另请参阅 setStencilBufferSize ().
返回
true
if stereo buffering is enabled; otherwise returns false. Stereo buffering is disabled by default.
另请参阅 setStereo ().
返回配置的交换行为。
另请参阅 setSwapBehavior ().
[since 5.3]
int
QSurfaceFormat::
swapInterval
() const
返回交换间隔。
该函数在 Qt 5.3 引入。
另请参阅 setSwapInterval ().
[since 5.3]
bool
QSurfaceFormat::
testOption
(
QSurfaceFormat::FormatOption
option
) const
返回 true 若格式选项 option 有设置;否则返回 false。
该函数在 Qt 5.3 引入。
另请参阅 options ().
Returns a QPair<int, int> representing the OpenGL version.
Useful for version checks, for example format.version() >= qMakePair(3, 2)
另请参阅 setVersion ().
返回
false
若所有选项对于两
QSurfaceFormat
对象
lhs
and
rhs
相等;否则返回
true
.
返回
true
若所有选项对于两
QSurfaceFormat
对象
lhs
and
rhs
相等。