00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
#ifndef UGL_IMAGE_HPP
00029
#define UGL_IMAGE_HPP
00030
00031
#include "../image/uimage.hpp"
00032
00033
00034
#include "../ufo_gl.hpp"
00035
#include "../image/uimageio.hpp"
00036
00037
#include "../util/udimension.hpp"
00038
#include "../util/urectangle.hpp"
00039
00040
namespace ufo {
00041
00051 class UFO_EXPORT UGL_Image :
public UImage {
00052 UFO_DECLARE_DYNAMIC_CLASS(UGL_Image)
00053
public:
00063 UGL_Image(
const std::string & fileName,
bool lazy =
true,
bool autoRefresh =
true,
00064 GLenum imageFormat = 0, GLenum internalFormat = 0);
00065
00075 UGL_Image(
UImageIO * imageIO,
bool lazy =
true,
bool autoRefresh =
true,
00076 GLenum imageFormat = 0, GLenum internalFormat = 0);
00077
00078
virtual ~UGL_Image();
00079
00080
public:
00081
virtual UDimension getImageSize()
const;
00082
virtual int getImageComponents()
const;
00083
virtual unsigned long handle()
const;
00084
00085
public:
00087
UDimension getSize()
const;
00088
00090
void paint(
UGraphics * g);
00091
00093
void paint(
UGraphics * g,
const UPoint & location);
00096
void paint(
UGraphics * g,
const URectangle & rect);
00097
00103
void paintSubImage(
UGraphics * g,
const URectangle & rect,
00104
const UPoint & dest);
00111
void paintSubImage(
UGraphics * g,
const URectangle & rect,
00112
const URectangle & dest);
00113
00117
void dispose();
00121
void disposeGL();
00122
00124
void refresh();
00125
00127
void setQuality(
int quality);
00128
int getQuality()
const;
00129
00130
protected:
00132
virtual bool createGLTexture(GLubyte * dataA,
int componentsA,
00133 GLenum imageFormatA, GLenum internalFormatA);
00134
00135
void ensureImage();
00138
int round2(
int n);
00139
00140
private:
00141 GLuint m_index;
00142 GLenum m_imageFormat;
00143 GLenum m_internalFormat;
00145
UDimension m_size;
00146
int m_imageComponents : 4;
00147
int m_quality : 4;
00148
int m_isValid : 1;
00149
int m_isLazy : 1;
00150
int m_autoRefresh : 1;
00151
00153 std::string m_fileName;
00155
UImageIO * m_imageData;
00156 };
00157
00158 }
00159
00160
#endif // UGL_IMAGE_HPP