Game Development Reference
In-Depth Information
VertexCount : 0;
}
LGL3->glGenBuffers( 1, &FVBOID );
LGL3->glBindBuffer( GL_ARRAY_BUFFER, FVBOID );
LGL3->glBufferData( GL_ARRAY_BUFFER, DataSize,
NULL, GL_STREAM_DRAW );
7.
Submit data for every vertex attribute:
for ( int i = 0; i != L_VS_TOTAL_ATTRIBS; i++ )
{
LGL3->glBufferSubData( GL_ARRAY_BUFFER,
(GLintptrARB)FAttribVBOOffset[ i ],
FAttribs->GetActiveVertexCount() *
sizeof( float ) * L_VS_VEC_COMPONENTS[ i ],
FEnumeratedStreams[ i ] );
}
8.
Here we create VAO if we are not on Android:
#if !defined( ANDROID )
LGL3->glBindVertexArray( FVAOID );
Bind();
LGL3->glBindVertexArray( 0 );
#endif
}
VAOs can be used with OpenGL ES 3. We leave their implementation as
a simple exercise to the reader. This can be done by using the OpenGL 3
code path for OpenGL ES 3.
How it works…
The Bind() method does the actual job of binding the vertex buffer object and preparing the
attribute pointers:
void clGLVertexArray::Bind() const
{
LGL3->glBindBuffer( GL_ARRAY_BUFFER, FVBOID );
LGL3->glVertexAttribPointer( L_VS_VERTEX,
L_VS_VEC_COMPONENTS[ 0 ], GL_FLOAT, GL_FALSE, 0,
FAttribVBOOffset[ 0 ] );
LGL3->glEnableVertexAttribArray( L_VS_VERTEX );
for ( int i = 1; i < L_VS_TOTAL_ATTRIBS; i++ )
{
 
Search WWH ::




Custom Search