1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#ifndef SEAR_RENDER_SPRITE_H
#define SEAR_RENDER_SPRITE_H
#include <varconf/Config.h>
#include <sage/sage.h>
#include <sage/GL.h>
namespace Sear
{
class Render;
class SpriteData;
class Sprite
{
public:
Sprite() : m_data(NULL) { ; }
Sprite(const std::string& name);
~Sprite();
Sprite(const Sprite& other);
Sprite& operator=(const Sprite& other);
void draw(Render* r);
private:
SpriteData* m_data;
};
/** the sprite implementation class. If multiple renderer are ever
supported, this should become an abstract base, with derived versions
of GLSpriteData, DX9SpriteData and so on.
SpriteDatas are ref-counted.
*/
class SpriteData
{
public:
SpriteData(const std::string& name);
~SpriteData();
void draw(Render* render);
void invalidate();
private:
friend class Sprite;
static varconf::Config& getSpriteConfig();
void load();
/** helper method invoked when the load fails for some reason */
void loadFail();
unsigned int twoN(unsigned int size);
void addRef()
{ ++m_refCount; }
void decRef();
std::string m_name;
unsigned int m_refCount;
bool m_valid;
int m_width, m_height;
GLuint m_textureId;
float m_pw, m_ph;
};
} // of namespace Sear
#endif // of #ifndef SEAR_RENDER_SPRITE_H
|