free the answer from, getaddrinfo
[gnash.git] / librender / GnashTexture.h
blob7df7a0e26b40133a484f69f4764aad0eef8676d9
1 // GnashTexture.h: GnashImage class used for OpenGL rendering
2 //
3 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc.
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef GNASH_GNASHTEXTURE_H
22 #define GNASH_GNASHTEXTURE_H
24 #include "GnashImage.h"
25 #include <boost/shared_ptr.hpp>
27 namespace gnash {
29 /// Texture flags
30 enum {
31 GNASH_TEXTURE_VAAPI = 1 << 0
34 /// OpenGL texture format
35 class DSOEXPORT GnashTextureFormat {
36 unsigned int _internal_format;
37 unsigned int _format;
39 public:
40 GnashTextureFormat(image::ImageType type);
42 /// Return GL internal format
43 unsigned int internal_format() const
44 { return _internal_format; }
46 /// Return GL format
47 unsigned int format() const
48 { return _format; }
51 /// OpenGL texture abstraction
52 class DSOEXPORT GnashTexture {
53 unsigned int _width;
54 unsigned int _height;
55 unsigned int _texture;
56 GnashTextureFormat _format;
58 /// OpenGL texture state
59 struct TextureState {
60 unsigned int old_texture;
61 unsigned int was_enabled : 1;
62 unsigned int was_bound : 1;
63 } _texture_state;
65 protected:
66 unsigned int _flags;
68 private:
69 bool init();
71 public:
72 GnashTexture(unsigned int width, unsigned int height,
73 image::ImageType type);
74 virtual ~GnashTexture();
76 /// Return texture flags
77 unsigned int flags() const
78 { return _flags; }
80 /// Return texture width
81 unsigned int width() const
82 { return _width; }
84 /// Return texture height
85 unsigned int height() const
86 { return _height; }
88 /// Return GL texture
89 unsigned int texture() const
90 { return _texture; }
92 /// Return GL internal format
93 unsigned int internal_format() const
94 { return _format.internal_format(); }
96 /// Return GL format
97 unsigned int format() const
98 { return _format.format(); }
100 /// Bind texture to a texturing target
101 bool bind();
103 /// Release texture
104 void release();
106 /// Copy texture data from a buffer.
108 /// Note that this buffer MUST have the same _pitch, or unexpected things
109 /// will happen. In general, it is only safe to copy from another GnashImage
110 /// (or derivative thereof) or unexpected things will happen.
112 /// @param data buffer to copy data from.
113 void update(const boost::uint8_t *data);
116 } // gnash namespace
118 #endif /* GNASH_GNASHTEXTURE_H */