Cinder  0.9.1
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cinder::gl::VertBatch Class Reference

#include <Batch.h>

Inherits cinder::geom::Source.

Public Member Functions

 VertBatch (GLenum primType=GL_POINTS, bool useContextDefaultBuffers=true)
 
void setType (GLenum type)
 
GLenum getType () const
 
void color (float r, float g, float b, float a=1.0f)
 
void color (const Colorf &color)
 
void color (const ColorAf &color)
 
void normal (float x, float y, float z)
 
void normal (const vec3 &n)
 
void texCoord (float s, float t, float r=0, float q=1)
 
void texCoord (const vec2 &t)
 
void texCoord (const vec3 &t)
 
void texCoord (const vec4 &t)
 
void texCoord0 (float s, float t, float r=0, float q=1)
 
void texCoord0 (const vec2 &t)
 
void texCoord0 (const vec3 &t)
 
void texCoord0 (const vec4 &t)
 
void texCoord1 (float s, float t, float r=0, float q=1)
 
void texCoord1 (const vec2 &t)
 
void texCoord1 (const vec3 &t)
 
void texCoord1 (const vec4 &t)
 
void vertex (float x, float y, float z=0, float w=1)
 
void vertex (const vec2 &v)
 
void vertex (const vec3 &v)
 
void vertex (const vec4 &v)
 
void vertex (const vec4 &v, const ColorAf &c)
 
void begin (GLenum type)
 
void end ()
 
void clear ()
 
bool empty () const
 
void draw ()
 

Static Public Member Functions

static VertBatchRef create (GLenum primType=GL_POINTS, bool useContextDefaultBuffers=false)
 

Protected Member Functions

void addVertex (const vec4 &v)
 
void setupBuffers ()
 
size_t getNumVertices () const override
 
size_t getNumIndices () const override
 
geom::Primitive getPrimitive () const override
 
uint8_t getAttribDims (geom::Attrib attr) const override
 
void loadInto (geom::Target *target, const geom::AttribSet &requestedAttribs) const override
 
VertBatchclone () const override
 
geom::AttribSet getAvailableAttribs () const override
 
void copyIndicesNonIndexed (uint16_t *dest) const
 
void copyIndicesNonIndexed (uint32_t *dest) const
 
template<typename T >
void forceCopyIndicesTrianglesImpl (T *dest) const
 

Protected Attributes

GLenum mPrimType
 
std::vector< vec4 > mVertices
 
std::vector< vec3 > mNormals
 
std::vector< ColorAfmColors
 
std::vector< vec4 > mTexCoords0
 
std::vector< vec4 > mTexCoords1
 
bool mOwnsBuffers
 
bool mForceUpdate
 
VaomVao
 
VaoRef mVaoStorage
 
VboRef mVbo
 

Detailed Description

Allows simple creation of basic geometry in a style similar to OpenGL immediate mode. Can be used to construct a gl::Batch for better performance, or can draw() directly. Used with a series of calls to color(), normal(), and/or texCoord(), followed by a call to vertex(), per-vertex.

Constructor & Destructor Documentation

cinder::gl::VertBatch::VertBatch ( GLenum  primType = GL_POINTS,
bool  useContextDefaultBuffers = true 
)

Constructs a VertBatch with primitive type primType. Default is GL_POINTS. If useContextDefaultBuffers is true, uses default buffers for the context, saving allocations; suitable for single draw.

Member Function Documentation

VertBatchRef cinder::gl::VertBatch::create ( GLenum  primType = GL_POINTS,
bool  useContextDefaultBuffers = false 
)
static

Creates a VertBatchRef with primitive type primType. Default is GL_POINTS. If useContextDefaultBuffers is false, allocates and uses internal buffers and VAO; suitable for multiple draws.

void cinder::gl::VertBatch::setType ( GLenum  type)

Sets the primitive type of the VertBatch. Default is GL_POINTS.

GLenum cinder::gl::VertBatch::getType ( ) const

Returns the primitive type of the VertBatch. Default is GL_POINTS.

void cinder::gl::VertBatch::color ( float  r,
float  g,
float  b,
float  a = 1.0f 
)

Sets the color for the current vertex (attribute geom::COLOR)

void cinder::gl::VertBatch::color ( const Colorf color)

Sets the color for the current vertex (attribute geom::COLOR)

void cinder::gl::VertBatch::color ( const ColorAf color)

Sets the color for the current vertex (attribute geom::COLOR)

void cinder::gl::VertBatch::normal ( float  x,
float  y,
float  z 
)

Sets the normal for the current vertex (attribute geom::NORMAL)

void cinder::gl::VertBatch::normal ( const vec3 &  n)

Sets the normal for the current vertex (attribute geom::NORMAL)

void cinder::gl::VertBatch::texCoord ( float  s,
float  t,
float  r = 0,
float  q = 1 
)

Sets the texCoord0 for the current vertex (attribute geom::TEX_COORD_0)

void cinder::gl::VertBatch::texCoord ( const vec2 &  t)

Sets the texCoord0 for the current vertex (attribute geom::TEX_COORD_0)

void cinder::gl::VertBatch::texCoord ( const vec3 &  t)

Sets the texCoord0 for the current vertex (attribute geom::TEX_COORD_0)

void cinder::gl::VertBatch::texCoord ( const vec4 &  t)

Sets the texCoord0 for the current vertex (attribute geom::TEX_COORD_0)

void cinder::gl::VertBatch::texCoord0 ( float  s,
float  t,
float  r = 0,
float  q = 1 
)

Sets the texCoord0 for the current vertex (attribute geom::TEX_COORD_0)

void cinder::gl::VertBatch::texCoord0 ( const vec2 &  t)

Sets the texCoord0 for the current vertex (attribute geom::TEX_COORD_0)

void cinder::gl::VertBatch::texCoord0 ( const vec3 &  t)

Sets the texCoord0 for the current vertex (attribute geom::TEX_COORD_0)

void cinder::gl::VertBatch::texCoord0 ( const vec4 &  t)

Sets the texCoord0 for the current vertex (attribute geom::TEX_COORD_0)

void cinder::gl::VertBatch::texCoord1 ( float  s,
float  t,
float  r = 0,
float  q = 1 
)

Sets the texCoord1 for the current vertex (attribute geom::TEX_COORD_1)

void cinder::gl::VertBatch::texCoord1 ( const vec2 &  t)

Sets the texCoord1 for the current vertex (attribute geom::TEX_COORD_1)

void cinder::gl::VertBatch::texCoord1 ( const vec3 &  t)

Sets the texCoord1 for the current vertex (attribute geom::TEX_COORD_1)

void cinder::gl::VertBatch::texCoord1 ( const vec4 &  t)

Sets the texCoord1 for the current vertex (attribute geom::TEX_COORD_1)

void cinder::gl::VertBatch::vertex ( float  x,
float  y,
float  z = 0,
float  w = 1 
)

Locks the values for the current vertex and sets its position (attribute geom::POSITION). Call after any corresponding calls to color(), normal() and/or texCoord().

void cinder::gl::VertBatch::vertex ( const vec2 &  v)

Locks the values for the current vertex and sets its position (attribute geom::POSITION). Call after any corresponding calls to color(), normal() and/or texCoord().

void cinder::gl::VertBatch::vertex ( const vec3 &  v)

Locks the values for the current vertex and sets its position (attribute geom::POSITION). Call after any corresponding calls to color(), normal() and/or texCoord().

void cinder::gl::VertBatch::vertex ( const vec4 &  v)

Locks the values for the current vertex and sets its position (attribute geom::POSITION). Call after any corresponding calls to color(), normal() and/or texCoord().

void cinder::gl::VertBatch::vertex ( const vec4 &  v,
const ColorAf c 
)

Locks the values for the current vertex and sets its position (attribute geom::POSITION) and color (geom::COLOR). Call after any corresponding calls to color(), normal() and/or texCoord(). Should not be called if you have called color() prior.

void cinder::gl::VertBatch::begin ( GLenum  type)

Resets the sequence of vertices and sets the VertBatch's primitive type.

void cinder::gl::VertBatch::end ( )

No-op. Present for parity with legacy immediate mode.

void cinder::gl::VertBatch::clear ( )

Clears all vertices recorded by the VertBatch.

bool cinder::gl::VertBatch::empty ( ) const

Returns true if no vertices have been added to the VertBatch.

void cinder::gl::VertBatch::draw ( )

Draws the VertBatch using the gl::Context's currently active shader. For multiple draws consider constructing a gl::Batch using the VertBatch instead.

void cinder::gl::VertBatch::addVertex ( const vec4 &  v)
protected
void cinder::gl::VertBatch::setupBuffers ( )
protected
size_t cinder::gl::VertBatch::getNumVertices ( ) const
overrideprotectedvirtual

Implements cinder::geom::Source.

size_t cinder::gl::VertBatch::getNumIndices ( ) const
overrideprotectedvirtual

Implements cinder::geom::Source.

geom::Primitive cinder::gl::VertBatch::getPrimitive ( ) const
overrideprotectedvirtual

Implements cinder::geom::Source.

uint8_t cinder::gl::VertBatch::getAttribDims ( geom::Attrib  attr) const
overrideprotectedvirtual

Implements cinder::geom::Source.

void cinder::gl::VertBatch::loadInto ( geom::Target target,
const geom::AttribSet requestedAttribs 
) const
overrideprotectedvirtual

Implements cinder::geom::Source.

VertBatch* cinder::gl::VertBatch::clone ( ) const
overrideprotectedvirtual

Implements cinder::geom::Source.

geom::AttribSet cinder::gl::VertBatch::getAvailableAttribs ( ) const
overrideprotectedvirtual

Implements cinder::geom::Source.

void cinder::geom::Source::copyIndicesNonIndexed ( uint16_t *  dest) const
protectedinherited

Builds a sequential list of vertices to simulate an indexed geometry when Source is non-indexed. Assumes dest contains storage for getNumVertices() entries.

void cinder::geom::Source::copyIndicesNonIndexed ( uint32_t *  dest) const
protectedinherited

Builds a sequential list of vertices to simulate an indexed geometry when Source is non-indexed. Assumes dest contains storage for getNumVertices() entries.

template<typename T >
void cinder::geom::Source::forceCopyIndicesTrianglesImpl ( T *  dest) const
protectedinherited

Member Data Documentation

GLenum cinder::gl::VertBatch::mPrimType
protected
std::vector<vec4> cinder::gl::VertBatch::mVertices
protected
std::vector<vec3> cinder::gl::VertBatch::mNormals
protected
std::vector<ColorAf> cinder::gl::VertBatch::mColors
protected
std::vector<vec4> cinder::gl::VertBatch::mTexCoords0
protected
std::vector<vec4> cinder::gl::VertBatch::mTexCoords1
protected
bool cinder::gl::VertBatch::mOwnsBuffers
protected
bool cinder::gl::VertBatch::mForceUpdate
protected
Vao* cinder::gl::VertBatch::mVao
protected
VaoRef cinder::gl::VertBatch::mVaoStorage
protected
VboRef cinder::gl::VertBatch::mVbo
protected

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