SpriteCache Class Reference

#include <spritecache.h>

Collaboration diagram for SpriteCache:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SpriteCache (Sprite &sprite)
void EnableRotationCache (std::vector< SpriteFrame > &frames, unsigned int cache_size)
void EnableFlippingCache (std::vector< SpriteFrame > &frames)
void EnableLastFrameCache ()
void DisableLastFrameCache ()
void InvalidLastFrame ()

Public Attributes

bool have_rotation_cache
unsigned int rotation_cache_size
bool have_flipping_cache
bool have_lastframe_cache
Surface last_frame
std::vector< SpriteFrameCacheframes

Private Attributes

Spritesprite

Detailed Description

Definition at line 50 of file spritecache.h.


Constructor & Destructor Documentation

SpriteCache::SpriteCache ( Sprite sprite  )  [explicit]

Definition at line 89 of file spritecache.cpp.

00089                                          :
00090   sprite(p_sprite)
00091 {
00092   have_rotation_cache = false;
00093   have_flipping_cache = false;
00094   have_lastframe_cache = false;
00095   rotation_cache_size = 0;
00096 }


Member Function Documentation

void SpriteCache::DisableLastFrameCache (  ) 

Definition at line 175 of file spritecache.cpp.

00175                                        {
00176   //The result of the last call to SDLgfx is kept in memory
00177   //to display it again if rotation / scale / alpha didn't changed
00178   assert(!have_rotation_cache);
00179   assert(!have_flipping_cache);
00180   have_lastframe_cache = false;
00181 }

void SpriteCache::EnableFlippingCache ( std::vector< SpriteFrame > &  frames  ) 

Definition at line 152 of file spritecache.cpp.

00152                                                                           {
00153   //For each frame, we pre-render the flipped frame
00154   assert(!have_flipping_cache);
00155   assert(!have_lastframe_cache);
00156 
00157   if (frames.empty())
00158     frames.resize( sprite_frames.size() );
00159   assert( frames.size() == sprite_frames.size() );
00160 
00161   have_flipping_cache = true;
00162 
00163   for ( unsigned int f = 0 ; f < frames.size() ; f++)
00164     frames[f].CreateFlippingCache(sprite_frames[f].surface);
00165 }

Here is the caller graph for this function:

void SpriteCache::EnableLastFrameCache (  ) 

Definition at line 167 of file spritecache.cpp.

00167                                       {
00168   //The result of the last call to SDLgfx is kept in memory
00169   //to display it again if rotation / scale / alpha didn't changed
00170   assert(!have_rotation_cache);
00171   assert(!have_flipping_cache);
00172   have_lastframe_cache = true;
00173 }

Here is the caller graph for this function:

void SpriteCache::EnableRotationCache ( std::vector< SpriteFrame > &  frames,
unsigned int  cache_size 
)

Definition at line 132 of file spritecache.cpp.

00132                                                                                                    {
00133   //For each frame, we pre-render 'cache_size' rotated surface
00134   //At runtime the prerender Surface with the nearest angle to what is asked is displayed
00135   assert(1 < cache_size and cache_size <= 360);
00136   assert(!have_lastframe_cache);
00137   assert(!have_flipping_cache); //Always compute rotation cache before flipping cache!
00138   assert(!have_rotation_cache);
00139   have_rotation_cache = true;
00140 
00141   if (frames.empty())
00142     frames.resize( sprite_frames.size() );
00143   assert( frames.size() == sprite_frames.size() );
00144   rotation_cache_size = cache_size;
00145 
00146   for ( unsigned int f = 0 ; f < frames.size() ; f++)
00147   {
00148     frames[f].CreateRotationCache(sprite_frames[f].surface, cache_size);
00149   }
00150 }

Here is the caller graph for this function:

void SpriteCache::InvalidLastFrame (  ) 

Definition at line 183 of file spritecache.cpp.

00183                                   {
00184   //Free lastframe_cache if the next frame to be displayed
00185   //is not the same as the last one.
00186   if(!have_lastframe_cache)
00187     return;
00188   last_frame.Free();
00189 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

std::vector<SpriteFrameCache> SpriteCache::frames

Definition at line 61 of file spritecache.h.

bool SpriteCache::have_flipping_cache

Definition at line 58 of file spritecache.h.

bool SpriteCache::have_lastframe_cache

Definition at line 59 of file spritecache.h.

bool SpriteCache::have_rotation_cache

Definition at line 56 of file spritecache.h.

Surface SpriteCache::last_frame

Definition at line 60 of file spritecache.h.

unsigned int SpriteCache::rotation_cache_size

Definition at line 57 of file spritecache.h.

Sprite& SpriteCache::sprite [private]

Definition at line 52 of file spritecache.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 14:18:27 2007 for Wormux by  doxygen 1.4.7