CUGL 2.1
Cornell University Game Library
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cugl::scene2::NinePatch Class Reference

#include <CUNinePatch.h>

Inheritance diagram for cugl::scene2::NinePatch:
cugl::scene2::SceneNode

Public Member Functions

 NinePatch ()
 
 ~NinePatch ()
 
virtual void dispose () override
 
virtual bool init () override
 
bool initWithFile (const std::string &filename)
 
bool initWithFile (const std::string &filename, const Rect interior)
 
bool initWithTexture (const std::shared_ptr< Texture > &texture)
 
bool initWithTexture (const std::shared_ptr< Texture > &texture, const Rect interior)
 
virtual bool initWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data) override
 
virtual void setContentSize (const Size size) override
 
void setTexture (const std::string &filename)
 
void setTexture (const std::shared_ptr< Texture > &texture)
 
std::shared_ptr< Texture > & getTexture ()
 
const std::shared_ptr< Texture > & getTexture () const
 
void setInterior (const Rect interior)
 
const Rect getInterior () const
 
void setBlendFunc (GLenum srcFactor, GLenum dstFactor)
 
GLenum getSourceBlendFactor () const
 
GLenum getDestinationBlendFactor () const
 
void setBlendEquation (GLenum equation)
 
GLenum getBlendEquation () const
 
virtual void draw (const std::shared_ptr< SpriteBatch > &batch, const Affine2 &transform, Color4 tint) override
 
void refresh ()
 
virtual std::string toString (bool verbose=false) const override
 
- Public Member Functions inherited from cugl::scene2::SceneNode
 SceneNode ()
 
 ~SceneNode ()
 
virtual bool initWithPosition (const Vec2 pos)
 
bool initWithPosition (float x, float y)
 
virtual bool initWithBounds (const Size size)
 
virtual bool initWithBounds (float width, float height)
 
virtual bool initWithBounds (const Rect rect)
 
virtual bool initWithBounds (float x, float y, float width, float height)
 
virtual std::shared_ptr< SceneNodecopy (const std::shared_ptr< SceneNode > &dst) const
 
unsigned int getTag () const
 
void setTag (unsigned int tag)
 
const std::string getName () const
 
void setName (const std::string name)
 
const std::string getClassName () const
 
 operator std::string () const
 
const Vec2 getPosition () const
 
void setPosition (const Vec2 &position)
 
void setPosition (float x, float y)
 
float getPositionX (void) const
 
void setPositionX (float x)
 
float getPositionY (void) const
 
void setPositionY (float y)
 
Vec2 getWorldPosition () const
 
const Size getContentSize () const
 
virtual void setContentSize (float width, float height)
 
float getContentWidth () const
 
void setContentWidth (float width)
 
float getContentHeight () const
 
void setContentHeight (float height)
 
virtual Rect getLayoutBounds () const
 
Size getSize () const
 
float getWidth () const
 
float getHeight () const
 
Rect getBoundingBox () const
 
virtual void setAnchor (const Vec2 anchor)
 
virtual void setAnchor (float x, float y)
 
const Vec2 getAnchor () const
 
Vec2 getAnchorInPixels ()
 
Color4 getColor () const
 
virtual void setColor (Color4 color)
 
Color4 getAbsoluteColor ()
 
bool isVisible () const
 
void setVisible (bool visible)
 
bool hasRelativeColor () const
 
void setRelativeColor (bool flag)
 
std::shared_ptr< ScissorgetScissor () const
 
void setScissor (const std::shared_ptr< Scissor > &scissor)
 
void setScissor ()
 
const Vec2 getScale () const
 
float getScaleX () const
 
float getScaleY () const
 
void setScale (float scale)
 
void setScale (const Vec2 vec)
 
void setScale (float sx, float sy)
 
float getAngle ()
 
void setAngle (float angle)
 
const Affine2getTransform () const
 
const Affine2getAlternateTransform () const
 
void setAlternateTransform (const Affine2 &transform)
 
bool withAlternateTransform ()
 
void chooseAlternateTransform (bool active)
 
const Affine2getNodeToParentTransform () const
 
Affine2 getParentToNodeTransform () const
 
Affine2 getNodeToWorldTransform () const
 
Affine2 getWorldToNodeTransform () const
 
Vec2 screenToNodeCoords (const Vec2 screenPoint) const
 
Vec2 worldToNodeCoords (const Vec2 worldPoint) const
 
Vec2 nodeToScreenCoords (const Vec2 nodePoint) const
 
Vec2 nodeToWorldCoords (const Vec2 nodePoint) const
 
Vec2 parentToNodeCoords (const Vec2 parentPoint) const
 
Vec2 nodeToParentCoords (const Vec2 nodePoint) const
 
size_t getChildCount () const
 
std::shared_ptr< SceneNodegetChild (unsigned int pos)
 
const std::shared_ptr< SceneNode > & getChild (unsigned int pos) const
 
template<typename T >
std::shared_ptr< T > getChild (unsigned int pos) const
 
std::shared_ptr< SceneNodegetChildByTag (unsigned int tag) const
 
template<typename T >
std::shared_ptr< T > getChildByTag (unsigned int tag) const
 
std::shared_ptr< SceneNodegetChildByName (const std::string name) const
 
template<typename T >
std::shared_ptr< T > getChildByName (const std::string name) const
 
std::vector< std::shared_ptr< SceneNode > > getChildren ()
 
const std::vector< std::shared_ptr< SceneNode > > & getChildren () const
 
void addChild (const std::shared_ptr< SceneNode > &child)
 
void addChildWithTag (const std::shared_ptr< SceneNode > &child, unsigned int tag)
 
void addChildWithName (const std::shared_ptr< SceneNode > &child, const std::string name)
 
void swapChild (const std::shared_ptr< SceneNode > &child1, const std::shared_ptr< SceneNode > &child2, bool inherit=false)
 
SceneNodegetParent ()
 
const SceneNodegetParent () const
 
Scene2getScene ()
 
const Scene2getScene () const
 
void removeFromParent ()
 
virtual void removeChild (unsigned int pos)
 
void removeChild (const std::shared_ptr< SceneNode > &child)
 
void removeChildByTag (unsigned int tag)
 
void removeChildByName (const std::string name)
 
virtual void removeAllChildren ()
 
void setPriority (float priority)
 
float getPriority ()
 
virtual void render (const std::shared_ptr< SpriteBatch > &batch, const Affine2 &transform, Color4 tint)
 
virtual void render (const std::shared_ptr< SpriteBatch > &batch)
 
const std::shared_ptr< Layout > & getLayout () const
 
void setLayout (const std::shared_ptr< Layout > &layout)
 
virtual void doLayout ()
 

Static Public Member Functions

static std::shared_ptr< NinePatchalloc ()
 
static std::shared_ptr< NinePatchallocWithFile (const std::string &filename)
 
static std::shared_ptr< NinePatchallocWithFile (const std::string &filename, const Rect interior)
 
static std::shared_ptr< NinePatchallocWithTexture (const std::shared_ptr< Texture > &texture)
 
static std::shared_ptr< NinePatchallocWithTexture (const std::shared_ptr< Texture > &texture, const Rect interior)
 
static std::shared_ptr< SceneNodeallocWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data)
 
- Static Public Member Functions inherited from cugl::scene2::SceneNode
static std::shared_ptr< SceneNodealloc ()
 
static std::shared_ptr< SceneNodeallocWithPosition (const Vec2 pos)
 
static std::shared_ptr< SceneNodeallocWithPosition (float x, float y)
 
static std::shared_ptr< SceneNodeallocWithBounds (const Size size)
 
static std::shared_ptr< SceneNodeallocWithBounds (float width, float height)
 
static std::shared_ptr< SceneNodeallocWithBounds (const Rect rect)
 
static std::shared_ptr< SceneNodeallocWithBounds (float x, float y, float width, float height)
 
static std::shared_ptr< SceneNodeallocWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data)
 

Protected Member Functions

virtual void generateRenderData ()
 
void clearRenderData ()
 
Uint32 generatePatch (const Rect src, const Rect dst, Uint32 offset)
 
 CU_DISALLOW_COPY_AND_ASSIGN (NinePatch)
 

Protected Attributes

std::shared_ptr< Texture_texture
 
Rect _interior
 
bool _rendered
 
Mesh< SpriteVertex2_mesh
 
std::vector< Uint32 > _indices
 
GLenum _blendEquation
 
GLenum _srcFactor
 
GLenum _dstFactor
 
- Protected Attributes inherited from cugl::scene2::SceneNode
Vec2 _position
 
Vec2 _anchor
 
Size _contentSize
 
Color4 _tintColor
 
bool _hasParentColor
 
bool _isVisible
 
std::shared_ptr< Scissor_scissor
 
Vec2 _scale
 
float _angle
 
Affine2 _transform
 
bool _useTransform
 
Affine2 _combined
 
std::vector< std::shared_ptr< SceneNode > > _children
 
SceneNode_parent
 
Scene2_graph
 
std::shared_ptr< Layout_layout
 
int _childOffset
 
unsigned int _tag
 
std::string _name
 
size_t _hashOfName
 
std::string _classname
 
float _priority
 
std::shared_ptr< JsonValue_json
 

Detailed Description

Class to support a ninepatch image

Even though a ninepatch is composed of nine parts, we assume that the ninepatch is specified by a single texture (it would be far too inefficient to spread a ninepatch across multiple textures). Instead, the user specifies the interior of the texture with a rectangle, and the class interpolates the ninepatch from that. If no rectangle is specified, it assumes a degenerate ninepatch with a one-pixel middle.

The interior rectangle is specified in pixel coordinates. As with PolygonNode, we assume that the pixel origin is the bottom-left corner of the image.

Constructor & Destructor Documentation

◆ NinePatch()

cugl::scene2::NinePatch::NinePatch ( )

Creates a NinePatch with the degenerate texture.

You must initialize this NinePatch before use.

NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate an object on the heap, use one of the static constructors instead.

◆ ~NinePatch()

cugl::scene2::NinePatch::~NinePatch ( )
inline

Deletes this node, releasing all resources.

Member Function Documentation

◆ alloc()

static std::shared_ptr<NinePatch> cugl::scene2::NinePatch::alloc ( )
inlinestatic

Returns a simple NinePatch with the degenerate texture.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. However, the result will just be rectangle the same size as the blank texture, and so will not be very interesting.

Returns
a simple NinePatch with the degenerate texture.

◆ allocWithData()

static std::shared_ptr<SceneNode> cugl::scene2::NinePatch::allocWithData ( const Scene2Loader loader,
const std::shared_ptr< JsonValue > &  data 
)
inlinestatic

Returns a newly allocated node with the given JSON specificaton.

This initializer is designed to receive the "data" object from the JSON passed to Scene2Loader. This JSON format supports all of the attribute values of its parent class. In addition, it supports the following additional attributes:

 "texture":  The name of a previously loaded texture asset
 "interior": An four-element array of numbers (x,y,width,height)

All attributes are optional. However, it is generally a good idea to specify both to take full advantage of NinePatch features.

Parameters
loaderThe scene loader passing this JSON file
dataThe JSON object specifying the node
Returns
a newly allocated node with the given JSON specificaton.

◆ allocWithFile() [1/2]

static std::shared_ptr<NinePatch> cugl::scene2::NinePatch::allocWithFile ( const std::string &  filename)
inlinestatic

Returns a newly allocated NinePatch with the given interior from the image filename.

The interior rectangle is specified in pixel coordinates. As with PolygonNode, we assume that the pixel origin is the bottom-left corner of the image.

The interior rectangle fully defines the NinePatch. For example, suppose the rectangle has origin (2,3) and size (4,2). Then (1,1) is in the bottom left corner, while (3,1) is in the bottom middle, and so on.

Parameters
filenameA path to image file, e.g., "scene1/earthtile.png"
Returns
a newly allocated NinePatch with the given interior from the image filename.

◆ allocWithFile() [2/2]

static std::shared_ptr<NinePatch> cugl::scene2::NinePatch::allocWithFile ( const std::string &  filename,
const Rect  interior 
)
inlinestatic

Returns a newly allocated NinePatch with the given interior from the image filename.

The interior rectangle is specified in pixel coordinates. As with PolygonNode, we assume that the pixel origin is the bottom-left corner of the image.

The interior rectangle fully defines the NinePatch. Any pixel to the left and above the rectangle is in the top right corner, and so on.

Parameters
filenameA path to image file, e.g., "scene1/earthtile.png"
interiorThe rectangle (in pixel coordinates) defining the interior.
Returns
a newly allocated NinePatch with the given interior from the image filename.

◆ allocWithTexture() [1/2]

static std::shared_ptr<NinePatch> cugl::scene2::NinePatch::allocWithTexture ( const std::shared_ptr< Texture > &  texture)
inlinestatic

Returns a newly allocated degenerate NinePatch from a Texture object.

After creation, this will be a degenerate NinePatch. It will identify the center pixel of the image as the interior. All other pixels will either be a corner or side.

Parameters
textureA shared pointer to a Texture object.
Returns
a newly allocated degenerate NinePatch from a Texture object.

◆ allocWithTexture() [2/2]

static std::shared_ptr<NinePatch> cugl::scene2::NinePatch::allocWithTexture ( const std::shared_ptr< Texture > &  texture,
const Rect  interior 
)
inlinestatic

Returns a newly allocated NinePatch with the given interior from a Texture object.

The interior rectangle is specified in pixel coordinates. As with PolygonNode, we assume that the pixel origin is the bottom-left corner of the image.

The interior rectangle fully defines the NinePatch. For example, suppose the rectangle has origin (2,3) and size (4,2). Then (1,1) is in the bottom left corner, while (3,1) is in the bottom middle, and so on.

Parameters
textureA shared pointer to a Texture object.
interiorThe rectangle (in pixel coordinates) defining the interior.
Returns
a newly allocated NinePatch with the given interior from a Texture object.

◆ clearRenderData()

void cugl::scene2::NinePatch::clearRenderData ( )
protected

Clears the render data, releasing all vertices and indices.

◆ CU_DISALLOW_COPY_AND_ASSIGN()

cugl::scene2::NinePatch::CU_DISALLOW_COPY_AND_ASSIGN ( NinePatch  )
protected

This macro disables the copy constructor (not allowed on scene graphs)

◆ dispose()

virtual void cugl::scene2::NinePatch::dispose ( )
overridevirtual

Disposes all of the resources used by this node.

A disposed Node can be safely reinitialized. Any children owned by this node will be released. They will be deleted if no other object owns them.

It is unsafe to call this on a Node that is still currently inside of a scene graph.

Reimplemented from cugl::scene2::SceneNode.

◆ draw()

virtual void cugl::scene2::NinePatch::draw ( const std::shared_ptr< SpriteBatch > &  batch,
const Affine2 transform,
Color4  tint 
)
overridevirtual

Draws this Node via the given SpriteBatch.

This method only worries about drawing the current node. It does not attempt to render the children.

This is the method that you should override to implement your custom drawing code. You are welcome to use any OpenGL commands that you wish. You can even skip use of the SpriteBatch. However, if you do so, you must flush the SpriteBatch by calling end() at the start of the method. in addition, you should remember to call begin() at the start of the method.

This method provides the correct transformation matrix and tint color. You do not need to worry about whether the node uses relative color. This method is called by render() and these values are guaranteed to be correct. In addition, this method does not need to check for visibility, as it is guaranteed to only be called when the node is visible.

Parameters
batchThe SpriteBatch to draw with.
transformThe global transformation matrix.
tintThe tint to blend with the Node color.

Reimplemented from cugl::scene2::SceneNode.

◆ generatePatch()

Uint32 cugl::scene2::NinePatch::generatePatch ( const Rect  src,
const Rect  dst,
Uint32  offset 
)
protected

Generates the textured quad for one of the nine patches.

This function generates a quad for the rectangle dst, using the subtexture identified by src. If dst is larger than src, the image is stretched to fit. The vertices are added to _vertices and the indices are added to _indices.

Parameters
srcThe subtexture region to use
dstThe rectangle to texture and to add to _vertices
offsetThe first available vertex index
Returns
the next available vertex index

◆ generateRenderData()

virtual void cugl::scene2::NinePatch::generateRenderData ( )
protectedvirtual

Allocate the render data necessary to render this node.

◆ getBlendEquation()

GLenum cugl::scene2::NinePatch::getBlendEquation ( ) const
inline

Returns the blending equation for this textured node

By default this value is GL_FUNC_ADD. For other options, see

 https://www.opengl.org/sdk/docs/man/html/glBlendEquation.xhtml

This blending equation only affects the texture of the current node. It does not affect any children of the node.

Returns
the blending equation for this sprite batch

◆ getDestinationBlendFactor()

GLenum cugl::scene2::NinePatch::getDestinationBlendFactor ( ) const
inline

Returns the destination blending factor

By default this value is GL_ONE_MINUS_SRC_ALPHA. For other options, see

 https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml

This blending factor only affects the texture of the current node. It does not affect any children of the node.

Returns
the destination blending factor

◆ getInterior()

const Rect cugl::scene2::NinePatch::getInterior ( ) const
inline

Returns interior rectangle defining the NinePatch.

The interior rectangle is specified in pixel coordinates. As with PolygonNode, we assume that the pixel origin is the bottom-left corner of the image.

The interior rectangle fully defines the NinePatch. For example, suppose the rectangle has origin (2,3) and size (4,2). Then (1,1) is in the bottom left corner, while (3,1) is in the bottom middle, and so on.

Returns
interior rectangle defining the NinePatch.

◆ getSourceBlendFactor()

GLenum cugl::scene2::NinePatch::getSourceBlendFactor ( ) const
inline

Returns the source blending factor

By default this value is GL_SRC_ALPHA. For other options, see

 https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml

This blending factor only affects the texture of the current node. It does not affect any children of the node.

Returns
the source blending factor

◆ getTexture() [1/2]

std::shared_ptr<Texture>& cugl::scene2::NinePatch::getTexture ( )
inline

Returns the texture used by this node.

Returns
the texture used by this node

◆ getTexture() [2/2]

const std::shared_ptr<Texture>& cugl::scene2::NinePatch::getTexture ( ) const
inline

Returns the texture used by this node.

Returns
the texture used by this node

◆ init()

virtual bool cugl::scene2::NinePatch::init ( )
inlineoverridevirtual

Intializes a simple NinePatch with the degenerate texture.

You do not need to set the texture; rendering this into a SpriteBatch will simply use the blank texture. However, the result will just be rectangle the same size as the blank texture, and so will not be very interesting.

Returns
true if the sprite is initialized properly, false otherwise.

Reimplemented from cugl::scene2::SceneNode.

◆ initWithData()

virtual bool cugl::scene2::NinePatch::initWithData ( const Scene2Loader loader,
const std::shared_ptr< JsonValue > &  data 
)
overridevirtual

Initializes a node with the given JSON specificaton.

This initializer is designed to receive the "data" object from the JSON passed to Scene2Loader. This JSON format supports all of the attribute values of its parent class. In addition, it supports the following additional attributes:

 "texture":  The name of a previously loaded texture asset
 "interior": An four-element array of numbers (x,y,width,height)

All attributes are optional. However, it is generally a good idea to specify both to take full advantage of NinePatch features.

Parameters
loaderThe scene loader passing this JSON file
dataThe JSON object specifying the node
Returns
true if initialization was successful.

Reimplemented from cugl::scene2::SceneNode.

◆ initWithFile() [1/2]

bool cugl::scene2::NinePatch::initWithFile ( const std::string &  filename)

Intializes a degenerate NinePatch from the image filename.

After creation, this will be a degenerate NinePatch. It will identify the center pixel of the image as the interior. All other pixels will either be a corner or side.

Parameters
filenameA path to image file, e.g., "scene1/earthtile.png"
Returns
true if the node is initialized properly, false otherwise.

◆ initWithFile() [2/2]

bool cugl::scene2::NinePatch::initWithFile ( const std::string &  filename,
const Rect  interior 
)

Initializes a NinePatch with the given interior from the image filename.

The interior rectangle is specified in pixel coordinates. As with PolygonNode, we assume that the pixel origin is the bottom-left corner of the image.

The interior rectangle fully defines the NinePatch. For example, suppose the rectangle has origin (2,3) and size (4,2). Then (1,1) is in the bottom left corner, while (3,1) is in the bottom middle, and so on.

Parameters
filenameA path to image file, e.g., "scene1/earthtile.png"
interiorThe rectangle (in pixel coordinates) defining the interior.
Returns
true if the node is initialized properly, false otherwise.

◆ initWithTexture() [1/2]

bool cugl::scene2::NinePatch::initWithTexture ( const std::shared_ptr< Texture > &  texture)

Initializes a degenerate NinePatch from a Texture object.

After creation, this will be a degenerate NinePatch. It will identify the center pixel of the image as the interior. All other pixels will either be a corner or side.

  • Parameters
    textureA shared pointer to a Texture object.
    Returns
    true if the node is initialized properly, false otherwise.

◆ initWithTexture() [2/2]

bool cugl::scene2::NinePatch::initWithTexture ( const std::shared_ptr< Texture > &  texture,
const Rect  interior 
)

Initializes a NinePatch with the given interior from a Texture object.

The interior rectangle is specified in pixel coordinates. As with PolygonNode, we assume that the pixel origin is the bottom-left corner of the image.

The interior rectangle fully defines the NinePatch. For example, suppose the rectangle has origin (2,3) and size (4,2). Then (1,1) is in the bottom left corner, while (3,1) is in the bottom middle, and so on.

Parameters
textureA shared pointer to a Texture object.
interiorThe rectangle (in pixel coordinates) defining the interior.
Returns
true if the node is initialized properly, false otherwise.

◆ refresh()

void cugl::scene2::NinePatch::refresh ( )
inline

Refreshes this node to restore the render data.

◆ setBlendEquation()

void cugl::scene2::NinePatch::setBlendEquation ( GLenum  equation)
inline

Sets the blending equation for this textured node

The enum must be a standard ones supported by OpenGL. See

 https://www.opengl.org/sdk/docs/man/html/glBlendEquation.xhtml

However, this setter does not do any error checking to verify that the input is valid. By default, the equation is GL_FUNC_ADD.

This blending equation only affects the texture of the current node. It does not affect any children of the node.

Parameters
equationSpecifies how source and destination colors are combined

◆ setBlendFunc()

void cugl::scene2::NinePatch::setBlendFunc ( GLenum  srcFactor,
GLenum  dstFactor 
)
inline

Sets the blending function for this texture node.

The enums are the standard ones supported by OpenGL. See

 https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml

However, this setter does not do any error checking to verify that the enums are valid. By default, srcFactor is GL_SRC_ALPHA while dstFactor is GL_ONE_MINUS_SRC_ALPHA. This corresponds to non-premultiplied alpha blending.

This blending factor only affects the texture of the current node. It does not affect any children of the node.

Parameters
srcFactorSpecifies how the source blending factors are computed
dstFactorSpecifies how the destination blending factors are computed.

◆ setContentSize()

virtual void cugl::scene2::NinePatch::setContentSize ( const Size  size)
overridevirtual

Sets the untransformed size of the node.

The content size remains the same no matter how the node is scaled or rotated. All nodes must have a size, though it may be degenerate (0,0).

Changing the size of a rectangle will not change the position of the node. However, if the anchor is not the bottom-left corner, it will change the origin. The Node will grow out from an anchor on an edge, and equidistant from an anchor in the center.

Parameters
sizeThe untransformed size of the node.

Reimplemented from cugl::scene2::SceneNode.

◆ setInterior()

void cugl::scene2::NinePatch::setInterior ( const Rect  interior)

Sets interior rectangle defining the NinePatch.

The interior rectangle is specified in pixel coordinates. As with PolygonNode, we assume that the pixel origin is the bottom-left corner of the image.

The interior rectangle fully defines the NinePatch. For example, suppose the rectangle has origin (2,3) and size (4,2). Then (1,1) is in the bottom left corner, while (3,1) is in the bottom middle, and so on.

Parameters
interiorThe NinePatch interior

◆ setTexture() [1/2]

void cugl::scene2::NinePatch::setTexture ( const std::shared_ptr< Texture > &  texture)

Sets the node texture to the one specified.

This method will have no effect on the polygon vertices. This class decouples the geometry from the texture. That is because we do not expect the vertices to match the texture perfectly.

Parameters
textureA shared pointer to a Texture object.

◆ setTexture() [2/2]

void cugl::scene2::NinePatch::setTexture ( const std::string &  filename)
inline

Sets the node texture to a new one allocated from a filename.

This method will have no effect on the polygon vertices. This class decouples the geometry from the texture. That is because we do not expect the vertices to match the texture perfectly.

Parameters
filenameA path to image file, e.g., "scene1/earthtile.png"

◆ toString()

virtual std::string cugl::scene2::NinePatch::toString ( bool  verbose = false) const
overridevirtual

Returns a string representation of this node for debugging purposes.

If verbose is true, the string will include class information. This allows us to unambiguously identify the class.

Parameters
verboseWhether to include class information
Returns
a string representation of this node for debuggging purposes.

Reimplemented from cugl::scene2::SceneNode.

Member Data Documentation

◆ _blendEquation

GLenum cugl::scene2::NinePatch::_blendEquation
protected

The blending equation for this texture

◆ _dstFactor

GLenum cugl::scene2::NinePatch::_dstFactor
protected

The destination factor for the blend function

◆ _indices

std::vector<Uint32> cugl::scene2::NinePatch::_indices
protected

The render indices for this node

◆ _interior

Rect cugl::scene2::NinePatch::_interior
protected

The internal grid square in pixel space

◆ _mesh

Mesh<SpriteVertex2> cugl::scene2::NinePatch::_mesh
protected

The render vertices for this node

◆ _rendered

bool cugl::scene2::NinePatch::_rendered
protected

Whether we have generated render data for this node

◆ _srcFactor

GLenum cugl::scene2::NinePatch::_srcFactor
protected

The source factor for the blend function

◆ _texture

std::shared_ptr<Texture> cugl::scene2::NinePatch::_texture
protected

The NinePatch texture


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