1 // GnashTexture.h: GnashImage class used for OpenGL rendering
3 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc.
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.
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.
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>
31 GNASH_TEXTURE_VAAPI
= 1 << 0
34 /// OpenGL texture format
35 class DSOEXPORT GnashTextureFormat
{
36 unsigned int _internal_format
;
40 GnashTextureFormat(image::ImageType type
);
42 /// Return GL internal format
43 unsigned int internal_format() const
44 { return _internal_format
; }
47 unsigned int format() const
51 /// OpenGL texture abstraction
52 class DSOEXPORT GnashTexture
{
55 unsigned int _texture
;
56 GnashTextureFormat _format
;
58 /// OpenGL texture state
60 unsigned int old_texture
;
61 unsigned int was_enabled
: 1;
62 unsigned int was_bound
: 1;
72 GnashTexture(unsigned int width
, unsigned int height
,
73 image::ImageType type
);
74 virtual ~GnashTexture();
76 /// Return texture flags
77 unsigned int flags() const
80 /// Return texture width
81 unsigned int width() const
84 /// Return texture height
85 unsigned int height() const
89 unsigned int texture() const
92 /// Return GL internal format
93 unsigned int internal_format() const
94 { return _format
.internal_format(); }
97 unsigned int format() const
98 { return _format
.format(); }
100 /// Bind texture to a texturing target
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
);
118 #endif /* GNASH_GNASHTEXTURE_H */