1 // SuperTux 2 // Copyright (C) 2018 Ingo Ruhnke <grumbel@gmail.com> 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_GL33CORE_CONTEXT_HPP 18 #define HEADER_SUPERTUX_VIDEO_GL_GL33CORE_CONTEXT_HPP 19 20 #include "video/gl/gl_context.hpp" 21 22 #include <memory> 23 24 class GLProgram; 25 class GLTexture; 26 class GLVertexArrays; 27 class GLVideoSystem; 28 29 class GL33CoreContext final : public GLContext 30 { 31 public: 32 GL33CoreContext(GLVideoSystem& video_system); 33 ~GL33CoreContext() override; 34 get_name() const35 virtual std::string get_name() const override { return "opengl33"; } 36 37 virtual void bind() override; 38 39 virtual void ortho(float width, float height, bool vflip) override; 40 41 virtual void blend_func(GLenum src, GLenum dst) override; 42 43 virtual void set_positions(const float* data, size_t size) override; 44 45 virtual void set_texcoords(const float* data, size_t size) override; 46 virtual void set_texcoord(float u, float v) override; 47 48 virtual void set_colors(const float* data, size_t size) override; 49 virtual void set_color(const Color& color) override; 50 51 virtual void bind_texture(const Texture& texture, const Texture* displacement_texture) override; 52 virtual void bind_no_texture() override; 53 virtual void draw_arrays(GLenum type, GLint first, GLsizei count) override; 54 supports_framebuffer() const55 virtual bool supports_framebuffer() const override { return true; } 56 get_program() const57 GLProgram& get_program() const { return *m_program; } get_vertex_arrays() const58 GLVertexArrays& get_vertex_arrays() const { return *m_vertex_arrays; } get_white_texture() const59 GLTexture& get_white_texture() const { return *m_white_texture; } 60 61 private: 62 GLVideoSystem& m_video_system; 63 std::unique_ptr<GLProgram> m_program; 64 std::unique_ptr<GLVertexArrays> m_vertex_arrays; 65 std::unique_ptr<GLTexture> m_white_texture; 66 std::unique_ptr<GLTexture> m_black_texture; 67 std::unique_ptr<GLTexture> m_grey_texture; 68 std::unique_ptr<GLTexture> m_transparent_texture; 69 70 private: 71 GL33CoreContext(const GL33CoreContext&) = delete; 72 GL33CoreContext& operator=(const GL33CoreContext&) = delete; 73 }; 74 75 #endif 76 77 /* EOF */ 78