supertux
gl_texture.hpp
1 // SuperTux
2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_VIDEO_GL_GL_TEXTURE_HPP
18 #define HEADER_SUPERTUX_VIDEO_GL_GL_TEXTURE_HPP
19 
20 #include <optional>
21 
22 #include "video/color.hpp"
23 #include "video/gl.hpp"
24 #include "video/sampler.hpp"
25 #include "video/texture.hpp"
26 
27 class Sampler;
28 
32 class GLTexture final : public Texture
33 {
34 public:
35  GLTexture(int width, int height, std::optional<Color> fill_color = std::nullopt);
36  GLTexture(const SDL_Surface& image, const Sampler& sampler);
37  ~GLTexture() override;
38 
39  virtual int get_texture_width() const override { return m_texture_width; }
40  virtual int get_texture_height() const override { return m_texture_height; }
41 
42  virtual int get_image_width() const override { return m_image_width; }
43  virtual int get_image_height() const override { return m_image_height; }
44 
45  void set_handle(GLuint handle) { m_handle = handle; }
46  const GLuint &get_handle() const { return m_handle; }
47 
48  const Sampler& get_sampler() const { return m_sampler; }
49 
50  void set_image_width(int width) { m_image_width = width; }
51  void set_image_height(int height) { m_image_height = height; }
52 
53 private:
54  void set_texture_params();
55 
56 private:
57  GLuint m_handle;
58  Sampler m_sampler;
59  int m_texture_width;
60  int m_texture_height;
61  int m_image_width;
62  int m_image_height;
63 
64 private:
65  GLTexture(const GLTexture&) = delete;
66  GLTexture& operator=(const GLTexture&) = delete;
67 };
68 
69 #endif
70 
71 /* EOF */
Definition: sampler.hpp:23
This class is a wrapper around a texture handle.
Definition: texture.hpp:30
This class is a wrapper around a texture handle.
Definition: gl_texture.hpp:32