Equalizer
1.2.1
|
00001 00002 /* Copyright (c) 2009-2011, Stefan Eilemann <eile@equalizergraphics.com> 00003 * 2010, Cedric Stalder <cedric.stalder@gmail.com> 00004 * 00005 * This library is free software; you can redistribute it and/or modify it under 00006 * the terms of the GNU Lesser General Public License version 2.1 as published 00007 * by the Free Software Foundation. 00008 * 00009 * This library is distributed in the hope that it will be useful, but WITHOUT 00010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00012 * details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public License 00015 * along with this library; if not, write to the Free Software Foundation, Inc., 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00017 */ 00018 00019 #ifndef EQUTIL_TEXTURE_H 00020 #define EQUTIL_TEXTURE_H 00021 00022 #include <eq/client/gl.h> // GLEW 00023 #include <eq/client/frame.h> // Frame::Buffer enum 00024 00025 #include <co/base/thread.h> // thread debug macro 00026 #include <co/base/nonCopyable.h> // base class 00027 00028 namespace eq 00029 { 00030 class Image; 00031 00032 namespace util 00033 { 00040 class Texture : public co::base::NonCopyable 00041 { 00042 public: 00051 EQ_API Texture( const GLenum target, 00052 const GLEWContext* const glewContext = 0 ); 00053 00055 EQ_API virtual ~Texture(); 00056 00060 GLenum getTarget() const { return _target; } 00061 00066 uint32_t getCompressorTarget() const; 00067 00073 GLuint getInternalFormat() const { return _internalFormat; } 00074 00082 EQ_API void setExternalFormat( const uint32_t format, 00083 const uint32_t type ); 00084 00089 GLuint getFormat() const { return _format; } 00090 00095 GLuint getType() const { return _type; } 00096 00098 GLuint getName() const { return _name; } 00099 00101 int32_t getWidth() const { return _width; } 00102 00104 int32_t getHeight() const { return _height; } 00105 00107 EQ_API bool isValid() const; 00109 00120 EQ_API void init( const GLuint internalFormat, const int32_t width, 00121 const int32_t height ); 00122 00127 EQ_API void flush(); 00128 00130 void applyZoomFilter( const ZoomFilter filter ) const; 00131 00132 void applyWrap() const; //<! @internal 00133 00139 EQ_API void copyFromFrameBuffer( const GLuint internalFormat, 00140 const fabric::PixelViewport& pvp ); 00141 00143 EQ_API void upload( const int32_t width, const int32_t height, 00144 const void* ptr ); 00145 00150 EQ_API void download( void* buffer ) const; 00151 00153 EQ_API void bind() const; 00154 00156 EQ_API void bindToFBO( const GLenum target, const int32_t width, 00157 const int32_t height ); 00158 00160 EQ_API void resize( const int32_t width, const int32_t height ); 00161 00163 EQ_API void writeRGB( const std::string& filename ) const; 00165 00166 const GLEWContext* glewGetContext() const { return _glewContext; } 00167 void setGLEWContext( const GLEWContext* context ) 00168 { _glewContext = context; } 00169 00176 EQ_API void flushNoDelete(); 00177 00191 EQ_API void setGLData( const GLuint id, const GLuint internalFormat, 00192 const int32_t width, const int32_t height ); 00194 00195 private: 00197 GLuint _name; 00198 00200 const GLenum _target; 00201 00203 GLuint _internalFormat; 00204 00206 GLuint _format; 00207 00209 GLuint _type; 00210 00212 int32_t _width; 00213 00215 int32_t _height; 00216 00218 bool _defined; 00219 00220 const GLEWContext* _glewContext; 00221 00222 struct Private; 00223 Private* _private; // placeholder for binary-compatible changes 00224 00233 void _setInternalFormat( const GLuint internalFormat ); 00234 00236 void _generate(); 00237 00239 void _grow( const int32_t width, const int32_t height ); 00240 00241 EQ_TS_VAR( _thread ); 00242 }; 00243 } 00244 } 00245 00246 #endif // EQUTIL_TEXTURE_H