hx3d  1
2D/3D Simple Game Framework
multi_array_buffer.hpp
1 /*
2  Multi array buffer.
3  One buffer for multiple attributes.
4 
5  Copyright (C) 2015 Denis BOURGE
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library 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 GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20  USA
21 
22 
23  TODO
24  > Finish the class.
25 */
26 
27 #ifndef HX3D_GRAPHICS_BUFFERS_MULTIARRAYBUFFER
28 #define HX3D_GRAPHICS_BUFFERS_MULTIARRAYBUFFER
29 
30 #include "hx3d/graphics/buffers/attribute_array_buffer.hpp"
31 
32 #include <map>
33 
34 namespace hx3d {
35 namespace graphics {
36 namespace buffers {
37 
41 class MultiArrayBuffer: public ArrayBuffer<float> {
42 
43 public:
46 
53  void addAttribute(const std::string name, const Attribute attribute);
54 
61  void setAttribute(const std::string name, const std::vector<float> data);
62 
69  AttributeArrayBuffer& getAttribute(const std::string name);
70 
74  void generate();
75 
76  virtual void upload() override;
77 
78  virtual void begin(const Ptr<Shader>& shader) override;
79  virtual void end(const Ptr<Shader>& shader) override;
80 
81 private:
83  std::map<std::string, AttributeArrayBuffer> _attributes;
84 
92  AttributeArrayBuffer& getMapAttribute(const unsigned int i);
93 
99  unsigned int attributeTotalSize();
100 };
101 
102 } /* buffers */
103 } /* graphics */
104 } /* hx3d */
105 
106 #endif
virtual void begin(const Ptr< Shader > &shader) override
Begin the use with a shader.
Multi-component array buffer for optimization purpose.
virtual void end(const Ptr< Shader > &shader) override
End the use with a shader.
virtual void upload() override
Upload the data to the GPU.
hx3d framework namespace
Definition: audio.hpp:26
OpenGL buffer attribute.
Definition: attribute.hpp:35
void addAttribute(const std::string name, const Attribute attribute)
Add an empty initialized attribute array buffer.
void setAttribute(const std::string name, const std::vector< float > data)
Set the wanted attribute array buffer content.
AttributeArrayBuffer & getAttribute(const std::string name)
Get the wanted attribute array buffer.
void generate()
Generate the vector using the attributes.
float * data()
Get the buffer values.
std::shared_ptr< T > Ptr
Quick-typing shared ptr.
Definition: ptr.hpp:34
OpenGL GPU uploadable buffer.