ScummVM API documentation
texture.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef GRAPHICS_OPENGL_TEXTURE_H
23 #define GRAPHICS_OPENGL_TEXTURE_H
24 
25 #include "graphics/opengl/system_headers.h"
26 #include "graphics/opengl/context.h"
27 
28 #include "graphics/pixelformat.h"
29 #include "graphics/surface.h"
30 
31 #include "common/rect.h"
32 
33 namespace OpenGL {
34 
35 enum WrapMode {
36  kWrapModeBorder,
37  kWrapModeEdge,
38  kWrapModeRepeat,
39  kWrapModeMirroredRepeat
40 };
41 
47 class Texture {
48 public:
56  Texture(GLenum glIntFormat, GLenum glFormat, GLenum glType, bool autoCreate = true);
57  ~Texture();
58 
64  void enableLinearFiltering(bool enable);
65 
69  bool isLinearFilteringEnabled() const { return (_glFilter == GL_LINEAR); }
70 
76  void setWrapMode(WrapMode wrapMode);
77 
81  void destroy();
82 
86  void create();
87 
91  void bind() const;
92 
103  bool setSize(uint width, uint height);
104 
113  void updateArea(const Common::Rect &area, const Graphics::Surface &src);
114 
118  uint getWidth() const { return _width; }
119 
123  uint getHeight() const { return _height; }
124 
128  uint getLogicalWidth() const { return _logicalWidth; }
129 
133  uint getLogicalHeight() const { return _logicalHeight; }
134 
138  const GLfloat *getTexCoords() const { return _texCoords; }
139 
146  GLuint getGLTexture() const { return _glTexture; }
147 
148  static const Graphics::PixelFormat getRGBAPixelFormat();
149 
150 protected:
151  const GLenum _glIntFormat;
152  const GLenum _glFormat;
153  const GLenum _glType;
154 
155  uint _width, _height;
156  uint _logicalWidth, _logicalHeight;
157  GLfloat _texCoords[4*2];
158 
159  GLint _glFilter;
160 
161  GLuint _glTexture;
162 };
163 
164 } // End of namespace OpenGL
165 
166 #endif
bool setSize(uint width, uint height)
void setWrapMode(WrapMode wrapMode)
Definition: surface.h:67
void enableLinearFiltering(bool enable)
Definition: pixelformat.h:138
uint getHeight() const
Definition: texture.h:123
Definition: rect.h:144
void updateArea(const Common::Rect &area, const Graphics::Surface &src)
GLuint getGLTexture() const
Definition: texture.h:146
uint getLogicalWidth() const
Definition: texture.h:128
uint getWidth() const
Definition: texture.h:118
void bind() const
Texture(GLenum glIntFormat, GLenum glFormat, GLenum glType, bool autoCreate=true)
Definition: renderbuffer.h:27
Definition: texture.h:47
const GLfloat * getTexCoords() const
Definition: texture.h:138
uint getLogicalHeight() const
Definition: texture.h:133
bool isLinearFilteringEnabled() const
Definition: texture.h:69