Equalizer  1.12.0
Parallel Rendering Framework
texture.h
1 
2 /* Copyright (c) 2009-2015, Stefan Eilemann <eile@equalizergraphics.com>
3  * Cedric Stalder <cedric.stalder@gmail.com>
4  * Daniel Nachbaur <danielnachbaur@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef EQUTIL_TEXTURE_H
21 #define EQUTIL_TEXTURE_H
22 
23 #include <eq/frame.h> // Frame::Buffer enum
24 #include <lunchbox/thread.h> // thread debug macro
25 
26 namespace eq
27 {
28 namespace util
29 {
30 namespace detail { class Texture; }
31 
38 class Texture
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  EQ_API void applyZoomFilter( const ZoomFilter filter ) const;
129 
130  EQ_API 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, const int32_t samples = 1 );
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  Texture( const Texture& ) = delete;
194  Texture& operator=( const Texture& ) = delete;
195  detail::Texture* const _impl;
196 
205  void _setInternalFormat( const unsigned internalFormat );
206 
208  void _generate();
209 
211  void _grow( const int32_t width, const int32_t height );
212 
213  LB_TS_VAR( _thread );
214 };
216 EQ_API std::ostream& operator << ( std::ostream&, const Texture& );
217 
218 }
219 }
220 
221 #endif // EQUTIL_TEXTURE_H
EQ_API bool isValid() const
EQ_API void setExternalFormat(const uint32_t format, const uint32_t type)
Set the external data format and type.
EQ_API void bind() const
Bind the texture.
A wrapper around OpenGL textures.
Definition: texture.h:38
EQ_API void download(void *buffer) const
Copy the texture data from the GPU to the given memory address.
EQ_API unsigned getInternalFormat() const
ZoomFilter
Filtering algorithm to applied during zoom operations.
Definition: zoomFilter.h:25
EQ_API void upload(const int32_t width, const int32_t height, const void *ptr)
Copy the specified buffer to the texture at 0,0.
EQ_API void flush()
Clear the texture, including deleting the GL texture name.
EQ_API void init(const unsigned internalFormat, const int32_t width, const int32_t height)
Initialize an OpenGL texture.
EQ_API std::ostream & operator<<(std::ostream &, const Texture &)
Print the texture state to the given output stream.
The Equalizer client library.
Definition: eq/agl/types.h:23
EQ_API void writeRGB(const std::string &filename) const
Write the texture data as an rgb image file.
EQ_API void setGLData(const unsigned id, const unsigned internalFormat, const int32_t width, const int32_t height)
Use an OpenGL texture created externally.
EQ_API unsigned getFormat() const
EQ_API int32_t getWidth() const
EQ_API int32_t getHeight() const
EQ_API unsigned getTarget() const
EQ_API void copyFromFrameBuffer(const unsigned internalFormat, const fabric::PixelViewport &pvp)
Copy the specified area from the current read buffer to the texture at 0,0.
EQ_API unsigned getName() const
virtual EQ_API ~Texture()
Destruct the texture.
Holds a 2D pixel viewport with methods for manipulation.
Definition: pixelViewport.h:34
EQ_API Texture(const unsigned target, const GLEWContext *const glewContext=0)
Construct a new Texture.
EQ_API void bindToFBO(const unsigned target, const int32_t width, const int32_t height, const int32_t samples=1)
Create and bind a texture to the current FBO.
EQ_API void resize(const int32_t width, const int32_t height)
Resize the texture.
EQ_API unsigned getType() const
EQ_API void flushNoDelete()
Flush the texture without deleting the GL texture name.