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_GL_SHADER_HPP 18 #define HEADER_SUPERTUX_VIDEO_GL_GL_SHADER_HPP 19 20 #include <memory> 21 #include <string> 22 #include <vector> 23 24 #include "video/gl.hpp" 25 26 class GLShader final 27 { 28 public: 29 static std::unique_ptr<GLShader> from_file(GLenum type, const std::string& filename); 30 static std::unique_ptr<GLShader> from_source(GLenum type, const std::vector<std::string>& sources); 31 32 public: 33 GLShader(GLenum type); 34 ~GLShader(); 35 get_handle() const36 GLuint get_handle() const { 37 return m_shader; 38 } 39 40 std::string get_shader_info_log() const; 41 42 private: 43 void source(std::vector<std::string> const& sources); 44 void compile(); 45 46 private: 47 GLuint m_shader; 48 49 private: 50 GLShader(const GLShader&) = delete; 51 GLShader& operator=(const GLShader&) = delete; 52 }; 53 54 #endif 55 56 /* EOF */ 57