OGLplus (0.45.0) a C++ wrapper for OpenGL

Encapsulates vertex attribute array functionality. More...

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

Inheritance diagram for oglplus::VertexAttribArray:
Collaboration diagram for oglplus::VertexAttribArray:

Public Member Functions

 VertexAttribArray (VertexAttribSlot location)
 References the vertex attribute array at location. More...
 
 VertexAttribArray (const ProgramOps &program, const GLchar *identifier)
 References the vertex attrib array identifier of the program. More...
 
 VertexAttribArray (const ProgramOps &program, const String &identifier)
 References the vertex attrib array identifier of the program. More...
 
const VertexAttribArraySetup (GLint values_per_vertex, DataType data_type) const
 Setup the properties of this vertex attribute array. More...
 
template<typename T >
const VertexAttribArraySetup (GLuint n=1) const
 Setup the properties of this vertex attribute array. More...
 
const VertexAttribArrayPointer (GLint values_per_vertex, DataType data_type, bool normalized, GLsizei stride, const void *pointer) const
 Setup the properties of this vertex attribute array. More...
 
const VertexAttribArrayIPointer (GLuint values_per_vertex, DataType data_type, GLsizei stride, const void *pointer) const
 Setup the properties of this vertex attribute array. More...
 
const VertexAttribArrayLPointer (GLuint values_per_vertex, DataType data_type, GLsizei stride, const void *pointer) const
 Setup the properties of this vertex attribute array. More...
 
const VertexAttribArrayFormat (GLint values_per_vertex, DataType data_type, bool normalized, GLuint relative_offset) const
 Setup the format of this vertex attribute array. More...
 
const VertexAttribArrayIFormat (GLint values_per_vertex, DataType data_type, GLuint relative_offset) const
 Setup the format of this vertex attribute array. More...
 
const VertexAttribArrayLFormat (GLint values_per_vertex, DataType data_type, GLuint relative_offset) const
 Setup the format of this vertex attribute array. More...
 
const VertexAttribArrayEnable (void) const
 Enables this vertex attribute array. More...
 
const VertexAttribArrayDisable (void) const
 Disables this vertex attribute array. 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

Constructor & Destructor Documentation

oglplus::VertexAttribArray::VertexAttribArray ( VertexAttribSlot  location)

References the vertex attribute array at location.

Related OpenGL symbols:
glGetAttribLocation
oglplus::VertexAttribArray::VertexAttribArray ( const ProgramOps program,
const GLchar *  identifier 
)

References the vertex attrib array identifier of the program.

Related OpenGL symbols:
glGetAttribLocation
oglplus::VertexAttribArray::VertexAttribArray ( const ProgramOps program,
const String identifier 
)

References the vertex attrib array 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.

const VertexAttribArray& oglplus::VertexAttribArray::Disable ( void  ) const

Disables this vertex attribute array.

Related OpenGL symbols:
glDisableVertexAttribArray

References OGLPLUS_VERIFY.

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

Set the vertex attrib divisor.

Requires OpenGL 3.3.

Related OpenGL symbols:
glVertexAttribDivisor

References OGLPLUS_CHECK.

const VertexAttribArray& oglplus::VertexAttribArray::Format ( GLint  values_per_vertex,
DataType  data_type,
bool  normalized,
GLuint  relative_offset 
) const

Setup the format of this vertex attribute array.

Related OpenGL symbols:
glVertexAttribFormat

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
const VertexAttribArray& oglplus::VertexAttribArray::IFormat ( GLint  values_per_vertex,
DataType  data_type,
GLuint  relative_offset 
) const

Setup the format of this vertex attribute array.

Related OpenGL symbols:
glVertexAttribIFormat

References OGLPLUS_CHECK.

const VertexAttribArray& oglplus::VertexAttribArray::IPointer ( GLuint  values_per_vertex,
DataType  data_type,
GLsizei  stride,
const void *  pointer 
) const

Setup the properties of this vertex attribute array.

Related OpenGL symbols:
glVertexAttribPointer

References OGLPLUS_CHECK.

const VertexAttribArray& oglplus::VertexAttribArray::LFormat ( GLint  values_per_vertex,
DataType  data_type,
GLuint  relative_offset 
) const

Setup the format of this vertex attribute array.

Related OpenGL symbols:
glVertexAttribLFormat

References OGLPLUS_CHECK.

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
const VertexAttribArray& oglplus::VertexAttribArray::LPointer ( GLuint  values_per_vertex,
DataType  data_type,
GLsizei  stride,
const void *  pointer 
) const

Setup the properties of this vertex attribute array.

Related OpenGL symbols:
glVertexAttribPointer

References OGLPLUS_CHECK.

const VertexAttribArray& oglplus::VertexAttribArray::Pointer ( GLint  values_per_vertex,
DataType  data_type,
bool  normalized,
GLsizei  stride,
const void *  pointer 
) const

Setup the properties of this vertex attribute array.

Related OpenGL symbols:
glVertexAttribPointer

References OGLPLUS_CHECK.

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
const VertexAttribArray& oglplus::VertexAttribArray::Setup ( GLint  values_per_vertex,
DataType  data_type 
) const

Setup the properties of this vertex attribute array.

Equivalent to

Pointer(valuer_per_vertex, data_type, false, 0, NULL)

if data_type is DataType::Float or to

LPointer(valuer_per_vertex, data_type, 0, NULL)

if data_type is DataType::Double or to

IPointer(valuer_per_vertex, data_type, 0, NULL)

otherwise.

Note
Consider using the templated version of Setup(), because it is more portable. For example instead of:
attr.Setup(3, DataType::Float);
use
attr.Setup<Vec3f>();
or
attr.Setup<GLfloat>(3);
See Also
Pointer
IPointer
LPointer
Related OpenGL symbols:
glVertexAttribPointer
Examples:
standalone/001_triangle_glut_gles3.cpp, standalone/001_triangle_glut_glew.cpp, standalone/001_triangle_screenshot.cpp, standalone/001_triangle_sdl_glew.cpp, standalone/001_triangle_wxgl_glew.cpp, standalone/007_glm_boxes.cpp, and standalone/026_blender_mesh_loader.cpp.

References oglplus::Double, and oglplus::Float.

template<typename T >
const VertexAttribArray& oglplus::VertexAttribArray::Setup ( GLuint  n = 1) const

Setup the properties of this vertex attribute array.

See Also
Pointer
IPointer
LPointer
Related OpenGL symbols:
glVertexAttribPointer

References oglplus::T.


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).