Tucano  0.1
A library for rapid prototyping with modern OpenGL and GLSL
Tucano::VertexAttribute Class Reference

A vertex attribute of a mesh. More...

#include <mesh.hpp>

Public Member Functions

 VertexAttribute (string in_name, int in_num_elements, int in_element_size, GLenum in_type, GLenum in_array_type=GL_ARRAY_BUFFER)
 
string getName (void) const
 Returns the name of the attribute. More...
 
int getSize (void) const
 Returns the number of elements of this attribute (usually number of vertices in VAO) More...
 
int getElementSize (void) const
 Returns the number of elements per attribute For example, returns 3 if attribute is of type vec3. More...
 
GLenum getType (void) const
 Returns the type of the attribute (ex. GL_FLOAT) More...
 
GLenum getArrayType (void) const
 Returns the type of array (ex. GL_ARRAY_BUFFER) More...
 
void setArrayType (GLenum at)
 Sets the type of array (default is GL_ARRAY_BUFFER) More...
 
GLint getLocation (void) const
 Returns the location of the attribute. The location is usually set by the shader, since it can be used by different shaders in different situations, and we don't want to force the shader layout id to be known beforehand. More...
 
void setLocation (GLint loc)
 Sets the location of the attribute for a shader. More...
 
GLuint getBufferID (void)
 Returns the id of the vertex array of this attribute. More...
 
void bind (void)
 Bind the attribute. More...
 
void enable (GLint loc)
 Bind the attribute to a given location. More...
 
void enable ()
 Binds the attribute to its location. More...
 
void unbind (void)
 Unbind the attribute. More...
 
void disable (void)
 Disables associated location if attribute has one. More...
 

Public Attributes

string name
 Attribute's name. More...
 
int size = 0
 size of attribute array (usually number of vertices) More...
 
int element_size = 0
 number of elements per attribute More...
 
GLint location = -1
 this is set by the shader using the attribute More...
 
GLuint bufferID = 0
 Vertex array Buffer ID. More...
 
GLenum type = GL_FLOAT
 Type of attribute element (ex. GL_FLOAT) More...
 
GLenum array_type = GL_ARRAY_BUFFER
 Type of attribute array (GL_ARRAY_BUFFER for most cases), indices are GL_ELEMENT_ARRAY_BUFFER. More...
 
std::shared_ptr< GLuint > bufferID_sptr
 

Friends

class Mesh
 

Detailed Description

A vertex attribute of a mesh.

Some common attributes (coordinate, color, normal, texCoord) have custom loaders. Otherwise, a generic attribute can be loaded.

Constructor & Destructor Documentation

Tucano::VertexAttribute::VertexAttribute ( string  in_name,
int  in_num_elements,
int  in_element_size,
GLenum  in_type,
GLenum  in_array_type = GL_ARRAY_BUFFER 
)
inline

Member Function Documentation

void Tucano::VertexAttribute::bind ( void  )
inline

Bind the attribute.

void Tucano::VertexAttribute::disable ( void  )
inline

Disables associated location if attribute has one.

void Tucano::VertexAttribute::enable ( GLint  loc)
inline

Bind the attribute to a given location.

void Tucano::VertexAttribute::enable ( )
inline

Binds the attribute to its location.

GLenum Tucano::VertexAttribute::getArrayType ( void  ) const
inline

Returns the type of array (ex. GL_ARRAY_BUFFER)

Returns
Type of array
GLuint Tucano::VertexAttribute::getBufferID ( void  )
inline

Returns the id of the vertex array of this attribute.

Returns
Buffer ID
int Tucano::VertexAttribute::getElementSize ( void  ) const
inline

Returns the number of elements per attribute For example, returns 3 if attribute is of type vec3.

Returns
Size of one attribute
GLint Tucano::VertexAttribute::getLocation ( void  ) const
inline

Returns the location of the attribute. The location is usually set by the shader, since it can be used by different shaders in different situations, and we don't want to force the shader layout id to be known beforehand.

Returns
Attribute shader location
string Tucano::VertexAttribute::getName ( void  ) const
inline

Returns the name of the attribute.

Returns
Attribute's name
int Tucano::VertexAttribute::getSize ( void  ) const
inline

Returns the number of elements of this attribute (usually number of vertices in VAO)

Returns
Number of elements
GLenum Tucano::VertexAttribute::getType ( void  ) const
inline

Returns the type of the attribute (ex. GL_FLOAT)

Returns
Type of attribute
void Tucano::VertexAttribute::setArrayType ( GLenum  at)
inline

Sets the type of array (default is GL_ARRAY_BUFFER)

Parameters
atArray type
void Tucano::VertexAttribute::setLocation ( GLint  loc)
inline

Sets the location of the attribute for a shader.

Parameters
locAttribute shader location
void Tucano::VertexAttribute::unbind ( void  )
inline

Unbind the attribute.

Friends And Related Function Documentation

friend class Mesh
friend

Member Data Documentation

GLenum Tucano::VertexAttribute::array_type = GL_ARRAY_BUFFER

Type of attribute array (GL_ARRAY_BUFFER for most cases), indices are GL_ELEMENT_ARRAY_BUFFER.

GLuint Tucano::VertexAttribute::bufferID = 0

Vertex array Buffer ID.

std::shared_ptr< GLuint > Tucano::VertexAttribute::bufferID_sptr
int Tucano::VertexAttribute::element_size = 0

number of elements per attribute

GLint Tucano::VertexAttribute::location = -1

this is set by the shader using the attribute

string Tucano::VertexAttribute::name

Attribute's name.

int Tucano::VertexAttribute::size = 0

size of attribute array (usually number of vertices)

GLenum Tucano::VertexAttribute::type = GL_FLOAT

Type of attribute element (ex. GL_FLOAT)


The documentation for this class was generated from the following file: