![]() |
Unuk 1.0
|
00001 #ifndef _SPRITE_H_ 00002 #define _SPRITE_H_ 00003 #include <GL/glut.h> 00004 #include <string> 00005 #include "ImageLoader.h" 00006 00007 using namespace std; 00008 00009 class ImageLoader; 00010 00011 class Sprite { 00012 public: 00013 static void Enable2D(void); 00014 00015 static void Disable2D(void); 00016 00017 Sprite(string filename); 00018 virtual ~Sprite(void); 00019 00020 virtual void Render(void); 00021 virtual void Rotate(GLint degrees) { angle += degrees; } 00022 00023 // Mutators. 00024 GLint GetAngle(void) const { return angle; } 00025 void SetAngle(GLint angle) { this->angle = angle; } 00026 void SetX(GLdouble x) { this->x = x; } 00027 void SetY(GLdouble y) { this->y = y; } 00028 GLint GetHeight(void) const { return image->GetHeight() * scaleY; } 00029 GLint GetWidth(void) const { return image->GetWidth() * scaleX; } 00030 00031 void SetPivot(GLfloat pivotX, GLfloat pivotY); 00032 GLfloat GetPivotX(void) const { return pivotX; } 00033 GLfloat GetPivotY(void) const { return pivotY; } 00034 00035 GLdouble GetX(void) const { return x; } 00036 GLdouble GetY(void) const { return y; } 00037 00038 void SetPivot(const Sprite &obj); 00039 00040 00041 // ================================================================= 00042 // Set the scale of the object. A scale of (1.0,1.0) means the sprite 00043 // maintains its original size. Values larger than 1 scales the sprite 00044 // up while values less than 1 shrink it down. 00045 // ================================================================= 00046 void SetScale(GLfloat x, GLfloat y) { scaleX = x, scaleY = y; } 00047 00048 private: 00049 ImageLoader *image; 00050 GLuint textureID; 00051 GLint angle; 00052 GLdouble x; 00053 GLdouble y; 00054 GLfloat pivotX; 00055 GLfloat pivotY; 00056 GLfloat scaleX; 00057 GLfloat scaleY; 00058 00059 void InitScene(void); 00060 00061 bool IsExtensionSupported(const char *extension) const; 00062 }; 00063 00064 #endif