1 //  SuperTux
2 //  Copyright (C) 2016 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_VERTEX_ARRAYS_HPP
18 #define HEADER_SUPERTUX_VIDEO_GL_GL_VERTEX_ARRAYS_HPP
19 
20 #include <stddef.h>
21 
22 #include "video/gl.hpp"
23 
24 class Color;
25 class GL33CoreContext;
26 
27 class GLVertexArrays final
28 {
29 public:
30   GLVertexArrays(GL33CoreContext& context);
31   ~GLVertexArrays();
32 
33   void bind();
34 
35   void set_positions(const float* data, size_t size);
36 
37   /** size is in bytes */
38   void set_texcoords(const float* data, size_t size);
39   void set_texcoord(float u, float v);
40 
41   void set_colors(const float* data, size_t size);
42   void set_color(const Color& color);
43 
44 private:
45   GL33CoreContext& m_context;
46   GLuint m_vao;
47   GLuint m_positions_buffer;
48   GLuint m_texcoords_buffer;
49   GLuint m_color_buffer;
50 
51 private:
52   GLVertexArrays(const GLVertexArrays&) = delete;
53   GLVertexArrays& operator=(const GLVertexArrays&) = delete;
54 };
55 
56 #endif
57 
58 /* EOF */
59