00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef VRS_OPENGL_TEXTURE_MIPMAPTEXTURE2DGL_H
00021 #define VRS_OPENGL_TEXTURE_MIPMAPTEXTURE2DGL_H
00022
00023 #include <vrs/image/image.h>
00024 #include <vrs/opengl/texture2dgl.h>
00025 #include <vrs/container/dataiterator.h>
00026
00027 namespace VRS {
00028
00029 class Image;
00030
00032 class VRS_CORE_API MipmapTexture2DGL :
00033 public Texture2DGL
00034 {
00035 public:
00036 VRS_TYPEINFO(MipmapTexture2DGL, Texture2DGL);
00037 VRS_SERIALIZABLE(MipmapTexture2DGL);
00038
00039 MipmapTexture2DGL(
00040 SO<Iterator<SO<Image> > > images,
00041 TextureGL::WrapMode wrapS = TextureGL::REPEAT,
00042 TextureGL::WrapMode wrapT = TextureGL::REPEAT,
00043 TextureGL::FilterMode minFilter = TextureGL::TRILINEAR,
00044 TextureGL::FilterMode magFilter = TextureGL::LINEAR,
00045 unsigned int baseLevel = 0,
00046 bool unrefAfterBinding = false,
00047 GLfloat anisotropic = 1.0,
00048 const Matrix& matrix = Matrix(),
00049 const Color& borderColor = Color::black,
00050 GLenum internalFormat = GL_ZERO
00051 );
00062 class ImageProxy : public VRS::SharedObj {
00063 public:
00064 VRS_TYPEINFO(ImageProxy, VRS::SharedObj);
00065 VRS_SERIALIZABLE(ImageProxy);
00066
00067 ImageProxy(unsigned int level, SO<Image> image);
00068
00069
00070 void setImage(SO<Image> image);
00071 SO<Image> getImage() const;
00072
00073 bool needsTransfer(const TransactionNo& transactionNo) const;
00074
00075 unsigned int getWidth()const {return m_width;}
00076 unsigned int getHeight()const {return m_height;}
00077 unsigned int getLevel()const {return m_level;}
00078 Image::MemoryLayout getLayout()const {return m_memory;}
00079
00080 protected:
00081 ImageProxy();
00082 SO<Image> m_image;
00083 bool m_transfer;
00084 unsigned int m_width, m_height, m_level;
00085 Image::MemoryLayout m_memory;
00086
00087 };
00088
00089 bool operator==(const MipmapTexture2DGL& other) const;
00090
00091 virtual void setImages(SO<Iterator<SO<Image> > > newImages, unsigned int baseLevel = 0, GLenum internalFormat = GL_ZERO);
00092 virtual void setImage(unsigned int level, SO<Image> newImage);
00093
00094
00095 virtual SO<Iterator<SO<Image> > > getImages() const;
00096
00097 virtual SO<Image> getImage(unsigned int level) const;
00098
00099 virtual SO<Iterator<SO<ImageProxy> > > getImageProxies() const;
00100 virtual SO<ImageProxy> getImageProxy(unsigned int level) const;
00101 virtual int getLevels() const;
00104 virtual unsigned int getBaseLevel() const;
00105
00106 virtual unsigned int getMinMipmapLevel() const;
00107 virtual unsigned int getMaxMipmapLevel() const;
00108
00109 virtual GLenum getInternalFormat() const;
00110
00111 virtual Matrix adjustMatrix() const;
00112
00113 bool unrefAfterBinding() const;
00114 protected:
00115 MipmapTexture2DGL();
00116
00117 virtual void acceptChildren(std::vector<Visitable*>& appendChildrenHere) const;
00118
00119 SO<Iterator<SO<Image> > > ensureImageFormatConsistence(const SO<Iterator<SO<Image> > >& images);
00120
00121 private:
00122
00123 SO<DataIterator<SO<ImageProxy> > > m_images;
00124 unsigned int m_baseLevel;
00125 bool m_unrefAfterBinding;
00126
00127 };
00128
00129 }
00130
00131 #endif // VRS_OPENGL_TEXTURE_MIPMAPTEXTURE2DGL_H