gtsam_points
Loading...
Searching...
No Matches
mesh.hpp
Go to the documentation of this file.
1#ifndef GLK_MESH_HPP
2#define GLK_MESH_HPP
3
4#include <memory>
5#include <vector>
6#include <Eigen/Core>
7
8#include <GL/gl3w.h>
9#include <glk/drawable.hpp>
10#include <glk/glsl_shader.hpp>
11
12namespace glk {
13
14class Texture;
15
16class Mesh : public Drawable {
17public:
18 Mesh(const void* vertices, int vertex_stride, const void* normals, int normal_stride, int num_vertices, const void* indices, int num_indices, bool wireframe = false);
19 Mesh(const void* vertices, int vertex_stride, const void* normals, int normal_stride, const void* colors, int color_stride, int num_vertices, const void* indices, int num_indices, bool wireframe = false);
20 Mesh(const void* vertices, int vertex_stride, const void* normals, int normal_stride, const void* colors, int color_stride, const void* tex_coords, int tex_coord_stride, int num_vertices, const void* indices, int num_indices, bool wireframe = false);
21
22 template <template <class> class Alloc>
24 const std::vector<Eigen::Vector3f, Alloc<Eigen::Vector3f>>& vertices,
25 const std::vector<Eigen::Vector3f, Alloc<Eigen::Vector3f>>& normals,
26 const std::vector<int>& indices,
27 bool wireframe = false)
28 : Mesh(vertices.data(), sizeof(float) * 3, normals.data(), sizeof(float) * 3, vertices.size(), indices.data(), indices.size(), wireframe) {}
29
30 template <template <class> class Alloc>
32 const std::vector<Eigen::Vector3f, Alloc<Eigen::Vector3f>>& vertices,
33 const std::vector<Eigen::Vector3f, Alloc<Eigen::Vector3f>>& normals,
34 const std::vector<Eigen::Vector4f, Alloc<Eigen::Vector4f>>& colors,
35 const std::vector<int>& indices,
36 bool wireframe = false)
37 : Mesh(vertices.data(), sizeof(float) * 3, normals.data(), sizeof(float) * 3, colors.data(), sizeof(float) * 4, vertices.size(), indices.data(), indices.size(), wireframe) {}
38
39 virtual ~Mesh();
40
41 virtual void draw(glk::GLSLShader& shader) const override;
42
43 void set_texture(const std::shared_ptr<Texture>& texture, GLenum texture_target = GL_TEXTURE1);
44
45private:
46 Mesh(const Mesh&);
47 Mesh& operator=(const Mesh&);
48
49private:
50 float line_width;
51 bool wireframe;
52
53 int vertex_stride;
54 int normal_stride;
55 int color_stride;
56 int tex_coord_stride;
57
58 int num_vertices;
59 int num_indices;
60
61 GLuint vao;
62 GLuint vbo;
63 GLuint nbo;
64 GLuint cbo;
65 GLuint tbo;
66 GLuint ebo;
67
68 GLenum texture_target;
69 std::shared_ptr<Texture> texture;
70};
71
72} // namespace glk
73
74#endif
Definition drawable.hpp:12
Definition glsl_shader.hpp:20
Definition mesh.hpp:16
Mesh(const void *vertices, int vertex_stride, const void *normals, int normal_stride, const void *colors, int color_stride, int num_vertices, const void *indices, int num_indices, bool wireframe=false)
Mesh(const std::vector< Eigen::Vector3f, Alloc< Eigen::Vector3f > > &vertices, const std::vector< Eigen::Vector3f, Alloc< Eigen::Vector3f > > &normals, const std::vector< int > &indices, bool wireframe=false)
Definition mesh.hpp:23
void set_texture(const std::shared_ptr< Texture > &texture, GLenum texture_target=GL_TEXTURE1)
virtual void draw(glk::GLSLShader &shader) const override
Mesh(const std::vector< Eigen::Vector3f, Alloc< Eigen::Vector3f > > &vertices, const std::vector< Eigen::Vector3f, Alloc< Eigen::Vector3f > > &normals, const std::vector< Eigen::Vector4f, Alloc< Eigen::Vector4f > > &colors, const std::vector< int > &indices, bool wireframe=false)
Definition mesh.hpp:31
virtual ~Mesh()
Mesh(const void *vertices, int vertex_stride, const void *normals, int normal_stride, int num_vertices, const void *indices, int num_indices, bool wireframe=false)
Mesh(const void *vertices, int vertex_stride, const void *normals, int normal_stride, const void *colors, int color_stride, const void *tex_coords, int tex_coord_stride, int num_vertices, const void *indices, int num_indices, bool wireframe=false)
Definition async_buffer_copy.hpp:6
std::enable_if_t< needs_aligned_allocator< T >::value, std::shared_ptr< T > > make_shared(Args &&... args)
Definition make_shared.hpp:20