"L. Spiro Engine"
|
A standard 2D sprite class. More...
#include <LSGSprite.h>
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 CVertexBuffer * | m_pvbImmVertBuf |
static CSharedShaderPtr | m_sspDefaultShader |
static CShader::LSG_HANDLE | m_hDefaultAlpha |
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.
typedef struct lsg::CSprite::LSG_CELL * lsg::CSprite::LPLSG_CELL |
A sprite cell.
typedef LSVOID(LSE_CALL * lsg::CSprite::PfCellResizeCallback)(LSVOID *_pvParm) |
A callback function prototype called when the cell dimensions change.
LSE_INLINE CVector2 LSE_CALL lsg::CSprite::CellCenterNegated | ( | ) | const |
Gets the negated center of the cell.
LSE_INLINE const CVector2 &LSE_CALL lsg::CSprite::CellScale | ( | ) | const |
Gets the scale of the cell.
LSE_INLINE const CVector2 &LSE_CALL lsg::CSprite::CellSize | ( | ) | const |
Gets 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().
_vPos | The position at which to render the sprite. |
_fRot | The rotation with which to render the sprite. |
_vScale | The scale with which to render the sprite. |
_fAlpha | The alpha with which to render the sprite. |
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().
_vPos | The position at which to render the sprite. |
_mRotScale | The upper-left 2-by-2 matrix of a translation matrix that represents the scale and X/Y rotation. |
_fAlpha | The alpha with which to render the sprite. |
static CShader* LSE_CALL lsg::CSprite::GetDefShader | ( | ) | [static, protected] |
Gets the default shader for sprites, creating it if necessary.
static CVertexBuffer* LSE_CALL lsg::CSprite::GetImmVertBuffer | ( | ) | [static, protected] |
Gets a pointer to the immediate-mode vertex buffer, creating it if necessary.
LSE_INLINE const CStandardTexture *LSE_CALL lsg::CSprite::GetTexture | ( | ) | const |
Gets 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.
_pcrcCallback | The callback function. |
_pvParm | The 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.
_vUpperLeft | Cell upper-left pixel coordinates on the current texture. |
_vSize | Size of the cell. |
_vCenter | Cell 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.
_cCell | The 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.
_fX | The X coordinate of the center-point pixel. |
_fY | The 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.
_fX | The X fraction of the center-point pixel. |
_fY | The 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.
_psspShader | The 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.
_pcPath | Path to the file to load. |
_tpParms | Texture parameters. |
LSE_INLINE LSVOID LSE_CALL lsg::CSprite::SetTexture | ( | CSharedStdTexPtr | _sstpTexture | ) |
Sets the texture to be used by this sprite.
_sstpTexture | Shared 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.
_pcPath | Path to the file to load. |
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.
_vPos | The input position. |
_fRot | Rotation round the Z axis, in radians. |
_vScale | The X and Y scales. |
_mRet | Return matrix. |
LSREAL lsg::CSprite::m_fAlpha [protected] |
The alpha.
LSREAL lsg::CSprite::m_fRot [protected] |
The rotation in 2D.
CShader::LSG_HANDLE lsg::CSprite::m_hDefaultAlpha [static, protected] |
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.
CVertexBuffer* lsg::CSprite::m_pvbImmVertBuf [static, protected] |
The vertex buffer for immediate mode.
LSVOID* lsg::CSprite::m_pvCallbackParm [protected] |
Parameter to pass to the callback function.
CSharedShaderPtr lsg::CSprite::m_sspDefaultShader [static, protected] |
The default sprite shader
CSharedShaderPtr lsg::CSprite::m_sspShader [mutable, protected] |
The shader to use with this sprite, if any. If invalid, the default shader is used.
CSharedStdTexPtr lsg::CSprite::m_sstpTexture [mutable, protected] |
The texture to use with this sprite.
CTextureManager lsg::CSprite::m_tmTexMan [static] |
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.