OGLplus (0.45.0) a C++ wrapper for OpenGL

Encapsulates vertex attribute functionality. More...

#include </home/chochlik/devel/oglplus/include/oglplus/vertex_attrib.hpp>

Inheritance diagram for oglplus::VertexAttrib< T >:
Collaboration diagram for oglplus::VertexAttrib< T >:

Public Member Functions

 VertexAttrib (VertexAttribSlot location)
 References the vertex attribute array at location. More...
 
 VertexAttrib (const ProgramOps &program, const GLchar *identifier)
 References the vertex attribute identifier of the program. More...
 
 VertexAttrib (const ProgramOps &program, const String &identifier)
 References the vertex attribute identifier of the program.
 
void Set (T value) const
 Set the value of the vertex attribute. More...
 
void operator= (T value) const
 Set the value of the vertex attribute. More...
 
VertexAttribSlot Location (void) const
 Returns the location of this vertex attribute in a program. More...
 
void BindLocation (const ProgramOps &program, const String &identifier) const
 Bind the vertex attribute location. More...
 
void Divisor (GLuint divisor) const
 Set the vertex attrib divisor. More...
 

Static Public Member Functions

static VertexAttribSlot GetLocation (const ProgramOps &program, const String &identifier)
 Finds the vertex attribute location, throws on failure. More...
 
template<typename... ProgramOps_>
static VertexAttribSlot GetCommonLocation (const GLchar *identifier, const ProgramOps &program, const ProgramOps_ &...programs)
 Returns vertex attr. location in multiple programs if it's consistent. More...
 
static bool QueryLocation (const ProgramOps &program, const String &identifier, VertexAttribSlot &location)
 Queries the vertex attribute location in a program. More...
 
static _common_location_query QueryCommonLocation (const String &identifier, VertexAttribSlot &location)
 Allows to query the vertex attribute location in multiple programs. More...
 
template<typename... ProgramOps_>
static bool QueryCommonLocation (const GLchar *identifier, VertexAttribSlot &location, const ProgramOps &program, const ProgramOps_ &...programs)
 Queries the vertex attribute location in multiple programs. More...
 

Detailed Description

template<typename T>
class oglplus::VertexAttrib< T >

Encapsulates vertex attribute functionality.

Constructor & Destructor Documentation

template<typename T >
oglplus::VertexAttrib< T >::VertexAttrib ( VertexAttribSlot  location)

References the vertex attribute array at location.

Related OpenGL symbols:
glGetAttribLocation
template<typename T >
oglplus::VertexAttrib< T >::VertexAttrib ( const ProgramOps program,
const GLchar *  identifier 
)

References the vertex attribute identifier of the program.

Related OpenGL symbols:
glGetAttribLocation

Member Function Documentation

void oglplus::VertexAttribOps::BindLocation ( const ProgramOps program,
const String identifier 
) const
inherited

Bind the vertex attribute location.

See Also
GetLocation
QueryLocation
Related OpenGL symbols:
glBindAttribLocation

References OGLPLUS_CHECK.

void oglplus::VertexAttribOps::Divisor ( GLuint  divisor) const
inherited

Set the vertex attrib divisor.

Requires OpenGL 3.3.

Related OpenGL symbols:
glVertexAttribDivisor

References OGLPLUS_CHECK.

template<typename... ProgramOps_>
static VertexAttribSlot oglplus::VertexAttribOps::GetCommonLocation ( const GLchar *  identifier,
const ProgramOps program,
const ProgramOps_ &...  programs 
)
staticinherited

Returns vertex attr. location in multiple programs if it's consistent.

Finds the location of the input vertex attribute specified by identifier in every program in programs. Throws Error if no such attribute exists or if it is not active in some of the programs or if the attribute has different locations in different programs. Otherwise returns the vertex attribute position.

Buffer buf;
Program prog1, prog2, prog3;
// build the programs, load data into the buffer, ...
vao.Bind();
buffer.Bind(Buffer::Target::Array);
try
{
"Position",
prog1,
prog2,
prog3
& )
);
attr.Setup(n_per_vertex, DataType::Float);
attr.Enable();
}
catch(Error& error)
{
// handle the error or bind the locations manually
}
See Also
GetLocation
GetCommonLocation
QueryLocation
BindLocation
Related OpenGL symbols:
glGetAttribLocation
Examples:
oglplus/026_stencil_shadow.cpp, oglplus/030_cube_mapping.cpp, and oglplus/032_transitions.cpp.
static VertexAttribSlot oglplus::VertexAttribOps::GetLocation ( const ProgramOps program,
const String identifier 
)
staticinherited

Finds the vertex attribute location, throws on failure.

Finds the location of the input vertex attribute specified by identifier in a program. Throws if no such attribute exists or if it is not active. For a non-throwing version see QueryLocation().

See Also
GetCommonLocation
QueryLocation
BindLocation
Related OpenGL symbols:
glGetAttribLocation
VertexAttribSlot oglplus::VertexAttribOps::Location ( void  ) const
inherited

Returns the location of this vertex attribute in a program.

See Also
GetLocation
GetCommonLocation
QueryLocation
BindLocation
Related OpenGL symbols:
glGetAttribLocation
template<typename T >
void oglplus::VertexAttrib< T >::operator= ( T  value) const

Set the value of the vertex attribute.

Related OpenGL symbols:
glVertexAttrib

References oglplus::VertexAttrib< T >::Set().

static _common_location_query oglplus::VertexAttribOps::QueryCommonLocation ( const String identifier,
VertexAttribSlot location 
)
staticinherited

Allows to query the vertex attribute location in multiple programs.

This function returns a temporary object that allows to query the location of the specified identifier in several programs. The returned object has two functions called In and And which are equivalent and take a Program as the argument. Both these functions return in turn a new instance of the temporary which allows to check in another program, and so on. The temporary is also convertible to bool indicating whether a common location was found in all programs in the chain.

Buffer buf;
Program prog1, prog2, prog3, prog4;
// build the programs, load data into the buffer, ...
vao.Bind();
buffer.Bind(Buffer::Target::Array);
VertexAttribSlot loc;
if(VertexAttribOps::QueryCommonLocation("Pos", loc)
.In(prog1).In(prog2).In(prog3).And(prog4)
)
{
VertexAttribArray attr(location);
attr.Setup(n_per_vertex, DataType::Float);
attr.Enable();
}
else
{
// handle the error or bind the locations manually
}
Note
Never store the resulting object in a named variable nor use it after the call to this overload of QueryCommonLocation has finished. Doing this causes undefined behavior.
See Also
GetLocation
GetCommonLocation
QueryLocation
BindLocation
Related OpenGL symbols:
glGetAttribLocation
template<typename... ProgramOps_>
static bool oglplus::VertexAttribOps::QueryCommonLocation ( const GLchar *  identifier,
VertexAttribSlot location,
const ProgramOps program,
const ProgramOps_ &...  programs 
)
staticinherited

Queries the vertex attribute location in multiple programs.

Finds the location of the input vertex attribute specified by identifier in every program in programs. Returns false if no such attribute exists or if it is not active in some of the programs or if the attribute has different locations in different programs. Otherwise stores the vertex attribute position in location and returns true.

See Also
GetLocation
GetCommonLocation
QueryLocation
BindLocation
Related OpenGL symbols:
glGetAttribLocation
static bool oglplus::VertexAttribOps::QueryLocation ( const ProgramOps program,
const String identifier,
VertexAttribSlot location 
)
staticinherited

Queries the vertex attribute location in a program.

Finds the location of the input vertex attribute specified by identifier in a program. Returns false if no such attribute exists or if it is not active, otherwise stores the vertex attribute position in location and returns true. For a throwing version see GetLocation().

See Also
GetLocation
GetCommonLocation
QueryCommonLocation
BindLocation
Related OpenGL symbols:
glGetAttribLocation
template<typename T >
void oglplus::VertexAttrib< T >::Set ( T  value) const

Set the value of the vertex attribute.

Related OpenGL symbols:
glVertexAttrib

Referenced by oglplus::VertexAttrib< T >::operator=().


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

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Wed Apr 30 2014 by Doxygen (version 1.8.4).