Unofficial OpenGL Software Development Kit  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
List of all members | Public Member Functions
glmesh::VertexFormat::Enable Class Reference

#include <VertexFormat.h>

Inherits noncopyable.

RAII-style class for binding a VertexFormat to the OpenGL context.

The constructors of this class call VertexFormat::BindAttributes or VertexFormat::BindAttribFormat, as appropriate. The destructor calls VertexFormat::DisableAttributes.

This class can use the ARB_vertex_attrib_binding functionality instead of glVertexAttribPointer. If you do, then this class only changes the vertex format state, not the buffer binding state. That is, it will call glEnable/DisableVertexAttrbiArray and `glVertexAttribFormat`, but not glVertexAttribBinding, glBindVertexBuffer, or glVertexBindingDivisor.

Note that all of the attributes will still have the same stride, and the offsets will be computed as though it all comes from a single buffer. You can use multiple separate VertexFormat objects if you want to have different buffers with different attributes for the same mesh.

If you are not using ARB_vertex_attrib_binding, then this class assumes that all vertex data comes from the buffer currently bound to GL_ARRAY_BUFFER.

The constructors have the effect of calling VertexFormat::BindAttributes or VertexFormat::BindAttributeFormats, as appropriate. Those functions define the OpenGL state that will be changed. The destructor will call VertexFormat::DisableAttributes.

Assuming all of your buffer setup is in order (ie: if you're using separate attribute formats, you have bound a buffer and set the attribute binding), you can use any OpenGL rendering functions to render using the VertexFormat given.

Public Member Functions

 Enable (const VertexFormat &fmt, size_t baseOffset)
 Binds the vertex format to the OpenGL context, given a byte offset to the first vertex. More...
 
 Enable (const VertexFormat &fmt, GLuint bindingIndex, SeparateAttribFormatTag)
 Binds the vertex format to the OpenGL context, using ARB_vertex_attrib_binding. More...
 
 ~Enable ()
 Unbinds the vertex format by calling VertexFormat::DisableAttributes.
 

Constructor & Destructor Documentation

glmesh::VertexFormat::Enable::Enable ( const VertexFormat fmt,
size_t  baseOffset 
)

Binds the vertex format to the OpenGL context, given a byte offset to the first vertex.

Calls VertexFormat::BindAttributes on fmt.

glmesh::VertexFormat::Enable::Enable ( const VertexFormat fmt,
GLuint  bindingIndex,
SeparateAttribFormatTag   
)

Binds the vertex format to the OpenGL context, using ARB_vertex_attrib_binding.

Calls VertexFormat::BindAttribFormat on fmt. You are expected to make the appropriate glBindVertexBuffer calls for the buffer yourself.

To call this function, pass glmesh::sepFormat as the third parameter (or a default-constructed object).

Note
No exception will be thrown if ARB_vertex_attrib_format or GL 4.3 are not available.

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