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 <QtOpenGL>
00028 #include <QSize>
00029
00030
00031 #include "galleryutil.h"
00032
00033 class ThumbItem;
00034
00035 class GLTexture
00036 {
00037 public:
00038 GLTexture() : tex(0), angle(0), item(NULL),
00039 width(512), height(512), cx(1.0f), cy(1.0f) {}
00040 ~GLTexture() { Deinit(); }
00041
00042 void Init(const QImage &image);
00043 void Deinit(void);
00044
00045 void Bind(void);
00046 void MakeQuad(float alpha = 1.0f, float scale = 1.0f);
00047 void SwapWidthHeight(void)
00048 { int tmp = width; width = height; height = tmp; }
00049
00050
00051 void SetItem(ThumbItem*, const QSize &sz);
00052 void SetSize(const QSize &sz)
00053 { width = sz.width(); height = sz.height(); }
00054 void SetScale(float x, float y)
00055 { cx = x; cy = y; }
00056 void ScaleTo(const QSize &dest, ScaleMax scaleMax);
00057 void SetAngle(int newangle) { angle = newangle; }
00058
00059
00060 QSize GetSize(void) const { return QSize(width, height); }
00061 uint GetPixelCount(void) const { return width * height; }
00062 float GetTextureX(void) const { return cx; }
00063 float GetTextureY(void) const { return cy; }
00064 int GetAngle(void) const { return angle; }
00065 QString GetDescription(const QString &status) const;
00066
00067 private:
00068 GLuint tex;
00069 int angle;
00070 ThumbItem *item;
00071 int width;
00072 int height;
00073 float cx;
00074 float cy;
00075 };
00076
00077 #endif // USING_OPENGL
00078 #endif // _GL_TEXTURE_H_