GraphicsStateGuardian¶
from panda3d.core import GraphicsStateGuardian
-
class
GraphicsStateGuardian
¶ Bases:
GraphicsStateGuardianBase
Encapsulates all the communication with a particular instance of a given rendering backend. Tries to guarantee that redundant state-change requests are not issued (hence “state guardian”).
There will be one of these objects for each different graphics context active in the system.
Inheritance diagram
-
enum
ShaderModel
¶ -
enumerator
SM_00
= 0¶
-
enumerator
SM_11
= 1¶
-
enumerator
SM_20
= 2¶
-
enumerator
SM_2X
= 3¶
-
enumerator
SM_30
= 4¶
-
enumerator
SM_40
= 5¶
-
enumerator
SM_50
= 6¶
-
enumerator
SM_51
= 7¶
-
enumerator
-
property
active
→ bool¶ - Getter
Returns the active flag associated with the
GraphicsStateGuardian
.- Setter
Sets the active flag associated with the
GraphicsStateGuardian
. If theGraphicsStateGuardian
is marked inactive, nothing is rendered. This is not normally turned off unless there is a problem with the rendering detected at a low level.
-
property
coordinate_system
→ CoordinateSystem¶ Returns the coordinate system in effect on this particular gsg. Normally, this will be the default coordinate system, but it might be set differently at runtime.
-
property
copy_texture_inverted
→ bool¶ Returns true if this particular GSG has the property that any framebuffer- to-texture copy results in a texture that is upside-down and backwards from Panda’s usual convention; that is, it copies into a texture from the bottom up instead of from the top down.
If this is true, then on offscreen
GraphicsBuffer
created for the purposes of rendering into a texture should be created with the invert flag set true, to compensate. Panda will do this automatically if you create an offscreen buffer usingGraphicsOutput.makeTextureBuffer()
.
-
property
driver_renderer
→ string¶
-
property
driver_vendor
→ string¶
-
property
driver_version
→ string¶
-
property
effective_incomplete_render
→ bool¶ Returns true if the GSG is effectively in incomplete_render state, considering both the GSG’s incomplete_render and its current DisplayRegion’s incomplete_render flags. It only makes sense to call this during the draw traversal; at other times this return value will be meaningless.
See
CullTraverser.getEffectiveIncompleteRender()
for this same information during the cull traversal.
-
static
getAlphaScaleTextureStage
() → TextureStage¶ Returns the
TextureStage
that will be used to apply an alpha scale, ifgetAlphaScaleViaTexture()
returns true.
-
getAlphaScaleViaTexture
() → bool¶ Returns true if this particular GSG can implement (or would prefer to implement) an alpha scale via an additional Texture layer, or false if we need to actually munge the alpha.
-
getAlphaScaleViaTexture
(tex_attrib: TextureAttrib) → bool This variant of
getAlphaScaleViaTexture()
answers the question of whether the GSG can implement an alpha scale via an additional Texture layer, considering the currentTextureAttrib
that will be in effect. This considers whether there is at least one additional texture slot available on the GSG.
-
static
getClassType
() → TypeHandle¶
-
getColorScaleViaLighting
() → bool¶ Returns true if this particular GSG can implement (or would prefer to implement) set color and/or color scale using materials and/or ambient lights, or false if we need to actually munge the color.
-
getCoordinateSystem
() → CoordinateSystem¶ Returns the coordinate system in effect on this particular gsg. Normally, this will be the default coordinate system, but it might be set differently at runtime.
-
getCopyTextureInverted
() → bool¶ Returns true if this particular GSG has the property that any framebuffer- to-texture copy results in a texture that is upside-down and backwards from Panda’s usual convention; that is, it copies into a texture from the bottom up instead of from the top down.
If this is true, then on offscreen
GraphicsBuffer
created for the purposes of rendering into a texture should be created with the invert flag set true, to compensate. Panda will do this automatically if you create an offscreen buffer usingGraphicsOutput.makeTextureBuffer()
.
-
getEngine
() → GraphicsEngine¶
-
getInternalCoordinateSystem
() → CoordinateSystem¶
-
getLoader
() → Loader¶ Returns the Loader object that will be used by this GSG to load textures when necessary, if
getIncompleteRender()
is true.
-
getMax2dTextureArrayLayers
() → int¶ Returns the largest possible number of pages, or -1 if there is no particular limit. Returns 0 if 2-d texture arrays not supported.
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
getMax3dTextureDimension
() → int¶ Returns the largest possible texture size in any one dimension for a 3-d texture, or -1 if there is no particular limit. Returns 0 if 3-d textures are not supported.
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
getMaxBufferTextureSize
() → int¶ Returns the largest possible buffer texture size, or -1 if there is no particular limit. Returns 0 if cube map textures are not supported.
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
getMaxClipPlanes
() → int¶ Returns the maximum number of simultaneous clip planes that may be applied to geometry, or -1 if there is no particular limit.
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
getMaxColorTargets
() → int¶ Returns the maximum number of simultaneous color textures that may be attached for render-to-texture, as supported by this particular GSG. If you exceed this number, the lowest-priority render targets will not be applied. Use RenderTarget::set_priority() to adjust the relative importance of the different render targets.
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
getMaxCubeMapDimension
() → int¶ Returns the largest possible texture size in any one dimension for a cube map texture, or -1 if there is no particular limit. Returns 0 if cube map textures are not supported.
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
getMaxLights
() → int¶ Returns the maximum number of simultaneous lights that may be rendered on geometry, or -1 if there is no particular limit.
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
getMaxTextureStages
() → int¶ Returns the maximum number of simultaneous textures that may be applied to geometry with multitexturing, as supported by this particular GSG. If you exceed this number, the lowest-priority texture stages will not be applied. Use
TextureStage.setPriority()
to adjust the relative importance of the different texture stages.The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
getMaxVertexTransformIndices
() → int¶ Returns the maximum number of transforms there may be in a single
TransformTable
for this graphics hardware. If this number is 0 (but get_max_transforms() is nonzero), then the graphics hardware (or API) doesn’t support indexed transforms, but can support direct transform references.The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
getMaxVertexTransforms
() → int¶ Returns the maximum number of transform matrices that may be simultaneously used to transform any one vertex by the graphics hardware. If this number is 0, then the hardware (or the graphics backend) doesn’t support soft- skinned vertices (in which case Panda will animate the vertices in software).
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
getMaximumSimultaneousRenderTargets
() → int¶ Deprecated. Use
getMaxColorTargets()
instead, which returns the exact same value.
-
getPipe
() → GraphicsPipe¶ Returns the graphics pipe on which this GSG was created.
-
getPreparedObjects
() → PreparedGraphicsObjects¶
-
getRuntimeColorScale
() → bool¶ Returns true if this particular GSG can implement (or would prefer to implement) set color and/or color scale directly, without requiring any munging of vertices or tricks with lighting.
-
getScene
() → SceneSetup¶
-
getShaderGenerator
() → ShaderGenerator¶ Returns the
ShaderGenerator
object that will be used by this GSG to generate shaders when necessary.
-
getShaderModel
() → ShaderModel¶ Returns the
GraphicsStateGuardianShaderModel
-
getSupportsBasicShaders
() → bool¶ Returns true if this particular GSG supports arbfp1+arbvp1 or above.
-
getSupportsCompressedTexture
() → bool¶ Returns true if this GSG can compress textures as it loads them into texture memory, and/or accept pre-compressed textures for storing.
-
getSupportsDepthStencil
() → bool¶ Returns true if this particular GSG supports textures whose format is F_depth_stencil. This only returns true if the GSG supports the full packed depth-stencil functionality.
-
getSupportsDepthTexture
() → bool¶ Returns true if this particular GSG supports textures whose format is F_depth_stencil. This returns true if the GSG supports GL_DEPTH_COMPONENT textures, which are considered a limited but still valid case of F_depth_stencil.
-
getSupportsDualSourceBlending
() → bool¶ Returns true if dual source (incoming1_color and incoming1_alpha) blend operands are supported by this GSG.
-
getSupportsGenerateMipmap
() → bool¶ Returns true if this particular GSG can generate mipmaps for a texture automatically, or if they must be generated in software. If this is true, then mipmaps can safely be enabled for rendered textures (e.g. using the
MultitexReducer
).
-
getSupportsGeometryInstancing
() → bool¶ Returns true if this particular GSG supports hardware geometry instancing: the ability to render multiple copies of a model. In OpenGL, this is done using the EXT_draw_instanced extension.
-
getSupportsIndirectDraw
() → bool¶ Returns true if this particular GSG supports draw calls for which the information comes from a buffer.
-
getSupportsLuminanceTexture
() → bool¶ Returns true if this particular GSG supports luminance textures.
-
getSupportsOcclusionQuery
() → bool¶ Returns true if this GSG supports an occlusion query. If this is true, then begin_occlusion_query() and end_occlusion_query() may be called to bracket a sequence of draw_triangles() (or whatever) calls to measure pixels that pass the depth test.
-
getSupportsSamplerObjects
() → bool¶ Returns true if this particular GSG supports the use of sampler objects to record texture sampling parameters separately from the texture objects. This doesn’t really affect functionality, but if this is false, it may mean that using the same texture with different
SamplerState
objects will result in reduced performance.
-
getSupportsTessellationShaders
() → bool¶ Returns true if this particular GSG supports tesselation shaders.
-
getSupportsTexNonPow2
() → bool¶ Returns true if this GSG can handle non power of two sized textures.
-
getSupportsTextureCombine
() → bool¶ Returns true if this particular GSG can use the TextureStage::M_combine mode, which includes all of the texture blend modes specified by set_combine_rgb() and/or set_combine_alpha(). If this is false, you must limit yourself to using the simpler blend modes.
-
getSupportsTextureDot3
() → bool¶ Returns true if this GSG can use the TextureStage::CM_dot3_rgb or CM_dot3_rgba combine modes.
-
getSupportsTextureSavedResult
() → bool¶ Returns true if this GSG can use the TextureStage::CS_last_saved_result source, which allows you to save the result of a
TextureStage
and re-use it for multiple inputs.
-
getSupportsTwoSidedStencil
() → bool¶ Returns true if this particular GSG supports two sided stencil: different stencil settings for the front and back side of the same polygon.
-
getTextureQualityOverride
() → QualityLevel¶ Returns the global quality_level override specified by
setTextureQualityOverride()
.This is mainly useful for the tinydisplay software renderer. See
Texture.setQualityLevel()
.
-
getThreadingModel
() → GraphicsThreadingModel¶ Returns the threading model that was used to create this GSG.
-
property
incomplete_render
→ bool¶ - Getter
Returns the incomplete_render flag. See
setIncompleteRender()
.- Setter
Sets the incomplete_render flag. When this is true, the frame will be rendered even if some of the geometry or textures in the scene are not available (e.g. they have been temporarily paged out). When this is false, the frame will be held up while this data is reloaded.
Setting this true allows for a smoother frame rate, but occasionally parts of the frame will be invisible or missing (they will generally come in within a second or two). Setting this false guarantees that every frame will be complete, but may cause more chugs as things are loaded up at runtime.
You may want to set this false during loading screens, to guarantee that all of your assets are available by the time you take the loading screen down.
This flag may also be set individually on each
DisplayRegion
. It will be considered true for a givenDisplayRegion
only if it is true on both the GSG and on theDisplayRegion
.
-
isActive
() → bool¶ Returns the active flag associated with the
GraphicsStateGuardian
.
-
isHardware
() → bool¶ Returns true if this GSG appears to be hardware-accelerated, or false if it is known to be software only.
-
isValid
() → bool¶ Returns true if the GSG has been correctly initialized within a graphics context, false if there has been some problem or it hasn’t been initialized yet.
-
property
loader
→ Loader¶ - Getter
Returns the Loader object that will be used by this GSG to load textures when necessary, if
getIncompleteRender()
is true.- Setter
Sets the Loader object that will be used by this GSG to load textures when necessary, if
getIncompleteRender()
is true.
-
property
max_2d_texture_array_layers
→ int¶ //z axis
//z axis
//z axis
- /**
Returns the largest possible number of pages, or -1 if there is no
particular limit. Returns 0 if 2-d texture arrays not supported.
The value returned may not be meaningful until after the graphics context
has been fully created (e.g. the window has been opened).
*/
-
property
max_3d_texture_dimension
→ int¶ Returns the largest possible texture size in any one dimension for a 3-d texture, or -1 if there is no particular limit. Returns 0 if 3-d textures are not supported.
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
property
max_buffer_texture_size
→ int¶ Returns the largest possible buffer texture size, or -1 if there is no particular limit. Returns 0 if cube map textures are not supported.
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
property
max_clip_planes
→ int¶ Returns the maximum number of simultaneous clip planes that may be applied to geometry, or -1 if there is no particular limit.
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
property
max_color_targets
→ int¶ Returns the maximum number of simultaneous color textures that may be attached for render-to-texture, as supported by this particular GSG. If you exceed this number, the lowest-priority render targets will not be applied. Use RenderTarget::set_priority() to adjust the relative importance of the different render targets.
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
property
max_cube_map_dimension
→ int¶ //z axis
//z axis
//z axis
- /**
Returns the largest possible texture size in any one dimension for a cube
map texture, or -1 if there is no particular limit. Returns 0 if cube map
textures are not supported.
The value returned may not be meaningful until after the graphics context
has been fully created (e.g. the window has been opened).
*/
-
property
max_lights
→ int¶ Returns the maximum number of simultaneous lights that may be rendered on geometry, or -1 if there is no particular limit.
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
property
max_texture_dimension
→ int¶ Returns the largest possible texture size in any one dimension supported by the GSG, or -1 if there is no particular limit.
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
property
max_texture_stages
→ int¶ Returns the maximum number of simultaneous textures that may be applied to geometry with multitexturing, as supported by this particular GSG. If you exceed this number, the lowest-priority texture stages will not be applied. Use
TextureStage.setPriority()
to adjust the relative importance of the different texture stages.The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
property
max_vertex_transform_indices
→ int¶ Returns the maximum number of transforms there may be in a single
TransformTable
for this graphics hardware. If this number is 0 (but get_max_transforms() is nonzero), then the graphics hardware (or API) doesn’t support indexed transforms, but can support direct transform references.The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
property
max_vertex_transforms
→ int¶ Returns the maximum number of transform matrices that may be simultaneously used to transform any one vertex by the graphics hardware. If this number is 0, then the hardware (or the graphics backend) doesn’t support soft- skinned vertices (in which case Panda will animate the vertices in software).
The value returned may not be meaningful until after the graphics context has been fully created (e.g. the window has been opened).
-
property
max_vertices_per_array
→ int¶ Returns the maximum number of vertices that should be put into any one
GeomVertexData
object for use with this GSG.
-
property
max_vertices_per_primitive
→ int¶ Returns the maximum number of vertex indices that should be put into any one
GeomPrimitive
object for use with this GSG.
-
property
pipe
→ GraphicsPipe¶ Returns the graphics pipe on which this GSG was created.
-
property
prepared_objects
→ PreparedGraphicsObjects¶
-
releaseAllShaderBuffers
() → int¶ Frees the resources for all index buffers associated with this GSG.
-
releaseAllVertexBuffers
() → int¶ Frees the resources for all vertex buffers associated with this GSG.
-
property
scene
→ SceneSetup¶
-
setActive
(active: bool) → None¶ Sets the active flag associated with the
GraphicsStateGuardian
. If theGraphicsStateGuardian
is marked inactive, nothing is rendered. This is not normally turned off unless there is a problem with the rendering detected at a low level.
-
setIncompleteRender
(incomplete_render: bool) → None¶ Sets the incomplete_render flag. When this is true, the frame will be rendered even if some of the geometry or textures in the scene are not available (e.g. they have been temporarily paged out). When this is false, the frame will be held up while this data is reloaded.
Setting this true allows for a smoother frame rate, but occasionally parts of the frame will be invisible or missing (they will generally come in within a second or two). Setting this false guarantees that every frame will be complete, but may cause more chugs as things are loaded up at runtime.
You may want to set this false during loading screens, to guarantee that all of your assets are available by the time you take the loading screen down.
This flag may also be set individually on each
DisplayRegion
. It will be considered true for a givenDisplayRegion
only if it is true on both the GSG and on theDisplayRegion
.
-
setLoader
(loader: Loader) → None¶ Sets the Loader object that will be used by this GSG to load textures when necessary, if
getIncompleteRender()
is true.
-
setScene
(scene_setup: SceneSetup) → bool¶
-
setShaderGenerator
(shader_generator: ShaderGenerator) → None¶ Sets the
ShaderGenerator
object that will be used by this GSG to generate shaders when necessary.
-
setShaderModel
(shader_model: ShaderModel) → None¶ Sets the
GraphicsStateGuardianShaderModel
. This will override the auto- detected shader model during GSG reset. Useful for testing lower-end shaders.
-
setTextureQualityOverride
(quality_level: QualityLevel) → None¶ Specifies the global quality_level to be imposed for all Textures rendered by this GSG. This overrides the value set on individual textures via
Texture.setQualityLevel()
. Set this to Texture::QL_default in order to allow the individual texture quality levels to be respected.This is mainly useful for the tinydisplay software renderer. See
Texture.setQualityLevel()
.
-
property
shader_generator
→ ShaderGenerator¶ - Getter
Returns the
ShaderGenerator
object that will be used by this GSG to generate shaders when necessary.- Setter
Sets the
ShaderGenerator
object that will be used by this GSG to generate shaders when necessary.
-
property
shader_model
→ ShaderModel¶ - Getter
Returns the
GraphicsStateGuardianShaderModel
- Setter
Sets the
GraphicsStateGuardianShaderModel
. This will override the auto- detected shader model during GSG reset. Useful for testing lower-end shaders.
-
property
supports_basic_shaders
→ bool¶ Returns true if this particular GSG supports arbfp1+arbvp1 or above.
-
property
supports_compressed_texture
→ bool¶ Returns true if this GSG can compress textures as it loads them into texture memory, and/or accept pre-compressed textures for storing.
-
property
supports_compute_shaders
→ bool¶ Returns true if this particular GSG supports compute shaders.
-
property
supports_depth_stencil
→ bool¶ Returns true if this particular GSG supports textures whose format is F_depth_stencil. This only returns true if the GSG supports the full packed depth-stencil functionality.
-
property
supports_depth_texture
→ bool¶ Returns true if this particular GSG supports textures whose format is F_depth_stencil. This returns true if the GSG supports GL_DEPTH_COMPONENT textures, which are considered a limited but still valid case of F_depth_stencil.
-
property
supports_dual_source_blending
→ bool¶ Returns true if dual source (incoming1_color and incoming1_alpha) blend operands are supported by this GSG.
-
property
supports_generate_mipmap
→ bool¶ Returns true if this particular GSG can generate mipmaps for a texture automatically, or if they must be generated in software. If this is true, then mipmaps can safely be enabled for rendered textures (e.g. using the
MultitexReducer
).
-
property
supports_geometry_instancing
→ bool¶ Returns true if this particular GSG supports hardware geometry instancing: the ability to render multiple copies of a model. In OpenGL, this is done using the EXT_draw_instanced extension.
-
property
supports_geometry_shaders
→ bool¶ Returns true if this particular GSG supports geometry shaders.
-
property
supports_indirect_draw
→ bool¶ Returns true if this particular GSG supports draw calls for which the information comes from a buffer.
-
property
supports_luminance_texture
→ bool¶ Returns true if this particular GSG supports luminance textures.
-
property
supports_occlusion_query
→ bool¶ Returns true if this GSG supports an occlusion query. If this is true, then begin_occlusion_query() and end_occlusion_query() may be called to bracket a sequence of draw_triangles() (or whatever) calls to measure pixels that pass the depth test.
-
property
supports_sampler_objects
→ bool¶ Returns true if this particular GSG supports the use of sampler objects to record texture sampling parameters separately from the texture objects. This doesn’t really affect functionality, but if this is false, it may mean that using the same texture with different
SamplerState
objects will result in reduced performance.
-
property
supports_shadow_filter
→ bool¶ Returns true if this particular GSG supports the filter mode FT_shadow for depth textures.
-
property
supports_stencil
→ bool¶ Returns true if this particular GSG supports stencil buffers at all.
-
property
supports_tessellation_shaders
→ bool¶ Returns true if this particular GSG supports tesselation shaders.
-
property
supports_tex_non_pow2
→ bool¶ Returns true if this GSG can handle non power of two sized textures.
-
property
supports_texture_combine
→ bool¶ Returns true if this particular GSG can use the TextureStage::M_combine mode, which includes all of the texture blend modes specified by set_combine_rgb() and/or set_combine_alpha(). If this is false, you must limit yourself to using the simpler blend modes.
-
property
supports_texture_dot3
→ bool¶ Returns true if this GSG can use the TextureStage::CM_dot3_rgb or CM_dot3_rgba combine modes.
-
property
supports_texture_saved_result
→ bool¶ Returns true if this GSG can use the TextureStage::CS_last_saved_result source, which allows you to save the result of a
TextureStage
and re-use it for multiple inputs.
-
property
supports_two_sided_stencil
→ bool¶ Returns true if this particular GSG supports two sided stencil: different stencil settings for the front and back side of the same polygon.
-
property
texture_quality_override
→ QualityLevel¶ - Getter
Returns the global quality_level override specified by
setTextureQualityOverride()
.This is mainly useful for the tinydisplay software renderer. See
Texture.setQualityLevel()
.- Setter
Specifies the global quality_level to be imposed for all Textures rendered by this GSG. This overrides the value set on individual textures via
Texture.setQualityLevel()
. Set this to Texture::QL_default in order to allow the individual texture quality levels to be respected.This is mainly useful for the tinydisplay software renderer. See
Texture.setQualityLevel()
.
-
enum