hx3d  1
2D/3D Simple Game Framework
base_geometry.hpp
1 /*
2  Base geometry.
3  Copyright (C) 2015 Denis BOURGE
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #ifndef HX3D_GRAPHICS_GEOMETRIES_BASEGEOMETRY
22 #define HX3D_GRAPHICS_GEOMETRIES_BASEGEOMETRY
23 
24 #include "hx3d/graphics/buffers/attribute_array_buffer.hpp"
25 #include "hx3d/graphics/buffers/index_array_buffer.hpp"
26 #include "hx3d/graphics/shader.hpp"
27 
28 using namespace hx3d::graphics::buffers;
29 
30 namespace hx3d {
31 namespace graphics {
32 
36 enum class Culling {
38  Front = 0,
40  Back,
42  Disabled,
43 };
44 
48 namespace geom {
49 
54 class BaseGeometry {
55 public:
56  BaseGeometry();
57 
64  void addAttribute(std::string name, Attribute attribute);
65 
72  void setAttribute(std::string name, std::vector<float> values);
73 
81  AttributeArrayBuffer& getAttribute(std::string name);
82 
88  void setIndices(std::vector<GLushort> values);
89 
95  IndexArrayBuffer& getIndices();
96 
102  void setFaceCulling(Culling culling);
103 
107  void uploadAll();
108 
114  virtual void draw(Ptr<Shader> shader) = 0;
115 
116 protected:
118  std::map<std::string, AttributeArrayBuffer> _attributes;
123 };
124 
125 } /* geom */
126 } /* graphics */
127 } /* hx3d */
128 
129 #endif
std::map< std::string, AttributeArrayBuffer > _attributes
Attributes map.
CounterClockwise culling: back face.
Culling _cullingType
Current culling.
IndexArrayBuffer _indices
Index array buffer.
Culling
Face culling type.
hx3d framework namespace
Definition: audio.hpp:26
OpenGL buffer attribute.
Definition: attribute.hpp:35
Clockwise culling: front face.
Base geometry. Must be inherited.
Data buffer helpers.
std::shared_ptr< T > Ptr
Quick-typing shared ptr.
Definition: ptr.hpp:34