UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials

Unigine::WidgetSprite Class

Interface for widget sprite handling. See also UnigineScript analog.

To use this class, include the UnigineWidgetSprite.h file.

Unigine::WidgetSprite Class

Members


static Ptr< WidgetSprite > create (const WidgetPtr & widget)

WidgetSprite constructor.

Arguments

  • const WidgetPtr & widget - Widget smart pointer.

static Ptr< WidgetSprite > create (const Ptr< Gui > & gui, const char * name)

WidgetSprite constructor.

Arguments

  • const Ptr< Gui > & gui - Gui pointer.
  • const char * name - Path to the texture. This is an optional parameter.

virtual int addLayer () const =0

Adds an empty layer with default properties to the sprite.

Return value

Number of the added layer.

virtual void removeLayer (int layer) const =0

Removes a given layer from the sprite.

Arguments

  • int layer - Layer number in range from 1 to the total number of sprite layers.

virtual int getNumLayers () const =0

Returns the total number of layers in the sprite.

Return value

Number of layers.

virtual void setColor (const vec4 & color) const =0

Sets a color for the first (bottom) layer of the sprite. This layer always exists in the sprite.

Arguments

  • const vec4 & color - Modulation color.

virtual vec4 getColor () const =0

Returns the current color set for the first (bottom) layer of the sprite.

Return value

Modulation color.

virtual void setWrapRepeat (int repeat) const =0

Sets texture tiling for the first (bottom) layer of the sprite. This layer always exists in the sprite. The default is 0 (no tiling). To see tiling in effect, you need to transform sprite texture coordinates via setTexCoord().

Arguments

  • int repeat - 1 to enable texture tiling; 0 to disable it.

virtual int getWrapRepeat () const =0

Returns a value indicating if texture tiling is enabled for the first (bottom) layer of the sprite.

Return value

Returns 1 if texture tiling is enabled; 0 if disabled.

virtual void setBufferMask (int mask) const =0

Sets a channel mask for the whole sprite. If a mask for a channel exists, one can draw in this channel.

Arguments

  • int mask - Channel mask (one of the BUFFER_*).

virtual int getBufferMask () const =0

Returns the current channel mask for the whole sprite.

Return value

Current channel mask (one of the BUFFER_*).

virtual void setBlendFunc (int src, int dest) const =0

Sets blending coefficients for the first (bottom) layer of the sprite. This layer always exists in the sprite.

Arguments

  • int src - Blending mode for the source screen buffer color (one of the BLEND_*).
  • int dest - Blending mode for the destination widget color (one of the BLEND_*).

virtual int getBlendSrcFunc () const =0

Returns the blending mode of the source screen buffer colour set for the first (bottom) layer of the sprite.

Return value

Blending mode (one of the BLEND_*).

virtual int getBlendDestFunc () const =0

Returns the blending mode of the destination widget colour set for the first (bottom) layer of the sprite.

Return value

Blending mode (one of the BLEND_*).

virtual void setTexCoord (const vec4 & texcoord) const =0

Sets the coordinates of the texture for the first (bottom) layer of the sprite. This layer always exists in the sprite.

Arguments

  • const vec4 & texcoord - Texture coordinates. The first pair of coordinates (x and y) is for the upper left corner, the second pair (z and w) is for the lower right corner.

virtual vec4 getTexCoord () const =0

Returns the current coordinates of the texture set for the first (bottom) layer of the sprite.

Return value

Texture coordinates. The first pair of coordinates (x and y) is for the upper left corner, the second pair (z and w) is for the lower right corner.

virtual void setTransform (const mat4 & transform) const =0

Sets a transformation matrix for the first (bottom) layer of the sprite. This layer always exists in the sprite.

Arguments

  • const mat4 & transform - Transformation matrix.

virtual mat4 getTransform () const =0

Returns the current transformation matrix set for the first (bottom) layer of the sprite.

Return value

Transformation matrix.

virtual void setImage (const ImagePtr & image, int dynamic) const =0

Sets a loaded into memory image for the first (bottom) layer of the sprite. This layer always exists in the sprite. An additional flag can be set in case the sprite image is going to be updated often or even each frame (for optimized memory management).

Arguments

  • const ImagePtr & image - Pointer to the image.
  • int dynamic - Positive number if the image will be updated each frame; otherwise, 0.

virtual void getImage (const ImagePtr & image) const =0

Returns the loaded into memory image that is currently set for the first (bottom) layer of the sprite.

Arguments

  • const ImagePtr & image - Pointer to the image.

virtual void setTexture (const char * name) const =0

Sets a texture from a file for the first (bottom) layer of the sprite. This layer always exists in the sprite.

Arguments

  • const char * name - Path to the texture.

virtual const char * getTexture () const =0

Returns the texture from a file that is currently set for the first (bottom) layer of the sprite.

Return value

Path to the texture.

virtual void setRender (const TexturePtr & texture, int flipped) const =0

Sets a texture to be rendered for the first (bottom) layer of the sprite.

Arguments

  • const TexturePtr & texture - Pointer to the texture.
  • int flipped - Flipped flag.

virtual TexturePtr getRender () const =0

Returns the pointer to the texture that is currently set for the first (bottom) layer of the sprite.

Return value

Pointer to the texture.

virtual void setLayerEnabled (int layer, int enable) const =0

Sets a value indicating if the layer is enabled for rendering.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.
  • int enable - 1 to enable the layer; 0 to disable it.

virtual int isLayerEnabled (int layer) const =0

Returns a value indicating if the layer is enabled for rendering.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.

Return value

Returns 1 if the layer is enabled; 0 if disabled.

virtual int getLayerWidth (int layer) const =0

Returns the current width of the layer (regardless of layer transformation).

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.

Return value

Width of the layer in units.

virtual int getLayerHeight (int layer) const =0

Returns the current width of the layer (regardless of layer transformation).

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.

Return value

Width of the layer in units.

virtual void setLayerColor (int layer, const vec4 & color) const =0

Sets a color for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.
  • const vec4 & color - Modulation color.

virtual vec4 getLayerColor (int layer) const =0

Returns the current color set for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers..

Return value

Modulation color.

virtual void setLayerWrapRepeat (int layer, int repeat) const =0

Sets texture tiling for a given layer of the sprite. To see tiling in effect, you need to transform sprite texture coordinates via setLayerTexCoord().

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.
  • int repeat - Positive number to enable texture tiling; 0 to disable it.

virtual int getLayerWrapRepeat (int layer) const =0

Returns a value indicating if texture tiling is enabled for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.

Return value

Returns 1 if texture tiling is enabled; 0 if disabled.

virtual void setLayerBufferMask (int layer, int mask) const =0

Sets a channel mask for a given layer of the sprite. If a mask for a channel exists, one can draw in this channel.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.
  • int mask - Channel mask. The default is BUFFER_ALL.

virtual int getLayerBufferMask (int layer) const =0

Returns the current channel mask set for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.

Return value

Channel mask. The default is BUFFER_ALL.

virtual void setLayerBlendFunc (int layer, int src, int dest) const =0

Sets blending coefficients for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.
  • int src - Blending mode for the source color (one of the BLEND_*).
  • int dest - Blending mode for the destination color (one of the BLEND_*).

virtual int getLayerBlendSrcFunc (int layer) const =0

Returns the blending mode of the source screen buffer colour set for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.

Return value

Blending mode (one of the BLEND_*).

virtual int getLayerBlendDestFunc (int layer) const =0

Returns the blending mode of the destination widget colour set for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.

Return value

Blending mode (one of the BLEND_*).

virtual void setLayerTexCoord (int layer, const vec4 & texcoord) const =0

Sets the coordinates of the texture for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.
  • const vec4 & texcoord - Texture coordinates. The first pair of coordinates (x and y) is for the upper left corner, the second pair (z and w) is for the lower right corner.

virtual vec4 getLayerTexCoord (int layer) const =0

Returns the current coordinates of the texture set for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.

Return value

Texture coordinates. The first pair of coordinates (x and y) is for the upper left corner, the second pair (z and w) is for the lower right corner.

virtual void setLayerTransform (int layer, const mat4 & transform) const =0

Sets a transformation matrix for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.
  • const mat4 & transform - Transformation matrix.

virtual mat4 getLayerTransform (int layer) const =0

Returns the current transformation matrix set for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.

Return value

Transformation matrix.

virtual void setLayerImage (int layer, const ImagePtr & image, int dynamic) const =0

Sets an image for a given layer of the sprite. An additional flag can be set in case the sprite image is going to be updated often or even each frame (for optimized memory management).

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.
  • const ImagePtr & image - Image to set.
  • int dynamic - Positive number if the image will be updated each frame; otherwise, 0.

virtual void getLayerImage (int layer, const ImagePtr & image) const =0

Returns the current image set for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.
  • const ImagePtr & image - Current image.

virtual void setLayerTexture (int layer, const char * name) const =0

Sets a texture for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.
  • const char * name - Path to the texture.

virtual const char * getLayerTexture (int layer) const =0

Returns the current texture set for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.

Return value

Path to the texture.

virtual void setLayerRender (int layer, const TexturePtr & texture, int flipped) const =0

Sets a texture for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.
  • const TexturePtr & texture - Pointer to the texture.
  • int flipped - Flipped flag.

virtual TexturePtr getLayerRender (int layer) const =0

Returns the current texture set for a given layer of the sprite.

Arguments

  • int layer - Layer number in range from 0 to the total number of sprite layers.

Return value

Pointer to the texture.
Last update: 2017-07-03