HIRO_DRAW
Computer Graphics Structures library
PrimitiveDatabase.h
1 /*
2  Copyright (C) Skeletex Research, s.r.o. - All Rights Reserved
3  Unauthorized copying of this file, via any medium is strictly prohibited
4  Proprietary and confidential
5 */
6 #ifndef HIRO_DRAW_PRIMITIVE_DATABASE_H
7 #define HIRO_DRAW_PRIMITIVE_DATABASE_H
8 #include <vector>
9 
10 #include <Utils/GeometryStructures.h>
11 #include <GLW/ArrayObject.h>
12 #include <HIRO_DRAW/API.h>
13 
14 
15 
16 namespace hiro::draw
17 {
18 
20  enum class GeometryName
21  {
22  cube,
23  sphere_s0,
24  sphere_s1,
25  sphere_s2,
26  octahedron,
27  camera,
28  plane_x,
29  plane_y,
30  plane_z,
31  _count
32  };
33 
35  HIRO_DRAW_API std::string ToString(hiro::draw::GeometryName geom);
36 
37 
38 
40  struct Geometry
41  {
45  uint32_t vertex_count;
47  uint32_t face_count;
49  glw::PArrayObject buffer;
50  };
51 
52 
53 
55  enum class PrimitiveName
56  {
57  line,
58  axes,
59  square,
60  _count
61  };
62 
64  HIRO_DRAW_API std::string ToString(hiro::draw::PrimitiveName prim);
65 
66 
67 
71  class HIRO_DRAW_API PrimitiveDatabase
72  {
73  public:
75 
76  static hiro::draw::PrimitiveDatabase &GetSingleton();
77 
79  void Draw(const hiro::draw::PrimitiveName primitive) const;
80 
82  void Draw(const hiro::draw::GeometryName geom) const;
83 
85  void DrawInstanced(uint32_t count, const hiro::draw::PrimitiveName primitive) const;
86 
88  void DrawInstanced(uint32_t count, const hiro::draw::GeometryName geom) const;
89 
91  const glw::PArrayObject &Get(const hiro::draw::PrimitiveName primitive) const;
92 
94  const hiro::draw::Geometry &GetGeometry(const hiro::draw::GeometryName geom) const;
95 
97  void Free();
98 
100  static glw::PArrayObject GenerateUvSphere(float radius, uint32_t smoothness = 8);
101 
103  static glw::PArrayObject GeneratePlane(const glm::vec3 &position, float sizing, geom::Axis perpandicular_to);
104 
105  private:
107  ~PrimitiveDatabase() = default;
108  std::vector<glw::PArrayObject> primitives_;
109  std::vector<hiro::draw::Geometry> geometries_;
110  };
111 
112 }
113 
114 #endif /* !HIRO_DRAW_PRIMITIVE_DATABASE_H */
uint32_t vertex_count
Number of vertices which are entering vertex shader.
Definition: PrimitiveDatabase.h:45
Unit sized line laying on x-axis.
HIRO_DRAW_API std::string ToString(hiro::draw::GeometryName geom)
Converts hiro::draw::GeometryName type to the text reprersentation.
Database of common mesh primitives. Automatically manages OpenGL resources.
Definition: PrimitiveDatabase.h:71
glw::PArrayObject buffer
Pointer to array buffer object holding OpenGL buffers.
Definition: PrimitiveDatabase.h:49
uint32_t face_count
Number of rendered faces.
Definition: PrimitiveDatabase.h:47
Standard cube with unit side length.
PrimitiveName
List of available names for primitives generated by hiro::draw::PrimitiveDatabase.
Definition: PrimitiveDatabase.h:55
Unit sized plane perpendicular to z-axis.
hiro::draw::GeometryName name
Identifier name.
Definition: PrimitiveDatabase.h:43
Icosahedron with unit radius subdivided.
Number of available names.
Icosahedron with unit radius.
GeometryName
List of available names for geometry objects generated by hiro::draw::PrimitiveDatabase.
Definition: PrimitiveDatabase.h:20
Extensions for object visualization. Implements a higher level of OpenGL rendering.
Definition: API.h:20
Holds information about geometry.
Definition: PrimitiveDatabase.h:40
Unit sized plane perpendicular to y-axis.
Anisotropic thin octahedron laying on x-axis <0,1>.
Icosahedron with unit radius subdivided twice.
Unit sized spacial basis.
Camera mesh aligned with view space looking to negative z.
Unit sized plane perpendicular to x-axis.