00001
00002 #ifndef _IMAGE_ARRAY_H
00003 #define _IMAGE_ARRAY_H
00004
00005 #include <vector>
00006
00007 #include "Image.h"
00008
00009
00010 namespace gk {
00011
00012 template< class T >
00013 class TImageArray
00014 {
00015 TImageArray( );
00016 TImageArray( const TImageArray& );
00017 TImageArray& operator= ( const TImageArray& );
00018
00019 protected:
00020 std::vector< TImage<T> *> m_images;
00021 int m_width;
00022 int m_height;
00023
00024 public:
00025 TImageArray( const int w, const int h, const int count= 1 )
00026 :
00027 m_images(),
00028 m_width(w),
00029 m_height(h)
00030 {
00031 m_images.resize(count);
00032 }
00033
00034 virtual ~TImageArray( ) {}
00035
00036 int width( ) const
00037 {
00038 return m_width;
00039 }
00040
00041 int height( ) const
00042 {
00043 return m_height;
00044 }
00045
00046 unsigned int size( ) const
00047 {
00048 return m_images.size();
00049 }
00050
00051 void clear( )
00052 {
00053 m_images.clear();
00054 }
00055
00056 int push_back( TImage<T> *image )
00057 {
00058 if(image == NULL)
00059 return -1;
00060 if(image->width() != m_width || image->height() != m_height)
00061 return -1;
00062
00063 m_images.push_back(image);
00064 return 0;
00065 }
00066
00067 int push_back( TImage<T>& image )
00068 {
00069 if(image.width() != m_width || image.height() != m_height)
00070 return -1;
00071
00072 m_images.push_back(&image);
00073 return 0;
00074 }
00075
00076 const TImage<T> *operator[] ( const int index ) const
00077 {
00078 if(index < 0 || index >= (int) m_images.size())
00079 return NULL;
00080
00081 return m_images[index];
00082 }
00083
00084 TImage<T> *operator[] ( const int index )
00085 {
00086 if(index < 0 || index >= (int) m_images.size())
00087 return NULL;
00088
00089 return m_images[index];
00090 }
00091 };
00092
00093
00094 typedef TImageArray<HDRPixel> HDRImageArray;
00095
00096 typedef TImageArray<Pixel> ImageArray;
00097
00098 template< class T >
00099 class TImageCube : public TImageArray<T>
00100 {
00101 public:
00102 TImageCube( const int w, const int h )
00103 :
00104 TImageArray<T>(w, h, 6)
00105 {}
00106
00107 ~TImageCube( ) {}
00108
00109 const TImage<T> *operator[] ( const unsigned int face ) const
00110 {
00111 if(face < GL_TEXTURE_CUBE_MAP_POSITIVE_X)
00112 return TImageArray<T>::m_images[face];
00113 if(face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)
00114 return TImageArray<T>::m_images[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X];
00115 return NULL;
00116 }
00117
00118 TImage<T> *operator[] ( const unsigned int face )
00119 {
00120 if(face < GL_TEXTURE_CUBE_MAP_POSITIVE_X)
00121 return TImageArray<T>::m_images[face];
00122 if(face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)
00123 return TImageArray<T>::m_images[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X];
00124 return NULL;
00125 }
00126 };
00127
00128
00129 typedef TImageCube<HDRPixel> HDRImageCube;
00130
00131 typedef TImageCube<Pixel> ImageCube;
00132
00133 }
00134
00135 #endif