# GraphicsStateGuardian

from pandac.PandaModules import GraphicsStateGuardian

Class : GraphicsStateGuardian
Description : 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:

GraphicsStateGuardian: GraphicsStateGuardianBase
GraphicsStateGuardianBase: TypedWritableReferenceCount
TypedWritableReferenceCount: TypedWritable ReferenceCount
TypedWritable: TypedObject
TypedObject: MemoryBase
MemoryBase:
ReferenceCount: MemoryBase

## Methods of GraphicsStateGuardian:

getAlphaScaleTextureStage
getAlphaScaleViaTexture
getClassType
getColorScaleViaLighting
getCoordinateSystem
getCopyTextureInverted
getEngine
getMax3dTextureDimension
getMaxClipPlanes
getMaxCubeMapDimension
getMaxLights
getMaxTextureDimension
getMaxTextureStages
getMaxVertexTransformIndices
getMaxVertexTransforms
getPipe
getPreparedObjects
getShaderModel
getSupports3dTexture
getSupportsBasicShaders
getSupportsCompressedTexture
getSupportsCompressedTextureFormat
getSupportsCubeMap
getSupportsDepthStencil
getSupportsDepthTexture
getSupportsGenerateMipmap
getSupportsRenderTexture
getSupportsShadowFilter
getSupportsTexNonPow2
getSupportsTextureCombine
getSupportsTextureDot3
getSupportsTextureSavedResult
getSupportsTwoSidedStencil
getThreadingModel
isActive
isValid
needsReset
releaseAll
releaseAllGeoms
releaseAllIndexBuffers
releaseAllTextures
releaseAllVertexBuffers
setActive
setCoordinateSystem
setShaderModel

## Methods of GraphicsStateGuardianBase:

getClassType
getDefaultGsg
getMaxVerticesPerArray
getMaxVerticesPerPrimitive
getSupportedGeomRendering
getSupportsMultisample
getSupportsOcclusionQuery
prefersTriangleStrips
setDefaultGsg

## Methods of TypedWritableReferenceCount:

getClassType

## Methods of TypedWritable:

getClassType

## Methods of TypedObject:

getClassType
getType
getTypeIndex
isExactType
isOfType

## Methods of ReferenceCount:

getClassType
getRefCount
ref
testRefCountIntegrity
testRefCountNonzero
unref

## Constants in GraphicsStateGuardian:

SM00 | (ShaderModel)
SM11 | (ShaderModel)
SM20 | (ShaderModel)
SM2X | (ShaderModel)
SM30 | (ShaderModel)
SM40 | (ShaderModel)

getAlphaScaleTextureStage static TextureStage *GraphicsStateGuardian::get_alpha_scale_texture_stage(void); Description: Returns the TextureStage that will be used to apply an alpha scale, if get_alpha_scale_via_texture() returns true.

getAlphaScaleViaTexture bool GraphicsStateGuardian::get_alpha_scale_via_texture(void) const; Description: 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. Description: This variant of get_alpha_scale_via_texture() answers the question of whether the GSG can implement an alpha scale via an additional Texture layer, considering the current TextureAttrib that will be in effect. This considers whether there is at least one additional texture slot available on the GSG.

getClassType static TypeHandle GraphicsStateGuardian::get_class_type(void); Undocumented function.

getColorScaleViaLighting bool GraphicsStateGuardian::get_color_scale_via_lighting(void) const; Description: 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 GraphicsStateGuardian::get_coordinate_system(void) const; Description: 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 GraphicsStateGuardian::get_copy_texture_inverted(void) const; Description: 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 using GraphicsOutput::make_texture_buffer().

getEngine GraphicsEngine *GraphicsStateGuardian::get_engine(void) const; Description: Returns the graphics engine that created this GSG.

getMax3dTextureDimension int GraphicsStateGuardian::get_max_3d_texture_dimension(void) const; Description: 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).

getMaxClipPlanes int GraphicsStateGuardian::get_max_clip_planes(void) const; Description: 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).

getMaxCubeMapDimension int GraphicsStateGuardian::get_max_cube_map_dimension(void) const; Description: 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 GraphicsStateGuardian::get_max_lights(void) const; Description: 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).

getMaxTextureDimension int GraphicsStateGuardian::get_max_texture_dimension(void) const; Description: 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).

getMaxTextureStages int GraphicsStateGuardian::get_max_texture_stages(void) const; Description: 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::set_priority() 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 GraphicsStateGuardian::get_max_vertex_transform_indices(void) const; Description: 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 GraphicsStateGuardian::get_max_vertex_transforms(void) const; Description: 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).

getPipe GraphicsPipe *GraphicsStateGuardian::get_pipe(void) const; Description: Returns the graphics pipe on which this GSG was created.

getPreparedObjects virtual PreparedGraphicsObjects *GraphicsStateGuardian::get_prepared_objects(void); Description: Returns the set of texture and geom objects that have been prepared with this GSG (and possibly other GSG's that share objects).

getShaderModel int GraphicsStateGuardian::get_shader_model(void) const; Description: Returns the ShaderModel

getSupports3dTexture bool GraphicsStateGuardian::get_supports_3d_texture(void) const; Description: Returns true if this GSG can render 3-d (volumetric) textures.

getSupportsBasicShaders bool GraphicsStateGuardian::get_supports_basic_shaders(void) const; Description: Returns true if this particular GSG supports arbfp1+arbvp1 or above.

getSupportsCompressedTexture bool GraphicsStateGuardian::get_supports_compressed_texture(void) const; Description: Returns true if this GSG can compress textures as it loads them into texture memory, and/or accept pre-compressed textures for storing.

getSupportsCompressedTextureFormat bool GraphicsStateGuardian::get_supports_compressed_texture_format(Texture::CompressionMode compression) const; Description: Returns true if this GSG can accept textures pre-compressed in the indicated format.

getSupportsCubeMap bool GraphicsStateGuardian::get_supports_cube_map(void) const; Description: Returns true if this GSG can render cube map textures.

getSupportsDepthStencil bool GraphicsStateGuardian::get_supports_depth_stencil(void) const; Description: 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 GraphicsStateGuardian::get_supports_depth_texture(void) const; Description: 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.

getSupportsGenerateMipmap bool GraphicsStateGuardian::get_supports_generate_mipmap(void) const; Description: 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).

getSupportsRenderTexture bool GraphicsStateGuardian::get_supports_render_texture(void) const; Description: Returns true if this particular GSG can render directly into a texture, or false if it must always copy-to-texture at the end of each frame to achieve this effect.

getSupportsShadowFilter bool GraphicsStateGuardian::get_supports_shadow_filter(void) const; Description: Returns true if this particular GSG supports the filter mode FT_shadow for depth textures.

getSupportsTexNonPow2 bool GraphicsStateGuardian::get_supports_tex_non_pow2(void) const; Description: Returns true if this GSG can handle non power of two sized textures.

getSupportsTextureCombine bool GraphicsStateGuardian::get_supports_texture_combine(void) const; Description: 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 GraphicsStateGuardian::get_supports_texture_dot3(void) const; Description: Returns true if this GSG can use the TextureStage::CM_dot3_rgb or CM_dot3_rgba combine modes.

getSupportsTextureSavedResult bool GraphicsStateGuardian::get_supports_texture_saved_result(void) const; Description: 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 GraphicsStateGuardian::get_supports_two_sided_stencil(void) const; Description: Returns true if this particular GSG supports two sided stencil.

getThreadingModel GraphicsThreadingModel const &GraphicsStateGuardian::get_threading_model(void) const; Description: Returns the threading model that was used to create this GSG.

isActive bool GraphicsStateGuardian::is_active(void) const; Description: Returns the active flag associated with the GraphicsStateGuardian.

isValid bool GraphicsStateGuardian::is_valid(void) const; Description: 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.

needsReset bool GraphicsStateGuardian::needs_reset(void) const; Description: Returns true if the gsg is marked as needing a reset.

releaseAll void GraphicsStateGuardian::release_all(void); Description: Releases all prepared objects.

releaseAllGeoms int GraphicsStateGuardian::release_all_geoms(void); Description: Frees the resources for all geoms associated with this GSG.

releaseAllIndexBuffers int GraphicsStateGuardian::release_all_index_buffers(void); Description: Frees the resources for all index buffers associated with this GSG.

releaseAllTextures int GraphicsStateGuardian::release_all_textures(void); Description: Frees the resources for all textures associated with this GSG.

releaseAllVertexBuffers int GraphicsStateGuardian::release_all_vertex_buffers(void); Description: Frees the resources for all vertex buffers associated with this GSG.

setActive void GraphicsStateGuardian::set_active(bool active); Description: Sets the active flag associated with the GraphicsStateGuardian. If the GraphicsStateGuardian 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.

setCoordinateSystem void GraphicsStateGuardian::set_coordinate_system(CoordinateSystem cs); Description: Changes the coordinate system in effect on this particular gsg. This is also called the "external" coordinate system, since it is the coordinate system used by the scene graph, external to to GSG. Normally, this will be the default coordinate system, but it might be set differently at runtime.

setShaderModel void GraphicsStateGuardian::set_shader_model(int shader_model); Description: Sets the ShaderModel. This will override the auto- detected shader model during GSG reset. Useful for testing lower-end shaders.

getClassType static TypeHandle GraphicsStateGuardianBase::get_class_type(void); Undocumented function.

getDefaultGsg static GraphicsStateGuardianBase *GraphicsStateGuardianBase::get_default_gsg(void); Description: Returns a pointer to the "default" GSG. This is typically the first GSG created in an application; in a single-window application, it will be the only GSG. This GSG is used to determine default optimization choices for loaded geometry. The return value may be NULL if a GSG has not been created.

getMaxVerticesPerArray virtual int GraphicsStateGuardianBase::get_max_vertices_per_array(void) const = 0; Undocumented function.

getMaxVerticesPerPrimitive virtual int GraphicsStateGuardianBase::get_max_vertices_per_primitive(void) const = 0; Undocumented function.

getSupportedGeomRendering virtual int GraphicsStateGuardianBase::get_supported_geom_rendering(void) const = 0; Undocumented function.

getSupportsMultisample virtual bool GraphicsStateGuardianBase::get_supports_multisample(void) const = 0; Undocumented function.

getSupportsOcclusionQuery virtual bool GraphicsStateGuardianBase::get_supports_occlusion_query(void) const = 0; Undocumented function.

prefersTriangleStrips virtual bool GraphicsStateGuardianBase::prefers_triangle_strips(void) const = 0; Undocumented function.

setDefaultGsg static void GraphicsStateGuardianBase::set_default_gsg(GraphicsStateGuardianBase *default_gsg); Description: Specifies a particular GSG to use as the "default" GSG. See get_default_gsg().

getClassType static TypeHandle TypedWritableReferenceCount::get_class_type(void); Undocumented function.

getClassType static TypeHandle TypedWritable::get_class_type(void); Undocumented function.

getClassType static TypeHandle TypedObject::get_class_type(void); Undocumented function.

getType virtual TypeHandle TypedObject::get_type(void) const = 0; Derived classes should override this function to return get_class_type().

getTypeIndex int TypedObject::get_type_index(void) const; Description: Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. This is equivalent to get_type().get_index().

isExactType bool TypedObject::is_exact_type(TypeHandle handle) const; Description: Returns true if the current object is the indicated type exactly.

isOfType bool TypedObject::is_of_type(TypeHandle handle) const; Description: Returns true if the current object is or derives from the indicated type.

getClassType static TypeHandle ReferenceCount::get_class_type(void); Undocumented function.

getRefCount int ReferenceCount::get_ref_count(void) const; Description: Returns the current reference count.

ref void ReferenceCount::ref(void) const; Description: Explicitly increments the reference count. User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

testRefCountIntegrity bool ReferenceCount::test_ref_count_integrity(void) const; Description: Does some easy checks to make sure that the reference count isn't completely bogus. Returns true if ok, false otherwise.

testRefCountNonzero bool ReferenceCount::test_ref_count_nonzero(void) const; Description: Does some easy checks to make sure that the reference count isn't zero, or completely bogus. Returns true if ok, false otherwise.

unref bool ReferenceCount::unref(void) const; Description: Explicitly decrements the reference count. Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic; plus, we don't have a virtual destructor anyway.) However, see the helper function unref_delete(). User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it. The return value is true if the new reference count is nonzero, false if it is zero.