Game Development Reference
In-Depth Information
LGL3->glVertexAttribPointer( i,
L_VS_VEC_COMPONENTS[ i ],
GL_FLOAT, GL_FALSE, 0,
FAttribVBOOffset[ i ] );
FAttribVBOOffset[ i ] ?
LGL3->glEnableVertexAttribArray( i ) :
LGL3->glDisableVertexAttribArray( i );
}
}
Now we can render the geometry via the Draw() method:
void clGLVertexArray::Draw( bool Wireframe ) const
{
#if !defined( ANDROID )
LGL3->glBindVertexArray( FVAOID );
#else
Bind();
#endif
LGL3->glDrawArrays( Wireframe ? GL_LINE_LOOP : GL_TRIANGLES,
0, static_cast<GLsizei>(
FAttribs->GetActiveVertexCount() ) );
}
Again, there is #define to disable VAO on Android. The following is a screenshot of the 3_
ShadersAndVertexArrays example, which renders an animated rotating cube using the
techniques from all of the previous recipes in this chapter:
There's moreā€¦
We always assume that every vertex attribute (position, texture coordinate, normal, and
color) exists in the geometry data in all of our examples. Indeed, this is always true for our
implementation of clVertexAttribs . However, in more complicated cases, where you
might need many more vertex attributes, for example, binormals, tangents, bone weights, and
so on, it is wise not to allocate memory for unused attributes. This can be done by modifying
the clVertexAttribs::EnumerateVertexStreams() member function and adding
NULL-checks to Bind() and SetVertexAttribs() .
 
Search WWH ::




Custom Search