summary refs log tree commit diff stats
path: root/src/renderer/mesh.h
blob: 06bf65d825aecebe7f4d1d8e768c9374a8ebdb39 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef MESH_H_76B72E12
#define MESH_H_76B72E12

#include <string>
#include "gl.h"
#include "wrappers.h"

class Mesh {
public:

  Mesh(std::string filename);

  Mesh(const Mesh& other) = delete;
  Mesh& operator=(const Mesh& other) = delete;

  inline GLuint getVertexBufferId() const
  {
    return vertexBuffer_.getId();
  }

  inline GLuint getUvBufferId() const
  {
    return uvBuffer_.getId();
  }

  inline GLuint getNormalBufferId() const
  {
    return normalBuffer_.getId();
  }

  inline GLuint getIndexBufferId() const
  {
    return indexBuffer_.getId();
  }

  inline size_t getIndexCount() const
  {
    return indexCount_;
  }

private:

  struct element {
    size_t vertexId;
    size_t uvId;
    size_t normalId;

    bool operator<(const element& other) const
    {
      return std::tie(vertexId, uvId, normalId) <
        std::tie(other.vertexId, other.uvId, other.normalId);
    }
  };

  GLBuffer vertexBuffer_;
  GLBuffer uvBuffer_;
  GLBuffer normalBuffer_;
  GLBuffer indexBuffer_;
  size_t indexCount_;
};

#endif /* end of include guard: MESH_H_76B72E12 */