Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Classes | Public Types | Public Member Functions | List of all members
BIAS::glfVertexFormat Class Reference

A vertex format describes the attributes of a vertex. More...

#include <OpenGLFramework/Base/glfVertexFormat.hh>

Public Types

enum  Attribute {
  ATTRIB_POSITION, ATTRIB_NORMAL, ATTRIB_COLOR, ATTRIB_TEXCOORD,
  ATTRIB_GENERIC
}
 Possible attributes of a vertex. More...
 

Public Member Functions

void AddAttribute (Attribute attrib, int index, GLenum type, int size, bool normalized=false)
 Adds a vertex attribute to the format. More...
 
void AddAttribute (Attribute attrib, GLenum type, int size)
 Convenience wrapper for other glfVertexFormat::AddAttribute method if no additional attribute index is required. More...
 
void Bind (const void *data) const
 Binds a vertex buffer or vertex array in OpenGL using this vertex format. More...
 
bool GetAttributeInfo (Attribute attrib, int index, int &offset, GLenum &type, int &size) const
 Retrieves information about a vertex attribute inside the vertex structure. More...
 
int GetVertexSize () const
 Returns the size in bytes of a single vertex. More...
 
 glfVertexFormat ()
 
bool HasAttribute (Attribute attrib, int index=0) const
 Returns true iff the given attribute is part of the format. More...
 
glfVertexFormatoperator= (const glfVertexFormat &v2)
 
 ~glfVertexFormat ()
 

Detailed Description

A vertex format describes the attributes of a vertex.

A list of vertices with the same format are stored in a vertex buffer.

Author
jkollmann
Examples:
ExampleRenderingContext.cpp.

Definition at line 40 of file glfVertexFormat.hh.

Member Enumeration Documentation

Possible attributes of a vertex.

Note that ATTRIB_TEXCOORD and ATTRIB_GENERIC require an additional index, i.e. there can be multiple of them.

Enumerator
ATTRIB_POSITION 
ATTRIB_NORMAL 
ATTRIB_COLOR 
ATTRIB_TEXCOORD 
ATTRIB_GENERIC 

Definition at line 50 of file glfVertexFormat.hh.

Constructor & Destructor Documentation

glfVertexFormat::glfVertexFormat ( )

Definition at line 30 of file glfVertexFormat.cpp.

glfVertexFormat::~glfVertexFormat ( )

Definition at line 35 of file glfVertexFormat.cpp.

Member Function Documentation

void glfVertexFormat::AddAttribute ( Attribute  attrib,
int  index,
GLenum  type,
int  size,
bool  normalized = false 
)

Adds a vertex attribute to the format.

Parameters
attribThe attribute to be added.
indexAdditional index for ATTRIB_TEXCOORD and ATTRIB_GENERIC.
typeData type for this attribute. Can be GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT, GL_FLOAT, or GL_DOUBLE.
sizeNumber of components for this attribute, i.e. 3 for a 3-dimensional vector.
normalizedTrue if values should be normalized. Only for ATTRIB_GENERIC.
Note
Not all combinations of attribute, type and size are supported by OpenGL or may be unsupported by the current OpenGL implementation. In this case an exception will be thrown.
Examples:
ExampleRenderingContext.cpp.

Definition at line 49 of file glfVertexFormat.cpp.

References ATTRIB_GENERIC, ATTRIB_TEXCOORD, and HasAttribute().

Referenced by BIAS::Primitives::AddRelativeQuadPatches(), BIAS::Primitives::AddRelativeQuadPatchOverImageLine(), BIAS::clfTrimmedICP::clfTrimmedICP(), BIAS::Primitives::LocalNormalizedVertexCloud(), BIAS::Primitives::LocalPerspectivePatches(), BIAS::Primitives::LocalPerspectivePatchOverLine(), BIAS::Primitives::LocalPerspectiveQuad(), BIAS::Primitives::PlainQuad2DWithTexture2D(), and BIAS::PMDWarp::SetupDefaultPrimitiveRendering_().

void BIAS::glfVertexFormat::AddAttribute ( Attribute  attrib,
GLenum  type,
int  size 
)
inline

Convenience wrapper for other glfVertexFormat::AddAttribute method if no additional attribute index is required.

This can be used for all attributes except ATTRIB_TEXCOORD and ATTRIB_GENERIC.

Definition at line 80 of file glfVertexFormat.hh.

void glfVertexFormat::Bind ( const void *  data) const

Binds a vertex buffer or vertex array in OpenGL using this vertex format.

Attention
For internal usage inside OpenGLFramework Base library only.

Definition at line 237 of file glfVertexFormat.cpp.

References ATTRIB_COLOR, ATTRIB_GENERIC, ATTRIB_NORMAL, ATTRIB_POSITION, and ATTRIB_TEXCOORD.

Referenced by BIAS::glfVertexBuffer::Bind().

bool glfVertexFormat::GetAttributeInfo ( Attribute  attrib,
int  index,
int &  offset,
GLenum &  type,
int &  size 
) const

Retrieves information about a vertex attribute inside the vertex structure.

Returns false if the vertex attribute is not part of this format.

Definition at line 110 of file glfVertexFormat.cpp.

References ATTRIB_GENERIC, and ATTRIB_TEXCOORD.

int glfVertexFormat::GetVertexSize ( ) const

Returns the size in bytes of a single vertex.

Definition at line 93 of file glfVertexFormat.cpp.

Referenced by BIAS::clfBuffer::AllocateFromVertexBuffer(), and BIAS::glfVertexBuffer::Create().

bool glfVertexFormat::HasAttribute ( Attribute  attrib,
int  index = 0 
) const

Returns true iff the given attribute is part of the format.

Definition at line 98 of file glfVertexFormat.cpp.

References ATTRIB_GENERIC, and ATTRIB_TEXCOORD.

Referenced by AddAttribute().

glfVertexFormat & glfVertexFormat::operator= ( const glfVertexFormat v2)

Definition at line 40 of file glfVertexFormat.cpp.


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