hx3d  1
2D/3D Simple Game Framework
geometry.cpp
1 /*
2  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 #include "hx3d/graphics/geometries/geometry.hpp"
22 
23 namespace hx3d {
24 namespace graphics {
25 namespace geom {
26 
27 Geometry::Geometry(): BaseGeometry() {}
28 
30 
31  // Culling
32  switch (_cullingType) {
33  case Culling::Disabled:
34  glDisable(GL_CULL_FACE);
35  break;
36  case Culling::Front:
37  glEnable(GL_CULL_FACE);
38  glCullFace(GL_FRONT);
39  break;
40  case Culling::Back:
41  glEnable(GL_CULL_FACE);
42  glCullFace(GL_BACK);
43  break;
44  default:
45  break;
46  }
47 
48  for (auto& a: _attributes) {
49  a.second.begin(shader);
50  }
51 
52  if (_indices.size() == 0) {
53  glDrawArrays(GL_TRIANGLES, 0, _attributes["Position"].size());
54  } else {
55  _indices.begin(shader);
56  _indices.end(shader);
57  }
58 
59  for (auto& a: _attributes) {
60  a.second.end(shader);
61  }
62 }
63 
64 } /* geom */
65 } /* graphics */
66 } /* hx3d */
std::map< std::string, AttributeArrayBuffer > _attributes
Attributes map.
CounterClockwise culling: back face.
Culling _cullingType
Current culling.
IndexArrayBuffer _indices
Index array buffer.
hx3d framework namespace
Definition: audio.hpp:26
virtual void begin(const Ptr< Shader > &shader) override
Begin the use with a shader.
Clockwise culling: front face.
virtual void draw(Ptr< Shader > shader) override
Draw the geometry.
Definition: geometry.cpp:29
virtual void end(const Ptr< Shader > &shader) override
End the use with a shader.
unsigned int size()
Get the buffer size.
Definition: buffer.inl.hpp:62
std::shared_ptr< T > Ptr
Quick-typing shared ptr.
Definition: ptr.hpp:34