iridescence
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);
20 const void* vertices,
21 int vertex_stride,
22 const void* normals,
23 int normal_stride,
24 const void* colors,
25 int color_stride,
26 int num_vertices,
27 const void* indices,
28 int num_indices,
29 bool wireframe = false);
31 const void* vertices,
32 int vertex_stride,
33 const void* normals,
34 int normal_stride,
35 const void* colors,
36 int color_stride,
37 const void* tex_coords,
38 int tex_coord_stride,
39 int num_vertices,
40 const void* indices,
41 int num_indices,
42 bool wireframe = false);
43
44 template <template <class> class Alloc>
46 const std::vector<Eigen::Vector3f, Alloc<Eigen::Vector3f>>& vertices,
47 const std::vector<Eigen::Vector3f, Alloc<Eigen::Vector3f>>& normals,
48 const std::vector<int>& indices,
49 bool wireframe = false)
50 : Mesh(vertices.data(), sizeof(float) * 3, normals.data(), sizeof(float) * 3, vertices.size(), indices.data(), indices.size(), wireframe) {}
51
52 template <template <class> class Alloc>
54 const std::vector<Eigen::Vector3f, Alloc<Eigen::Vector3f>>& vertices,
55 const std::vector<Eigen::Vector3f, Alloc<Eigen::Vector3f>>& normals,
56 const std::vector<Eigen::Vector4f, Alloc<Eigen::Vector4f>>& colors,
57 const std::vector<int>& indices,
58 bool wireframe = false)
59 : Mesh(vertices.data(), sizeof(float) * 3, normals.data(), sizeof(float) * 3, colors.data(), sizeof(float) * 4, vertices.size(), indices.data(), indices.size(), wireframe) {}
60
61 virtual ~Mesh();
62
63 virtual void draw(glk::GLSLShader& shader) const override;
64
65 void set_texture(const std::shared_ptr<Texture>& texture, GLenum texture_target = GL_TEXTURE1);
66
67private:
68 Mesh(const Mesh&);
69 Mesh& operator=(const Mesh&);
70
71private:
72 float line_width;
73 bool wireframe;
74
75 int vertex_stride;
76 int normal_stride;
77 int color_stride;
78 int tex_coord_stride;
79
80 int num_vertices;
81 int num_indices;
82
83 GLuint vao;
84 GLuint vbo;
85 GLuint nbo;
86 GLuint cbo;
87 GLuint tbo;
88 GLuint ebo;
89
90 GLenum texture_target;
91 std::shared_ptr<Texture> texture;
92};
93
94} // namespace glk
95
96#endif
Definition drawable.hpp:12
GLSLShader is a wrapper for OpenGL shader programs.
Definition glsl_shader.hpp:49
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:45
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:53
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)
Texture class to wrap OpenGL texture object.
Definition texture.hpp:11
Definition async_buffer_copy.hpp:6