Equalizer  1.6.1
texture.h
1 
2 /* Copyright (c) 2009-2012, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2010, Cedric Stalder <cedric.stalder@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef EQUTIL_TEXTURE_H
20 #define EQUTIL_TEXTURE_H
21 
22 #include <eq/client/frame.h> // Frame::Buffer enum
23 
24 #include <lunchbox/thread.h> // thread debug macro
25 #include <lunchbox/nonCopyable.h> // base class
26 
27 namespace eq
28 {
29 namespace util
30 {
31 namespace detail { class Texture; }
38  class Texture : public lunchbox::NonCopyable
39  {
40  public:
49  EQ_API Texture( const unsigned target,
50  const GLEWContext* const glewContext = 0 );
51 
53  EQ_API virtual ~Texture();
54 
58  EQ_API unsigned getTarget() const;
59 
64  uint32_t getCompressorTarget() const;
65 
71  EQ_API unsigned getInternalFormat() const;
72 
80  EQ_API void setExternalFormat( const uint32_t format,
81  const uint32_t type );
82 
87  EQ_API unsigned getFormat() const;
88 
93  EQ_API unsigned getType() const;
94 
96  EQ_API unsigned getName() const;
97 
99  EQ_API int32_t getWidth() const;
100 
102  EQ_API int32_t getHeight() const;
103 
105  EQ_API bool isValid() const;
107 
118  EQ_API void init( const unsigned internalFormat, const int32_t width,
119  const int32_t height );
120 
125  EQ_API void flush();
126 
128  void applyZoomFilter( const ZoomFilter filter ) const;
129 
130  void applyWrap() const; //<! @internal
131 
137  EQ_API void copyFromFrameBuffer( const unsigned internalFormat,
138  const fabric::PixelViewport& pvp );
139 
141  EQ_API void upload( const int32_t width, const int32_t height,
142  const void* ptr );
143 
148  EQ_API void download( void* buffer ) const;
149 
151  EQ_API void bind() const;
152 
154  EQ_API void bindToFBO( const unsigned target, const int32_t width,
155  const int32_t height );
156 
158  EQ_API void resize( const int32_t width, const int32_t height );
159 
161  EQ_API void writeRGB( const std::string& filename ) const;
163 
164  EQ_API const GLEWContext* glewGetContext() const;
165  EQ_API void setGLEWContext( const GLEWContext* context );
166 
173  EQ_API void flushNoDelete();
174 
188  EQ_API void setGLData( const unsigned id, const unsigned internalFormat,
189  const int32_t width, const int32_t height );
191 
192  private:
193  detail::Texture* const _impl;
194 
203  void _setInternalFormat( const unsigned internalFormat );
204 
206  void _generate();
207 
209  void _grow( const int32_t width, const int32_t height );
210 
211  LB_TS_VAR( _thread );
212  };
213 }
214 }
215 
216 #endif // EQUTIL_TEXTURE_H
void upload(const int32_t width, const int32_t height, const void *ptr)
Copy the specified buffer to the texture at 0,0.
void writeRGB(const std::string &filename) const
Write the texture data as an rgb image file.
unsigned getInternalFormat() const
void bindToFBO(const unsigned target, const int32_t width, const int32_t height)
Create and bind a texture to the current FBO.
void download(void *buffer) const
Copy the texture data from the GPU to the given memory address.
int32_t getHeight() const
ZoomFilter
Filtering algorithm to applied during zoom operations.
Definition: zoomFilter.h:26
void copyFromFrameBuffer(const unsigned internalFormat, const fabric::PixelViewport &pvp)
Copy the specified area from the current read buffer to the texture at 0,0.
void setExternalFormat(const uint32_t format, const uint32_t type)
Set the external data format and type.
void flushNoDelete()
Flush the texture without deleting the GL texture name.
void bind() const
Bind the texture.
unsigned getName() const
virtual ~Texture()
Destruct the texture.
Holds a 2D pixel viewport with methods for manipulation.
Definition: pixelViewport.h:34
unsigned getFormat() const
void resize(const int32_t width, const int32_t height)
Resize the texture.
void setGLData(const unsigned id, const unsigned internalFormat, const int32_t width, const int32_t height)
Use an OpenGL texture created externally.
A wrapper around OpenGL textures.
Definition: texture.h:38
Texture(const unsigned target, const GLEWContext *const glewContext=0)
Construct a new Texture.
bool isValid() const
unsigned getType() const
int32_t getWidth() const
void flush()
Clear the texture, including deleting the GL texture name.
void init(const unsigned internalFormat, const int32_t width, const int32_t height)
Initialize an OpenGL texture.
unsigned getTarget() const