texture.h

00001 
00002 /* Copyright (c) 2009, Stefan Eilemann <eile@equalizergraphics.com>
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #ifndef EQ_TEXTURE_H
00019 #define EQ_TEXTURE_H
00020 
00021 #include <eq/client/windowSystem.h> // GL types
00022 #include <eq/client/frame.h>        // Frame::Buffer enum
00023 
00024 #include <eq/base/thread.h>         // thread debug macro
00025 #include <eq/base/nonCopyable.h>    // base class
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 // placeholder for binary-compatible changes
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
Generated on Mon Aug 10 18:58:41 2009 for Equalizer 0.9 by  doxygen 1.5.8