|
sgltk 0.6
Simple OpenGL Tool Kit
|
Manages meshes. More...
#include <mesh.h>

Public Member Functions | |
| void | setup_shader (Shader *shader) |
| Specifies the shader to use to render the mesh. | |
| bool | setup_camera (glm::mat4 *view_matrix, glm::mat4 *projection_matrix) |
| Sets up the view and projection matrices that will be used by the mesh. | |
| bool | setup_camera (Camera *camera) |
| Sets up the view and projection matrices that will be used by the mesh. | |
| void | set_model_matrix_name (const std::string &name) |
| Sets the name of the model matrix in the shader. | |
| void | set_view_matrix_name (const std::string &name) |
| Sets the name of the view matrix in the shader. | |
| void | set_projection_matrix_name (const std::string &name) |
| Sets the name of the projection matrix in the shader. | |
| void | set_model_view_matrix_name (const std::string &name) |
| Sets the name of the model-view matrix in the shader. | |
| void | set_view_proj_matrix_name (const std::string &name) |
| Sets the name of the view-projection matrix in the shader. | |
| void | set_model_view_proj_name (const std::string &name) |
| Sets the name of the model-view-projection matrix in the shader. | |
| void | set_normal_matrix_name (const std::string &name) |
| Sets the name of the normal matrix in the shader. | |
| void | set_ambient_color_name (const std::string &name) |
| Sets the name of the ambient color in the shader. | |
| void | set_diffuse_color_name (const std::string &name) |
| Sets the name of the diffuse color in the shader. | |
| void | set_specular_color_name (const std::string &name) |
| Sets the name of the specular color in the shader. | |
| void | set_shininess_name (const std::string &name) |
| Sets the name of the shininess of the material in the shader. | |
| void | set_shininess_strength_name (const std::string &name) |
| Sets the name of the shininess strength of the material in the shader. | |
| void | attach_texture (const std::string &name, const sgltk::Texture &texture, unsigned int index=0) |
| Attaches a texture to the mesh. | |
| void | set_transform_feedback_mode (GLenum mode) |
| Sets the output type for transform feedback operations. | |
| void | attach_buffer (const sgltk::Buffer *buffer, GLuint target, unsigned int index=0) |
| Attaches a buffer that is automatically bound before each draw call. | |
| template<typename T> | |
| unsigned int | attach_vertex_buffer (const T *vertexdata, unsigned int number_elements, GLenum usage=GL_STATIC_DRAW) |
| Loads data into memory. | |
| template<typename T> | |
| unsigned int | attach_vertex_buffer (const std::vector< T > &vertexdata, GLenum usage=GL_STATIC_DRAW) |
| Loads data into memory. | |
| template<typename T> | |
| bool | replace_buffer_data (unsigned int buffer_index, const T *data, unsigned int number_elements) |
| Overwrites all data in a vertex buffer. | |
| template<typename T> | |
| bool | replace_buffer_data (unsigned int buffer_index, const std::vector< T > &data) |
| Overwrites all data in a vertex buffer. | |
| template<typename T> | |
| bool | replace_partial_data (unsigned int buffer_index, unsigned int offset, const T *data, unsigned int number_elements) |
| Modifies the data in a vertex buffer. | |
| template<typename T> | |
| bool | replace_partial_data (unsigned int buffer_index, unsigned int offset, const std::vector< T > &data) |
| Modifies the data in a vertex buffer. | |
| template<typename T> | |
| int | add_vertex_attribute (std::string attrib_name, GLint number_elements, GLenum type, const T *data, GLenum usage=GL_STATIC_DRAW) |
| This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute. | |
| template<typename T> | |
| int | add_vertex_attribute (std::string attrib_name, GLint number_elements, GLenum type, const std::vector< T > &data, GLenum usage=GL_STATIC_DRAW) |
| This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute. | |
| template<typename T> | |
| int | add_vertex_attribute (int attrib_location, GLint number_elements, GLenum type, const T *data, GLenum usage=GL_STATIC_DRAW) |
| This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute. | |
| template<typename T> | |
| int | add_vertex_attribute (int attrib_location, GLint number_elements, GLenum type, const std::vector< T > &data, GLenum usage=GL_STATIC_DRAW) |
| This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute. | |
| int | set_buffer_vertex_attribute (const std::string &attrib_name, sgltk::Buffer *buffer, GLint number_elements, GLenum type, GLsizei stride, const GLvoid *pointer, unsigned int divisor=0) |
| Sets pointers to vertex attributes. | |
| int | set_buffer_vertex_attribute (int attrib_location, sgltk::Buffer *buffer, GLint number_elements, GLenum type, GLsizei stride, const GLvoid *pointer, unsigned int divisor=0) |
| Sets pointers to vertex attributes. | |
| int | set_vertex_attribute (const std::string &attrib_name, unsigned int buffer_index, GLint number_elements, GLenum type, GLsizei stride, const GLvoid *pointer, unsigned int divisor=0) |
| Sets pointers to vertex attributes. | |
| int | set_vertex_attribute (int attrib_location, unsigned int buffer_index, GLint number_elements, GLenum type, GLsizei stride, const GLvoid *pointer, unsigned int divisor=0) |
| Sets pointers to vertex attributes. | |
| template<typename T> | |
| int | attach_index_buffer (const std::vector< T > &indices) |
| Attaches an index array to the mesh. | |
| template<typename T> | |
| void | compute_bounding_box (const std::vector< T > &vertexdata, unsigned int pointer) |
| Computes the bounding box of the mesh. | |
| void | draw (GLenum mode) |
| Renders the mesh using the first index buffer. | |
| void | draw (GLenum mode, const glm::mat4 *model_matrix) |
| Renders the mesh using the first index buffer. | |
| void | draw (GLenum mode, unsigned int index_buffer, const glm::mat4 *model_matrix) |
| Renders the mesh. | |
| void | draw_instanced (GLenum mode, unsigned int num_instances) |
| Renders the mesh multiple times. | |
| void | draw_instanced (GLenum mode, unsigned int index_buffer, unsigned int num_instances) |
| Renders the mesh multiple times. | |
| template<> | |
| int | attach_index_buffer (const std::vector< unsigned char > &indices) |
| template<> | |
| int | attach_index_buffer (const std::vector< unsigned short > &indices) |
| template<> | |
| int | attach_index_buffer (const std::vector< unsigned int > &indices) |
Public Attributes | |
| unsigned int | num_uv |
| Number of texture coordinates. | |
| unsigned int | num_col |
| Number of vertex colors. | |
| unsigned int | num_vertices |
| Number of vertices. | |
| std::string | ambient_color_name |
| The name of the ambient materiel component. | |
| std::string | diffuse_color_name |
| The name of the diffuse materiel component. | |
| std::string | specular_color_name |
| The name of the specular materiel component. | |
| std::string | shininess_name |
| The name of the specular factor. | |
| std::string | shininess_strength_name |
| The name of the specular exponent. | |
| std::string | model_matrix_name |
| The name of the model matrix in the shader. | |
| std::string | view_matrix_name |
| The name of the view matrix in the shader. | |
| std::string | projection_matrix_name |
| The name of the projection matrix in the shader. | |
| std::string | model_view_matrix_name |
| The name of the model-view matrix in the shader. | |
| std::string | view_proj_matrix_name |
| The name of the view-projection matrix in the shader. | |
| std::string | model_view_projection_matrix_name |
| The name of the model-view-projection matrix in the shader. | |
| std::string | normal_matrix_name |
| The name of the normal matrix in the shader. | |
| Shader * | shader |
| The shader being used to draw the mesh. | |
| std::vector< glm::vec3 > | bounding_box |
| The bounding box. | |
| glm::mat4 | model_matrix |
| The model matrix. | |
| float | shininess |
| The shininess of the material. | |
| float | shininess_strength |
| The strength of the shininess of the material. | |
| glm::vec4 | color_ambient |
| The ambient color component of the material. | |
| glm::vec4 | color_diffuse |
| The diffuse color component of the material. | |
| glm::vec4 | color_specular |
| The specular color component of the material. | |
| std::vector< std::tuple< std::string, const Texture &, unsigned int > > | auto_textures |
| Attached textures. | |
| std::vector< std::tuple< std::string, const Texture &, unsigned int > > | textures |
| Attached user textures. | |
| bool | wireframe |
| Indicates that the mesh should be drawn as a wireframe. | |
| bool | twosided |
| Indicates that the mesh should not be drawn using back face culling. | |
| int sgltk::Mesh::add_vertex_attribute | ( | int | attrib_location, |
| GLint | number_elements, | ||
| GLenum | type, | ||
| const std::vector< T > & | data, | ||
| GLenum | usage = GL_STATIC_DRAW ) |
This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute.
| attrib_location | The attribute location in the shader |
| number_elements | Number of elements |
| type | Element type |
| data | The vertices to be loaded into memory |
| usage | A hint as to how the buffer will be accessed. Valid values are GL_{STREAM,STATIC,DYNAMIC}_{DRAW,READ,COPY}. |
| int sgltk::Mesh::add_vertex_attribute | ( | int | attrib_location, |
| GLint | number_elements, | ||
| GLenum | type, | ||
| const T * | data, | ||
| GLenum | usage = GL_STATIC_DRAW ) |
This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute.
| attrib_location | The attribute location in the shader |
| number_elements | Number of elements |
| type | Element type |
| data | The vertices to be loaded into memory |
| usage | A hint as to how the buffer will be accessed. Valid values are GL_{STREAM,STATIC,DYNAMIC}_{DRAW,READ,COPY}. |
| int sgltk::Mesh::add_vertex_attribute | ( | std::string | attrib_name, |
| GLint | number_elements, | ||
| GLenum | type, | ||
| const std::vector< T > & | data, | ||
| GLenum | usage = GL_STATIC_DRAW ) |
This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute.
| attrib_name | The attribute name in the shader |
| number_elements | Number of elements |
| type | Element type |
| data | The vertices to be loaded into memory |
| usage | A hint as to how the buffer will be accessed. Valid values are GL_{STREAM,STATIC,DYNAMIC}_{DRAW,READ,COPY}. |
| int sgltk::Mesh::add_vertex_attribute | ( | std::string | attrib_name, |
| GLint | number_elements, | ||
| GLenum | type, | ||
| const T * | data, | ||
| GLenum | usage = GL_STATIC_DRAW ) |
This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute.
| attrib_name | The attribute name in the shader |
| number_elements | Number of elements |
| type | Element type |
| data | The vertices to be loaded into memory |
| usage | A hint as to how the buffer will be accessed. Valid values are GL_{STREAM,STATIC,DYNAMIC}_{DRAW,READ,COPY}. |
| void Mesh::attach_buffer | ( | const sgltk::Buffer * | buffer, |
| GLuint | target, | ||
| unsigned int | index = 0 ) |
Attaches a buffer that is automatically bound before each draw call.
| buffer | The buffer to attach_buffer |
| target | The target the buffer will be bound to |
| index | The index of the binding point within the array specified by target. |
| int sgltk::Mesh::attach_index_buffer | ( | const std::vector< T > & | indices | ) |
Attaches an index array to the mesh.
| indices | Indices describing the topology of the mesh |
|
inline |
|
inline |
|
inline |
| void Mesh::attach_texture | ( | const std::string & | name, |
| const sgltk::Texture & | texture, | ||
| unsigned int | index = 0 ) |
| unsigned int sgltk::Mesh::attach_vertex_buffer | ( | const std::vector< T > & | vertexdata, |
| GLenum | usage = GL_STATIC_DRAW ) |
Loads data into memory.
| vertexdata | The data to be loaded into memory |
| usage | A hint as to how the buffer will be accessed. Valid values are GL_{STREAM,STATIC,DYNAMIC}_{DRAW,READ,COPY}. |
| unsigned int sgltk::Mesh::attach_vertex_buffer | ( | const T * | vertexdata, |
| unsigned int | number_elements, | ||
| GLenum | usage = GL_STATIC_DRAW ) |
Loads data into memory.
| vertexdata | The data to be loaded into memory |
| number_elements | Number of elements |
| usage | A hint as to how the buffer will be accessed. Valid values are GL_{STREAM,STATIC,DYNAMIC}_{DRAW,READ,COPY}. |
| void sgltk::Mesh::compute_bounding_box | ( | const std::vector< T > & | vertexdata, |
| unsigned int | pointer ) |
| void Mesh::draw | ( | GLenum | mode | ) |
| void Mesh::draw | ( | GLenum | mode, |
| const glm::mat4 * | model_matrix ) |
| void Mesh::draw | ( | GLenum | mode, |
| unsigned int | index_buffer, | ||
| const glm::mat4 * | model_matrix = nullptr ) |
| void Mesh::draw_instanced | ( | GLenum | mode, |
| unsigned int | index_buffer, | ||
| unsigned int | num_instances ) |
| void Mesh::draw_instanced | ( | GLenum | mode, |
| unsigned int | num_instances ) |
| bool sgltk::Mesh::replace_buffer_data | ( | unsigned int | buffer_index, |
| const std::vector< T > & | data ) |
| bool sgltk::Mesh::replace_buffer_data | ( | unsigned int | buffer_index, |
| const T * | data, | ||
| unsigned int | number_elements ) |
| bool sgltk::Mesh::replace_partial_data | ( | unsigned int | buffer_index, |
| unsigned int | offset, | ||
| const std::vector< T > & | data ) |
| bool sgltk::Mesh::replace_partial_data | ( | unsigned int | buffer_index, |
| unsigned int | offset, | ||
| const T * | data, | ||
| unsigned int | number_elements ) |
Modifies the data in a vertex buffer.
| buffer_index | The index of the buffer to be modified |
| offset | The byte offset into the buffer |
| data | The data to be loaded into the buffer |
| number_elements | Number of elements |
| void Mesh::set_ambient_color_name | ( | const std::string & | name | ) |
| int Mesh::set_buffer_vertex_attribute | ( | const std::string & | attrib_name, |
| sgltk::Buffer * | buffer, | ||
| GLint | number_elements, | ||
| GLenum | type, | ||
| GLsizei | stride, | ||
| const GLvoid * | pointer, | ||
| unsigned int | divisor = 0 ) |
Sets pointers to vertex attributes.
| attrib_name | The attribute name in the shader |
| buffer | The buffer that contains the attribute |
| number_elements | Number of elements |
| type | Element type |
| stride | Memory offset between vertices |
| pointer | The offset of the attribute in the vertex structure |
| divisor | Determines how many instances share the same attribute value. 0 means that every shader instance gets a new value, 1 means every mesh instance gets a new value, 2 means that two instances get the same value and so on. |
| int Mesh::set_buffer_vertex_attribute | ( | int | attrib_location, |
| sgltk::Buffer * | buffer, | ||
| GLint | number_elements, | ||
| GLenum | type, | ||
| GLsizei | stride, | ||
| const GLvoid * | pointer, | ||
| unsigned int | divisor = 0 ) |
Sets pointers to vertex attributes.
| attrib_location | The attribute location in the shader |
| buffer | The buffer that contains the attribute |
| number_elements | Number of elements |
| type | Element type |
| stride | Memory offset between vertices |
| pointer | The offset of the attribute in the vertex structure |
| divisor | Determines how many instances share the same attribute value. 0 means that every shader instance gets a new value, 1 means every mesh instance gets a new value, 2 means that two instances get the same value and so on. |
| void Mesh::set_diffuse_color_name | ( | const std::string & | name | ) |
| void Mesh::set_model_matrix_name | ( | const std::string & | name | ) |
| void Mesh::set_model_view_matrix_name | ( | const std::string & | name | ) |
| void Mesh::set_model_view_proj_name | ( | const std::string & | name | ) |
| void Mesh::set_normal_matrix_name | ( | const std::string & | name | ) |
| void Mesh::set_projection_matrix_name | ( | const std::string & | name | ) |
| void Mesh::set_shininess_name | ( | const std::string & | name | ) |
| void Mesh::set_shininess_strength_name | ( | const std::string & | name | ) |
| void Mesh::set_specular_color_name | ( | const std::string & | name | ) |
| void Mesh::set_transform_feedback_mode | ( | GLenum | mode | ) |
| int Mesh::set_vertex_attribute | ( | const std::string & | attrib_name, |
| unsigned int | buffer_index, | ||
| GLint | number_elements, | ||
| GLenum | type, | ||
| GLsizei | stride, | ||
| const GLvoid * | pointer, | ||
| unsigned int | divisor = 0 ) |
Sets pointers to vertex attributes.
| attrib_name | The attribute name in the shader |
| buffer_index | The index of the buffer that contains the attribute |
| number_elements | Number of elements |
| type | Element type |
| stride | Memory offset between vertices |
| pointer | The offset of the attribute in the vertex structure |
| divisor | Determines how many instances share the same attribute value. 0 means that every shader instance gets a new value, 1 means every mesh instance gets a new value, 2 means that two instances get the same value and so on. |
| int Mesh::set_vertex_attribute | ( | int | attrib_location, |
| unsigned int | buffer_index, | ||
| GLint | number_elements, | ||
| GLenum | type, | ||
| GLsizei | stride, | ||
| const GLvoid * | pointer, | ||
| unsigned int | divisor = 0 ) |
Sets pointers to vertex attributes.
| attrib_location | The attribute location in the shader |
| buffer_index | The index of the buffer that contains the attribute |
| number_elements | Number of elements |
| type | Element type |
| stride | Memory offset between vertices |
| pointer | The offset of the attribute in the vertex structure |
| divisor | Determines how many instances share the same attribute value. 0 means that every shader instance gets a new value, 1 means every mesh instance gets a new value, 2 means that two instances get the same value and so on. |
| void Mesh::set_view_matrix_name | ( | const std::string & | name | ) |
| void Mesh::set_view_proj_matrix_name | ( | const std::string & | name | ) |
| bool Mesh::setup_camera | ( | Camera * | camera | ) |
| bool Mesh::setup_camera | ( | glm::mat4 * | view_matrix, |
| glm::mat4 * | projection_matrix ) |
| void Mesh::setup_shader | ( | Shader * | shader | ) |
| std::string sgltk::Mesh::ambient_color_name |
| std::vector<std::tuple<std::string, const Texture&, unsigned int> > sgltk::Mesh::auto_textures |
| std::vector<glm::vec3> sgltk::Mesh::bounding_box |
| glm::vec4 sgltk::Mesh::color_ambient |
| glm::vec4 sgltk::Mesh::color_diffuse |
| glm::vec4 sgltk::Mesh::color_specular |
| std::string sgltk::Mesh::diffuse_color_name |
| std::string sgltk::Mesh::model_matrix_name |
| std::string sgltk::Mesh::model_view_matrix_name |
| std::string sgltk::Mesh::model_view_projection_matrix_name |
| std::string sgltk::Mesh::normal_matrix_name |
| unsigned int sgltk::Mesh::num_uv |
| std::string sgltk::Mesh::projection_matrix_name |
| Shader* sgltk::Mesh::shader |
| std::string sgltk::Mesh::shininess_name |
| float sgltk::Mesh::shininess_strength |
| std::string sgltk::Mesh::shininess_strength_name |
| std::string sgltk::Mesh::specular_color_name |
| std::vector<std::tuple<std::string, const Texture&, unsigned int> > sgltk::Mesh::textures |
| bool sgltk::Mesh::twosided |
| std::string sgltk::Mesh::view_matrix_name |
| std::string sgltk::Mesh::view_proj_matrix_name |
| bool sgltk::Mesh::wireframe |