00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _GL_TEXTURE_H_
00024 #define _GL_TEXTURE_H_
00025 #ifdef USING_OPENGL
00026
00027 #include <qgl.h>
00028 #include <qsize.h>
00029
00030 class ThumbItem;
00031
00032 class GLTexture
00033 {
00034 public:
00035 GLTexture() : tex(0), angle(0), item(NULL),
00036 width(512), height(512), cx(1.0f), cy(1.0f) {}
00037 ~GLTexture() { Deinit(); }
00038
00039 void Init(const QImage &image);
00040 void Deinit(void);
00041
00042 void Bind(void);
00043 void MakeQuad(float alpha = 1.0f, float scale = 1.0f);
00044 void SwapWidthHeight(void)
00045 { int tmp = width; width = height; height = tmp; }
00046
00047
00048 void SetItem(ThumbItem*, const QSize &sz);
00049 void SetSize(const QSize &sz)
00050 { width = sz.width(); height = sz.height(); }
00051 void SetScale(float x, float y)
00052 { cx = x; cy = y; }
00053 void ScaleTo(const QSize &dest, bool scaleMax);
00054 void SetAngle(int newangle) { angle = newangle; }
00055
00056
00057 QSize GetSize(void) const { return QSize(width, height); }
00058 uint GetPixelCount(void) const { return width * height; }
00059 float GetTextureX(void) const { return cx; }
00060 float GetTextureY(void) const { return cy; }
00061 int GetAngle(void) const { return angle; }
00062 QString GetDescription(const QString &status) const;
00063
00064 private:
00065 GLuint tex;
00066 int angle;
00067 ThumbItem *item;
00068 int width;
00069 int height;
00070 float cx;
00071 float cy;
00072 };
00073
00074 #endif // USING_OPENGL
00075 #endif // _GL_TEXTURE_H_