def
__eq__
(, arg__2)
def
__ne__
(, arg__2)
def
accum
()
def
accumBufferSize
()
def
alpha
()
def
alphaBufferSize
()
def
blueBufferSize
()
def
depth
()
def
depthBufferSize
()
def
directRendering
()
def
doubleBuffer
()
def
greenBufferSize
()
def
hasOverlay
()
def
majorVersion
()
def
minorVersion
()
def
plane
()
def
profile
()
def
redBufferSize
()
def
rgba
()
def
sampleBuffers
()
def
samples
()
def
setAccum
(enable)
def
setAccumBufferSize
(size)
def
setAlpha
(enable)
def
setAlphaBufferSize
(size)
def
setBlueBufferSize
(size)
def
setDepth
(enable)
def
setDepthBufferSize
(size)
def
setDirectRendering
(enable)
def
setDoubleBuffer
(enable)
def
setGreenBufferSize
(size)
def
setOption
(opt)
def
setOverlay
(enable)
def
setPlane
(plane)
def
setProfile
(profile)
def
setRedBufferSize
(size)
def
setRgba
(enable)
def
setSampleBuffers
(enable)
def
setSamples
(numSamples)
def
setStencil
(enable)
def
setStencilBufferSize
(size)
def
setStereo
(enable)
def
setSwapInterval
(interval)
def
setVersion
(major, minor)
def
stencil
()
def
stencilBufferSize
()
def
stereo
()
def
swapInterval
()
def
testOption
(opt)
def
defaultFormat
()
def
defaultOverlayFormat
()
def
fromSurfaceFormat
(format)
def
hasOpenGL
()
def
hasOpenGLOverlays
()
def
openGLVersionFlags
()
def
setDefaultFormat
(f)
def
setDefaultOverlayFormat
(f)
def
toSurfaceFormat
(format)
A display format has several characteristics:
You can also specify preferred bit depths for the color buffer, depth buffer, alpha buffer, accumulation buffer and the stencil buffer with the functions:
setRedBufferSize(),setGreenBufferSize(),setBlueBufferSize(),setDepthBufferSize(),setAlphaBufferSize(),setAccumBufferSize()andsetStencilBufferSize().Note that even if you specify that you prefer a 32 bit depth buffer (e.g. with
setDepthBufferSize(32)), the format that is chosen may not have a 32 bit depth buffer, even if there is a format available with a 32 bit depth buffer. The main reason for this is how the system dependant picking algorithms work on the different platforms, and some format options may have higher precedence than others.You create and tell a
QGLFormatobject what rendering options you want from an OpenGL rendering context.OpenGL drivers or accelerated hardware may or may not support advanced features such as alpha channel or stereographic viewing. If you request some features that the driver/hardware does not provide when you create a
QGLWidget, you will get a rendering context with the nearest subset of features.There are different ways to define the display characteristics of a rendering context. One is to create a
QGLFormatand make it the default for the entire application:fmt = QGLFormat() fmt.setAlpha(True) fmt.setStereo(True) QGLFormat.setDefaultFormat(fmt)Or you can specify the desired format when creating an object of your
QGLWidgetsubclass:fmt = QGLFormat() fmt.setDoubleBuffer(False) # single buffer fmt.setDirectRendering(False) # software rendering myWidget = MyGLWidget(fmt, ...)After the widget has been created, you can find out which of the requested features the system was able to provide:
fmt = QGLFormat() fmt.setOverlay(True) fmt.setStereo(True) myWidget = MyGLWidget(fmt, ...) if !myWidget.format().stereo(): # ok, goggles off if !myWidget.format().hasOverlay(): print "Cool hardware required"OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.另请参阅
QGLFormat
¶
QGLFormat(options[, plane=0])
QGLFormat(other)
- param plane
int- param other
- param options
FormatOptions
构造
QGLFormat
object with the following default settings:
Double
buffer:
Enabled.
Depth
buffer:
Enabled.
RGBA:
Enabled (i.e., color index disabled).
Alpha
channel:
Disabled.
Accumulator
buffer:
Disabled.
Stencil
buffer:
Enabled.
Stereo:
Disabled.
Direct
rendering:
Enabled.
Overlay:
Disabled.
Plane:
0 (i.e., normal plane).
Multisample
buffers:
Disabled.
创建
QGLFormat
object that is a copy of the current
defaultFormat()
.
若
options
is not 0, the default format is modified by the specified format options. The
options
parameter should be
FormatOption
values OR’ed together.
This constructor makes it easy to specify a certain desired format in classes derived from
QGLWidget
,例如:
# The rendering in MyGLWidget depends on using
# stencil buffer and alpha channel
class MyGLWidget(QGLWidget):
def __init__(self, parent):
QGLWidget.__init__(self, QGLFormat(QGL.StencilBuffer | QGL.AlphaChannel), parent)
if !format().stencil():
print "Could not get stencil buffer results will be suboptimal"
if !format().alpha():
print "Could not get alpha channel results will be suboptimal"
...
Note that there are
FormatOption
values to turn format settings both on and off, e.g.
DepthBuffer
and
NoDepthBuffer
,
DirectRendering
and
IndirectRendering
,等。
plane
parameter defaults to 0 and is the plane which this format should be associated with. Not all OpenGL implementations supports overlay/underlay rendering planes.
构造副本为
other
.
PySide2.QtOpenGL.QGLFormat.
OpenGLContextProfile
¶
This enum describes the OpenGL context profiles that can be specified for contexts implementing OpenGL version 3.2 or higher. These profiles are different from OpenGL ES profiles.
|
常量 |
描述 |
|---|---|
|
QGLFormat.NoProfile |
OpenGL version is lower than 3.2. |
|
QGLFormat.CoreProfile |
Functionality deprecated in OpenGL version 3.0 is not available. |
|
QGLFormat.CompatibilityProfile |
Functionality from earlier OpenGL versions is available. |
New in version 4.7.
PySide2.QtOpenGL.QGLFormat.
OpenGLVersionFlag
¶
This enum describes the various OpenGL versions that are recognized by Qt. Use the
openGLVersionFlags()
function to identify which versions that are supported at runtime.
|
常量 |
描述 |
|---|---|
|
QGLFormat.OpenGL_Version_None |
If no OpenGL is present or if no OpenGL context is current. |
|
QGLFormat.OpenGL_Version_1_1 |
OpenGL version 1.1 or higher is present. |
|
QGLFormat.OpenGL_Version_1_2 |
OpenGL version 1.2 or higher is present. |
|
QGLFormat.OpenGL_Version_1_3 |
OpenGL version 1.3 or higher is present. |
|
QGLFormat.OpenGL_Version_1_4 |
OpenGL version 1.4 or higher is present. |
|
QGLFormat.OpenGL_Version_1_5 |
OpenGL version 1.5 or higher is present. |
|
QGLFormat.OpenGL_Version_2_0 |
OpenGL version 2.0 or higher is present. Note that version 2.0 supports all the functionality of version 1.5. |
|
QGLFormat.OpenGL_Version_2_1 |
OpenGL version 2.1 or higher is present. |
|
QGLFormat.OpenGL_Version_3_0 |
OpenGL version 3.0 or higher is present. |
|
QGLFormat.OpenGL_Version_3_1 |
OpenGL version 3.1 or higher is present. Note that OpenGL version 3.1 or higher does not necessarily support all the features of version 3.0 and lower. |
|
QGLFormat.OpenGL_Version_3_2 |
OpenGL version 3.2 or higher is present. |
|
QGLFormat.OpenGL_Version_3_3 |
OpenGL version 3.3 or higher is present. |
|
QGLFormat.OpenGL_Version_4_0 |
OpenGL version 4.0 or higher is present. |
|
QGLFormat.OpenGL_Version_4_1 |
OpenGL version 4.1 or higher is present. |
|
QGLFormat.OpenGL_Version_4_2 |
OpenGL version 4.2 or higher is present. |
|
QGLFormat.OpenGL_Version_4_3 |
OpenGL version 4.3 or higher is present. |
|
QGLFormat.OpenGL_ES_CommonLite_Version_1_0 |
OpenGL ES version 1.0 Common Lite or higher is present. |
|
QGLFormat.OpenGL_ES_Common_Version_1_0 |
OpenGL ES version 1.0 Common or higher is present. The Common profile supports all the features of Common Lite. |
|
QGLFormat.OpenGL_ES_CommonLite_Version_1_1 |
OpenGL ES version 1.1 Common Lite or higher is present. |
|
QGLFormat.OpenGL_ES_Common_Version_1_1 |
OpenGL ES version 1.1 Common or higher is present. The Common profile supports all the features of Common Lite. |
|
QGLFormat.OpenGL_ES_Version_2_0 |
OpenGL ES version 2.0 or higher is present. Note that OpenGL ES version 2.0 does not support all the features of OpenGL ES 1.x. So if is returned, none of the ES 1.x flags are returned. |
另请参阅 http://www.opengl.org for more information about the different revisions of OpenGL.
另请参阅
PySide2.QtOpenGL.QGLFormat.
accum
(
)
¶
bool
返回
true
if the accumulation buffer is enabled; otherwise returns
false
. The accumulation buffer is disabled by default.
PySide2.QtOpenGL.QGLFormat.
accumBufferSize
(
)
¶
int
Returns the accumulation buffer size.
PySide2.QtOpenGL.QGLFormat.
alpha
(
)
¶
bool
返回
true
if the alpha buffer in the framebuffer is enabled; otherwise returns
false
. The alpha buffer is disabled by default.
PySide2.QtOpenGL.QGLFormat.
alphaBufferSize
(
)
¶
int
Returns the alpha buffer size.
PySide2.QtOpenGL.QGLFormat.
blueBufferSize
(
)
¶
int
Returns the blue buffer size.
另请参阅
PySide2.QtOpenGL.QGLFormat.
defaultFormat
(
)
¶
Returns the default
QGLFormat
for the application. All
QGLWidget
objects that are created use this format unless another format is specified, e.g. when they are constructed.
If no special default format has been set using
setDefaultFormat()
, the default format is the same as that created with
QGLFormat()
.
另请参阅
PySide2.QtOpenGL.QGLFormat.
defaultOverlayFormat
(
)
¶
Returns the default
QGLFormat
for overlay contexts.
The default overlay format is:
Double
buffer:
Disabled.
Depth
buffer:
Disabled.
RGBA:
Disabled (i.e., color index enabled).
Alpha
channel:
Disabled.
Accumulator
buffer:
Disabled.
Stencil
buffer:
Disabled.
Stereo:
Disabled.
Direct
rendering:
Enabled.
Overlay:
Disabled.
Multisample
buffers:
Disabled.
Plane:
1 (i.e., first overlay plane).
PySide2.QtOpenGL.QGLFormat.
depth
(
)
¶
bool
返回
true
if the depth buffer is enabled; otherwise returns false. The depth buffer is enabled by default.
PySide2.QtOpenGL.QGLFormat.
depthBufferSize
(
)
¶
int
Returns the depth buffer size.
PySide2.QtOpenGL.QGLFormat.
directRendering
(
)
¶
bool
返回
true
if direct rendering is enabled; otherwise returns false.
Direct rendering is enabled by default.
另请参阅
PySide2.QtOpenGL.QGLFormat.
doubleBuffer
(
)
¶
bool
返回
true
if double buffering is enabled; otherwise returns false. Double buffering is enabled by default.
另请参阅
PySide2.QtOpenGL.QGLFormat.
fromSurfaceFormat
(
format
)
¶
format
–
QSurfaceFormat
Returns an OpenGL format for the window format specified by
format
.
PySide2.QtOpenGL.QGLFormat.
greenBufferSize
(
)
¶
int
Returns the green buffer size.
另请参阅
PySide2.QtOpenGL.QGLFormat.
hasOpenGL
(
)
¶
bool
返回
true
if the window system has any OpenGL support; otherwise returns
false
.
警告
This function must not be called until the
QApplication
object has been created.
PySide2.QtOpenGL.QGLFormat.
hasOpenGLOverlays
(
)
¶
bool
返回
true
if the window system supports OpenGL overlays; otherwise returns
false
.
警告
This function must not be called until the
QApplication
object has been created.
PySide2.QtOpenGL.QGLFormat.
hasOverlay
(
)
¶
bool
返回
true
if overlay plane is enabled; otherwise returns
false
.
Overlay is disabled by default.
另请参阅
PySide2.QtOpenGL.QGLFormat.
majorVersion
(
)
¶
int
Returns the OpenGL major version.
PySide2.QtOpenGL.QGLFormat.
minorVersion
(
)
¶
int
Returns the OpenGL minor version.
PySide2.QtOpenGL.QGLFormat.
openGLVersionFlags
(
)
¶
OpenGLVersionFlags
Identifies, at runtime, which OpenGL versions that are supported by the current platform.
Note that if OpenGL version 1.5 is supported, its predecessors (i.e., version 1.4 and lower) are also supported. To identify the support of a particular feature, like multi texturing, test for the version in which the feature was first introduced (i.e., version 1.3 in the case of multi texturing) to adapt to the largest possible group of runtime platforms.
This function needs a valid current OpenGL context to work; otherwise it will return
OpenGL_Version_None
.
PySide2.QtOpenGL.QGLFormat.
plane
(
)
¶
int
Returns the plane of this format. The default for normal formats is 0, which means the normal plane. The default for overlay formats is 1, which is the first overlay plane.
PySide2.QtOpenGL.QGLFormat.
profile
(
)
¶
Returns the OpenGL context profile.
另请参阅
PySide2.QtOpenGL.QGLFormat.
redBufferSize
(
)
¶
int
Returns the red buffer size.
另请参阅
PySide2.QtOpenGL.QGLFormat.
rgba
(
)
¶
bool
返回
true
if RGBA color mode is set. Returns
false
if color index mode is set. The default color mode is RGBA.
另请参阅
PySide2.QtOpenGL.QGLFormat.
sampleBuffers
(
)
¶
bool
返回
true
if multisample buffer support is enabled; otherwise returns
false
.
The multisample buffer is disabled by default.
另请参阅
PySide2.QtOpenGL.QGLFormat.
samples
(
)
¶
int
Returns the number of samples per pixel when multisampling is enabled. By default, the highest number of samples that is available is used.
PySide2.QtOpenGL.QGLFormat.
setAccum
(
enable
)
¶
enable
–
bool
若
enable
is true enables the accumulation buffer; otherwise disables the accumulation buffer.
The accumulation buffer is disabled by default.
The accumulation buffer is used to create blur effects and multiple exposures.
PySide2.QtOpenGL.QGLFormat.
setAccumBufferSize
(
size
)
¶
size
–
int
Set the preferred accumulation buffer size, where
size
is the bit depth for each RGBA component.
PySide2.QtOpenGL.QGLFormat.
setAlpha
(
enable
)
¶
enable
–
bool
若
enable
is true enables the alpha buffer; otherwise disables the alpha buffer.
The alpha buffer is disabled by default.
The alpha buffer is typically used for implementing transparency or translucency. The A in RGBA specifies the transparency of a pixel.
PySide2.QtOpenGL.QGLFormat.
setAlphaBufferSize
(
size
)
¶
size
–
int
Set the preferred alpha buffer size to
size
. This function implicitly enables the alpha channel.
PySide2.QtOpenGL.QGLFormat.
setBlueBufferSize
(
size
)
¶
size
–
int
Set the preferred blue buffer size to
size
.
PySide2.QtOpenGL.QGLFormat.
setDefaultFormat
(
f
)
¶
f
–
QGLFormat
Sets a new default
QGLFormat
for the application to
f
. For example, to set single buffering as the default instead of double buffering, your main() might contain code like this:
a = QApplication([])
f = QGLFormat()
f.setDoubleBuffer(False)
QGLFormat.setDefaultFormat(f)
另请参阅
PySide2.QtOpenGL.QGLFormat.
setDefaultOverlayFormat
(
f
)
¶
f
–
QGLFormat
Sets a new default
QGLFormat
for overlay contexts to
f
. This format is used whenever a
QGLWidget
is created with a format that
hasOverlay()
enabled.
For example, to get a double buffered overlay context (if available), use code like this:
f = QGLFormat.defaultOverlayFormat()
f.setDoubleBuffer(True)
QGLFormat.setDefaultOverlayFormat(f)
As usual, you can find out after widget creation whether the underlying OpenGL system was able to provide the requested specification:
# ...continued from above
myWidget = MyGLWidget(QGLFormat(QGL.HasOverlay), ...)
if myWidget.format().hasOverlay():
# Yes, we got an overlay, let's check _its_ format:
olContext = myWidget.overlayContext()
if olContext.format().doubleBuffer():
# yes, we got a double buffered overlay
else:
# no, only single buffered overlays are available
PySide2.QtOpenGL.QGLFormat.
setDepth
(
enable
)
¶
enable
–
bool
若
enable
is true enables the depth buffer; otherwise disables the depth buffer.
The depth buffer is enabled by default.
The purpose of a depth buffer (or Z-buffering) is to remove hidden surfaces. Pixels are assigned Z values based on the distance to the viewer. A pixel with a high Z value is closer to the viewer than a pixel with a low Z value. This information is used to decide whether to draw a pixel or not.
PySide2.QtOpenGL.QGLFormat.
setDepthBufferSize
(
size
)
¶
size
–
int
Set the minimum depth buffer size to
size
.
PySide2.QtOpenGL.QGLFormat.
setDirectRendering
(
enable
)
¶
enable
–
bool
若
enable
is true enables direct rendering; otherwise disables direct rendering.
Direct rendering is enabled by default.
Enabling this option will make OpenGL bypass the underlying window system and render directly from hardware to the screen, if this is supported by the system.
另请参阅
PySide2.QtOpenGL.QGLFormat.
setDoubleBuffer
(
enable
)
¶
enable
–
bool
若
enable
is true sets double buffering; otherwise sets single buffering.
Double buffering is enabled by default.
Double buffering is a technique where graphics are rendered on an off-screen buffer and not directly to the screen. When the drawing has been completed, the program calls a swapBuffers() function to exchange the screen contents with the buffer. The result is flicker-free drawing and often better performance.
Note that single buffered contexts are currently not supported with EGL.
PySide2.QtOpenGL.QGLFormat.
setGreenBufferSize
(
size
)
¶
size
–
int
Set the preferred green buffer size to
size
.
PySide2.QtOpenGL.QGLFormat.
setOption
(
opt
)
¶
opt
–
FormatOptions
Sets the format option to
opt
.
另请参阅
PySide2.QtOpenGL.QGLFormat.
setOverlay
(
enable
)
¶
enable
–
bool
若
enable
is true enables an overlay plane; otherwise disables the overlay plane.
Enabling the overlay plane will cause
QGLWidget
to create an additional context in an overlay plane. See the
QGLWidget
documentation for further information.
另请参阅
PySide2.QtOpenGL.QGLFormat.
setPlane
(
plane
)
¶
plane
–
int
Sets the requested plane to
plane
. 0 is the normal plane, 1 is the first overlay plane, 2 is the second overlay plane, etc.; -1, -2, etc. are underlay planes.
Note that in contrast to other format specifications, the plane specifications will be matched exactly. This means that if you specify a plane that the underlying OpenGL system cannot provide, an
invalid
QGLWidget
will be created.
另请参阅
PySide2.QtOpenGL.QGLFormat.
setProfile
(
profile
)
¶
profile
–
OpenGLContextProfile
Set the OpenGL context profile to
profile
。
profile
is ignored if the requested OpenGL version is less than 3.2.
另请参阅
PySide2.QtOpenGL.QGLFormat.
setRedBufferSize
(
size
)
¶
size
–
int
Set the preferred red buffer size to
size
.
PySide2.QtOpenGL.QGLFormat.
setRgba
(
enable
)
¶
enable
–
bool
若
enable
is true sets RGBA mode. If
enable
is false sets color index mode.
The default color mode is RGBA.
RGBA is the preferred mode for most OpenGL applications. In RGBA color mode you specify colors as red + green + blue + alpha quadruplets.
In color index mode you specify an index into a color lookup table.
另请参阅
PySide2.QtOpenGL.QGLFormat.
setSampleBuffers
(
enable
)
¶
enable
–
bool
若
enable
is true, a GL context with multisample buffer support is picked; otherwise ignored.
PySide2.QtOpenGL.QGLFormat.
setSamples
(
numSamples
)
¶
numSamples
–
int
Set the preferred number of samples per pixel when multisampling is enabled to
numSamples
. By default, the highest number of samples available is used.
PySide2.QtOpenGL.QGLFormat.
setStencil
(
enable
)
¶
enable
–
bool
若
enable
is true enables the stencil buffer; otherwise disables the stencil buffer.
The stencil buffer is enabled by default.
The stencil buffer masks certain parts of the drawing area so that masked parts are not drawn on.
PySide2.QtOpenGL.QGLFormat.
setStencilBufferSize
(
size
)
¶
size
–
int
Set the preferred stencil buffer size to
size
.
PySide2.QtOpenGL.QGLFormat.
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.
另请参阅
PySide2.QtOpenGL.QGLFormat.
setSwapInterval
(
interval
)
¶
interval
–
int
Set the preferred swap interval. This can be used to sync the GL drawing into a system 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.
Under Windows and under X11, where the
WGL_EXT_swap_control
and
GLX_SGI_video_sync
extensions are used, the
interval
parameter can be used to set the minimum number of video frames that are displayed before a buffer swap will occur. In effect, setting the
interval
to 10, means there will be 10 vertical retraces between every buffer swap.
Under Windows the
WGL_EXT_swap_control
extension has to be present, and under X11 the
GLX_SGI_video_sync
extension has to be present.
另请参阅
PySide2.QtOpenGL.QGLFormat.
setVersion
(
major
,
minor
)
¶
major
–
int
minor
–
int
Set the OpenGL version to the
major
and
minor
numbers. If a context compatible with the requested OpenGL version cannot be created, a context compatible with version 1.x is created instead.
PySide2.QtOpenGL.QGLFormat.
stencil
(
)
¶
bool
返回
true
if the stencil buffer is enabled; otherwise returns false. The stencil buffer is enabled by default.
PySide2.QtOpenGL.QGLFormat.
stencilBufferSize
(
)
¶
int
Returns the stencil buffer size.
PySide2.QtOpenGL.QGLFormat.
stereo
(
)
¶
bool
返回
true
if stereo buffering is enabled; otherwise returns false. Stereo buffering is disabled by default.
另请参阅
PySide2.QtOpenGL.QGLFormat.
swapInterval
(
)
¶
int
Returns the currently set swap interval. -1 is returned if setting the swap interval isn’t supported in the system GL implementation.
另请参阅
PySide2.QtOpenGL.QGLFormat.
testOption
(
opt
)
¶
opt
–
FormatOptions
bool
返回
true
if format option
opt
已设置;否则返回
false
.
另请参阅