SFML

- Main Page
- Modules
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | Static Public Attributes | List of all members
sf::RenderStates Class Reference
Graphics module

Define the states used for drawing to a RenderTarget. More...

`#include <RenderStates.hpp>`

## Public Member Functions
| RenderStates ()
| Default constructor. More...
| RenderStates (BlendMode theBlendMode)
| Construct a default set of render states with a custom blend mode. More...
| RenderStates (const Transform &theTransform)
| Construct a default set of render states with a custom transform. More...
| RenderStates (const Texture *theTexture)
| Construct a default set of render states with a custom texture. More...
| RenderStates (const Shader *theShader)
| Construct a default set of render states with a custom shader. More...
| RenderStates (BlendMode theBlendMode, const Transform &theTransform, const Texture *theTexture, const Shader *theShader)
| Construct a set of render states with all its attributes. More...

## Public Attributes
BlendMode | blendMode
| Blending mode. More...
Transform | transform
| Transform. More...
const Texture * | texture
| Texture. More...
const Shader * | shader
| Shader. More...

## Static Public Attributes
static const RenderStates | Default
| Special instance holding the default render states. More...

## Detailed Description

Define the states used for drawing to a RenderTarget.

There are four global states that can be applied to the drawn objects:

- the blend mode: how pixels of the object are blended with the background
- the transform: how the object is positioned/rotated/scaled
- the texture: what image is mapped to the object
- the shader: what custom effect is applied to the object

High-level objects such as sprites or text force some of these states when they are drawn. For example, a sprite will set its own texture, so that you don't have to care about it when drawing the sprite.

The transform is a special case: sprites, texts and shapes (and it's a good idea to do it with your own drawable classes too) combine their transform with the one that is passed in the RenderStates structure. So that you can use a "global" transform on top of each object's transform.

Most objects, especially high-level drawables, can be drawn directly without defining render states explicitely – the default set of states is ok in most cases.

window.Draw(sprite);

If you want to use a single specific render state, for example a shader, you can pass it directly to the Draw function: sf::RenderStates has an implicit one-argument constructor for each state.

window.draw(sprite, shader);

When you're inside the Draw function of a drawable object (inherited from sf::Drawable), you can either pass the render states unmodified, or change some of them. For example, a transformable object will combine the current transform with its own transform. A sprite will set its texture. Etc.

See Also
  sf::RenderTarget, sf::Drawable

Definition at line 45 of file RenderStates.hpp.

## Constructor & Destructor Documentation

sf::RenderStates::RenderStates | ( | ) |  |

Default constructor.

Constructing a default set of render states is equivalent to using sf::RenderStates::Default. The default set defines:

- the BlendAlpha blend mode
- the identity transform
- a null texture
- a null shader

sf::RenderStates::RenderStates | ( | BlendMode | theBlendMode) |  |

Construct a default set of render states with a custom blend mode.

Parameters

  theBlendMode | Blend mode to use

sf::RenderStates::RenderStates | ( | const Transform & | theTransform) |  |

Construct a default set of render states with a custom transform.

Parameters

  theTransform | Transform to use

sf::RenderStates::RenderStates | ( | const Texture * | theTexture) |  |

Construct a default set of render states with a custom texture.

Parameters

  theTexture | Texture to use

sf::RenderStates::RenderStates | ( | const Shader * | theShader) |  |

Construct a default set of render states with a custom shader.

Parameters

  theShader | Shader to use

sf::RenderStates::RenderStates | ( | BlendMode | theBlendMode,
|  | const Transform & | theTransform,
|  | const Texture * | theTexture,
|  | const Shader * | theShader
| ) |  |

Construct a set of render states with all its attributes.

Parameters

  theBlendMode | Blend mode to use
  theTransform | Transform to use
  theTexture | Texture to use
  theShader | Shader to use

## Member Data Documentation

BlendMode sf::RenderStates::blendMode

Blending mode.

Definition at line 115 of file RenderStates.hpp.

const RenderStates sf::RenderStates::Default
| static

Special instance holding the default render states.

Definition at line 110 of file RenderStates.hpp.

const Shader* sf::RenderStates::shader

Shader.

Definition at line 118 of file RenderStates.hpp.

const Texture* sf::RenderStates::texture

Texture.

Definition at line 117 of file RenderStates.hpp.

Transform sf::RenderStates::transform

Transform.

Definition at line 116 of file RenderStates.hpp.

The documentation for this class was generated from the following file:

- RenderStates.hpp