"L. Spiro Engine"
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Protected Member Functions | Protected Attributes | Static Protected Attributes

lsg::CSprite Class Reference

A standard 2D sprite class. More...

#include <LSGSprite.h>

List of all members.

Classes

struct  LSG_CELL

Public Types

typedef struct
lsg::CSprite::LSG_CELL
LPLSG_CELL
typedef struct
lsg::CSprite::LSG_CELL 
LPCLSG_CELL
typedef LSVOID(LSE_CALL * PfCellResizeCallback )(LSVOID *_pvParm)

Public Member Functions

LSE_INLINE const
CStandardTexture *LSE_CALL 
GetTexture () const
LSE_INLINE LSVOID LSE_CALL SetTexture (CSharedStdTexPtr _sstpTexture)
LSE_INLINE LSBOOL LSE_CALL SetTexture (const LSCHAR *_pcPath)
LSE_INLINE LSBOOL LSE_CALL SetTexture (const LSCHAR *_pcPath, const LSG_TEX_PARMS &_tpParms)
LSE_INLINE LSVOID LSE_CALL SetShader (const CSharedShaderPtr *_psspShader)
LSBOOL LSE_CALL DrawAtImm (const CVector2 &_vPos, LSREAL _fRot=LSM_ZERO, const CVector2 &_vScale=CVector2(LSM_ONE, LSM_ONE), LSREAL _fAlpha=LSM_ONE) const
LSBOOL LSE_CALL DrawAtImm (const CVector2 &_vPos, const CMatrix2x2 &_mRotScale, LSREAL _fAlpha=LSM_ONE) const
LSVOID LSE_CALL SetCellCenter (LSREAL _fX, LSREAL _fY)
LSVOID LSE_CALL SetCellCenterNorm (LSREAL _fX, LSREAL _fY)
LSVOID LSE_CALL SetCell (const CVector2 &_vUpperLeft, const CVector2 &_vSize, const CVector2 &_vCenter)
LSE_INLINE LSVOID LSE_CALL SetCell (const LSG_CELL &_cCell)
LSE_INLINE const CVector2 &LSE_CALL CellSize () const
LSE_INLINE const CVector2 &LSE_CALL CellScale () const
LSE_INLINE CVector2 LSE_CALL CellCenterNegated () const
LSVOID LSE_CALL SetCallbackFunction (PfCellResizeCallback _pcrcCallback, LSVOID *_pvParm)

Static Public Member Functions

static LSVOID LSE_CALL ShutDownSprites ()

Static Public Attributes

static CTextureManager m_tmTexMan

Static Protected Member Functions

static LSVOID LSE_CALL UpdateTrans (const CVector3 &_vPos, LSREAL _fRot, const CVector2 &_vScale, CMatrix4x4 &_mRet)
static CShader *LSE_CALL GetDefShader ()
static CVertexBuffer *LSE_CALL GetImmVertBuffer ()

Protected Attributes

CSharedStdTexPtr m_sstpTexture
CSharedShaderPtr m_sspShader
PfCellResizeCallback m_pcrcCellResizeCallback
LSVOID * m_pvCallbackParm
CVector3 m_vPos
CVector2 m_vScale
LSREAL m_fRot
LSREAL m_fAlpha
CVector2 m_vCellSize
CVector2 m_vInvTexSize
CVector2 m_vUvStart
CVector2 m_vUvEnd
CMatrix4x4 m_mLocalTrans

Static Protected Attributes

static CVertexBufferm_pvbImmVertBuf
static CSharedShaderPtr m_sspDefaultShader
static CShader::LSG_HANDLE m_hDefaultAlpha

Detailed Description

A standard 2D sprite class.

Class CSprite Description: A standard 2D sprite class. Sprites can be rendered in immediate mode but this is slower. Use CSprite::Begin() and CSprite::End() for high-performance rendering.


Member Typedef Documentation

A sprite cell.

typedef LSVOID(LSE_CALL * lsg::CSprite::PfCellResizeCallback)(LSVOID *_pvParm)

A callback function prototype called when the cell dimensions change.


Member Function Documentation

LSE_INLINE CVector2 LSE_CALL lsg::CSprite::CellCenterNegated ( ) const

Gets the negated center of the cell.

Returns:
Returns the negated center of the cell.
LSE_INLINE const CVector2 &LSE_CALL lsg::CSprite::CellScale ( ) const

Gets the scale of the cell.

Returns:
Returns the scale of the cell.
LSE_INLINE const CVector2 &LSE_CALL lsg::CSprite::CellSize ( ) const

Gets the size of the cell.

Returns:
Returns the size of the cell.
LSBOOL LSE_CALL lsg::CSprite::DrawAtImm ( const CVector2 &  _vPos,
LSREAL  _fRot = LSM_ZERO,
const CVector2 &  _vScale = CVector2(LSM_ONE, LSM_ONE),
LSREAL  _fAlpha = LSM_ONE 
) const

Renders the sprite in immediate mode. This is slower than rendering between blocks of CSprite::Begin() and CSprite::End().

Parameters:
_vPosThe position at which to render the sprite.
_fRotThe rotation with which to render the sprite.
_vScaleThe scale with which to render the sprite.
_fAlphaThe alpha with which to render the sprite.
Returns:
Returns true if the sprite was rendered.
LSBOOL LSE_CALL lsg::CSprite::DrawAtImm ( const CVector2 &  _vPos,
const CMatrix2x2 &  _mRotScale,
LSREAL  _fAlpha = LSM_ONE 
) const

Renders the sprite in immediate mode. This is slower than rendering between blocks of CSprite::Begin() and CSprite::End().

Parameters:
_vPosThe position at which to render the sprite.
_mRotScaleThe upper-left 2-by-2 matrix of a translation matrix that represents the scale and X/Y rotation.
_fAlphaThe alpha with which to render the sprite.
Returns:
Returns true if the sprite was rendered.
static CShader* LSE_CALL lsg::CSprite::GetDefShader ( ) [static, protected]

Gets the default shader for sprites, creating it if necessary.

Returns:
Returns the default shader for sprites.
static CVertexBuffer* LSE_CALL lsg::CSprite::GetImmVertBuffer ( ) [static, protected]

Gets a pointer to the immediate-mode vertex buffer, creating it if necessary.

Returns:
Returns a pointer to the immediate-mode vertex buffer.
LSE_INLINE const CStandardTexture *LSE_CALL lsg::CSprite::GetTexture ( ) const

Gets a read-only pointer to the texture used by this sprite.

Returns:
Returns a read-only pointer to the texture used by this sprite.
LSVOID LSE_CALL lsg::CSprite::SetCallbackFunction ( PfCellResizeCallback  _pcrcCallback,
LSVOID *  _pvParm 
)

Sets the callback called when the cell dimensions change.

Parameters:
_pcrcCallbackThe callback function.
_pvParmThe parameter passed to the callback function.
LSVOID LSE_CALL lsg::CSprite::SetCell ( const CVector2 &  _vUpperLeft,
const CVector2 &  _vSize,
const CVector2 &  _vCenter 
)

Sets the cell dimensions and center point.

Parameters:
_vUpperLeftCell upper-left pixel coordinates on the current texture.
_vSizeSize of the cell.
_vCenterCell center-point pixel coordinates on the current texture.
LSE_INLINE LSVOID LSE_CALL lsg::CSprite::SetCell ( const LSG_CELL _cCell)

Sets the cell dimensions and center point.

Parameters:
_cCellThe cell dimensions and center point.
LSVOID LSE_CALL lsg::CSprite::SetCellCenter ( LSREAL  _fX,
LSREAL  _fY 
)

Sets the center point of the current cell in pixels.

Parameters:
_fXThe X coordinate of the center-point pixel.
_fYThe Y coordinate of the center-point pixel.
LSVOID LSE_CALL lsg::CSprite::SetCellCenterNorm ( LSREAL  _fX,
LSREAL  _fY 
)

Sets the center point of the current cell as a fraction of the width and height of the current cell.

Parameters:
_fXThe X fraction of the center-point pixel.
_fYThe Y fraction of the center-point pixel.
LSE_INLINE LSVOID LSE_CALL lsg::CSprite::SetShader ( const CSharedShaderPtr _psspShader)

Sets the shader to be used by this sprite. Pass NULL to use the default shader.

Parameters:
_psspShaderThe shader to use for this sprite, or NULL.
LSE_INLINE LSBOOL LSE_CALL lsg::CSprite::SetTexture ( const LSCHAR *  _pcPath,
const LSG_TEX_PARMS _tpParms 
)

Sets the texture to be used by this sprite by file name.

Parameters:
_pcPathPath to the file to load.
_tpParmsTexture parameters.
Returns:
Returns true if the texture exists, is valid, and was fully loaded.
LSE_INLINE LSVOID LSE_CALL lsg::CSprite::SetTexture ( CSharedStdTexPtr  _sstpTexture)

Sets the texture to be used by this sprite.

Parameters:
_sstpTextureShared pointer to the texture to be used by this sprite.
LSE_INLINE LSBOOL LSE_CALL lsg::CSprite::SetTexture ( const LSCHAR *  _pcPath)

Sets the texture to be used by this sprite by file name.

Parameters:
_pcPathPath to the file to load.
Returns:
Returns true if the texture exists, is valid, and was fully loaded.
static LSVOID LSE_CALL lsg::CSprite::ShutDownSprites ( ) [static]

Shuts down the sprite engine.

static LSVOID LSE_CALL lsg::CSprite::UpdateTrans ( const CVector3 &  _vPos,
LSREAL  _fRot,
const CVector2 &  _vScale,
CMatrix4x4 &  _mRet 
) [static, protected]

Updates the given transform with the given inputs.

Parameters:
_vPosThe input position.
_fRotRotation round the Z axis, in radians.
_vScaleThe X and Y scales.
_mRetReturn matrix.

Member Data Documentation

LSREAL lsg::CSprite::m_fAlpha [protected]

The alpha.

LSREAL lsg::CSprite::m_fRot [protected]

The rotation in 2D.

The uniform for the alpha component of the default sprite shader.

CMatrix4x4 lsg::CSprite::m_mLocalTrans [protected]

The local transform.

Optional pointer to a function to be called when the cell has changed.

The vertex buffer for immediate mode.

LSVOID* lsg::CSprite::m_pvCallbackParm [protected]

Parameter to pass to the callback function.

The default sprite shader

The shader to use with this sprite, if any. If invalid, the default shader is used.

The texture to use with this sprite.

Texture manager for sprites.

CVector2 lsg::CSprite::m_vCellSize [protected]

The width and height of the sprite cell.

CVector2 lsg::CSprite::m_vInvTexSize [protected]

The inverse width and height of the current texture.

CVector3 lsg::CSprite::m_vPos [protected]

The position in 2D, with z being the depth.

CVector2 lsg::CSprite::m_vScale [protected]

The scale in 2D.

CVector2 lsg::CSprite::m_vUvEnd [protected]

UV lower-right corner.

CVector2 lsg::CSprite::m_vUvStart [protected]

UV upper-left corner.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator