texture.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef EQ_TEXTURE_H
00019 #define EQ_TEXTURE_H
00020
00021 #include <eq/client/windowSystem.h>
00022 #include <eq/client/frame.h>
00023
00024 #include <eq/base/thread.h>
00025 #include <eq/base/nonCopyable.h>
00026
00027 namespace eq
00028 {
00029 class Image;
00030 class PixelViewport;
00031
00038 class Texture : public base::NonCopyable
00039 {
00040 public:
00042 Texture( GLEWContext* const glewContext = 0 );
00043 ~Texture();
00044
00046 void flush();
00047
00049 void setFormat( const GLuint format );
00050
00052 GLuint getFormat() const { return _internalFormat; }
00053
00055 void copyFromFrameBuffer( const PixelViewport& pvp );
00056
00058 void upload( const Image* image, const Frame::Buffer which );
00059
00061 void download( void* buffer, const uint32_t format,
00062 const uint32_t type ) const;
00063
00066 void download( void* buffer ) const;
00067
00069 void bind() const
00070 { EQASSERT( _id ); glBindTexture( GL_TEXTURE_RECTANGLE_ARB, _id ); }
00071
00073 void bindToFBO( const GLenum target, const int width, const int height);
00074
00076 void resize( const int width, const int height );
00077
00079 bool isValid() const;
00080
00081 GLEWContext* glewGetContext() { return _glewContext; }
00082 const GLEWContext* glewGetContext() const { return _glewContext; }
00083
00084 private:
00086 GLuint _id;
00087
00089 GLuint _internalFormat;
00090
00092 GLuint _format;
00093
00095 GLuint _type;
00096
00098 int32_t _width;
00099
00101 int32_t _height;
00102
00104 bool _defined;
00105
00106 GLEWContext* const _glewContext;
00107
00108 union
00109 {
00110 char dummy[64];
00111 };
00112
00114 void _generate();
00115
00117 void _resize( const int32_t width, const int32_t height );
00118
00119 CHECK_THREAD_DECLARE( _thread );
00120 };
00121 };
00122 #endif // EQ_TEXTURE_H