overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Classes | Public Member Functions | Static Public Member Functions
gameplay::VertexAttributeBinding Class Reference

#include <VertexAttributeBinding.h>

Inheritance diagram for gameplay::VertexAttributeBinding:
gameplay::Ref

List of all members.

Classes

class  VertexAttribute

Public Member Functions

void bind ()
void unbind ()

Static Public Member Functions

static VertexAttributeBindingcreate (Mesh *mesh, Effect *effect)
static VertexAttributeBindingcreate (const VertexFormat &vertexFormat, void *vertexPointer, Effect *effect)

Detailed Description

Defines a binding between the vertex layout of a Mesh and the vertex input attributes of a vertex shader (Effect).

In a perfect world, this class would always be a binding directly between a unique VertexFormat and an Effect, where the VertexFormat is simply the definition of the layout of any anonymous vertex buffer. However, the OpenGL mechanism for setting up these bindings is Vertex Array Objects (VAOs). OpenGL requires a separate VAO per vertex buffer object (VBO), rather than per vertex layout definition. Therefore, although we would like to define this binding between a VertexFormat and Effect, we are specifying the binding between a Mesh and Effect to satisfy the OpenGL requirement of one VAO per VBO.

Note that this class still does provide a binding between a VertexFormat and an Effect, however this binding is actually a client-side binding and should only be used when writing custom code that use client-side vertex arrays, since it is slower than the server-side VAOs used by OpenGL (when creating a VertexAttributeBinding between a Mesh and Effect).


Member Function Documentation

Binds this vertex array object.

static VertexAttributeBinding* gameplay::VertexAttributeBinding::create ( Mesh mesh,
Effect effect 
) [static]

Creates a new VertexAttributeBinding between the given Mesh and Effect.

If a VertexAttributeBinding matching the specified Mesh and Effect already exists, it will be returned. Otherwise, a new VertexAttributeBinding will be returned. If OpenGL VAOs are enabled, the a new VAO will be created and stored in the returned VertexAttributeBinding, otherwise a client-side array of vertex attribute bindings will be stored.

Parameters:
meshThe mesh.
effectThe effect.
Returns:
A VertexAttributeBinding for the requested parameters.
static VertexAttributeBinding* gameplay::VertexAttributeBinding::create ( const VertexFormat vertexFormat,
void *  vertexPointer,
Effect effect 
) [static]

Creates a client-side vertex attribute binding.

This method creates a client-side vertex attribute binding, which is simply a cached set of parameters that need to be passed to the renderer to setup vertex attribute bindings between a vertex buffer and a vertex shader. The specified vertexPointer is a client-side block of memory that contains the vertices to be send to the renderer, formatted as indicated in the specified vertexFormat parameter.

Parameters:
vertexFormatThe vertex format.
vertexPointerPointer to beginning of client-side vertex array.
effectThe effect.
Returns:
A VertexAttributeBinding for the requested parameters.

Unbinds this vertex array object.

 All Classes Functions Variables Typedefs Enumerations Enumerator