예제 #1
0
void HexagonMirrorApp::drawInstanced( const gl::VboMesh &vbo, size_t instanceCount )
{
    if( vbo.getNumIndices() > 0 )
        drawRangeInstanced( vbo, (size_t)0, vbo.getNumIndices(), instanceCount );
    else
        drawArraysInstanced( vbo, 0, vbo.getNumVertices(), instanceCount );
}
예제 #2
0
void HexagonMirrorApp::drawRangeInstanced( const gl::VboMesh &vbo, size_t startIndex, size_t indexCount, size_t instanceCount )
{
    if( vbo.getNumIndices() <= 0 )
        return;

    vbo.enableClientStates();
    vbo.bindAllData();

#if( defined GLEE_ARB_draw_instanced )
    glDrawElementsInstancedARB( vbo.getPrimitiveType(), indexCount, GL_UNSIGNED_INT, (GLvoid*)( sizeof(uint32_t) * startIndex ), instanceCount );
#elif( defined GLEE_EXT_draw_instanced )
    glDrawElementsInstancedEXT( vbo.getPrimitiveType(), indexCount, GL_UNSIGNED_INT, (GLvoid*)( sizeof(uint32_t) * startIndex ), instanceCount );
#else
    // fall back to rendering a single instance
    glDrawElements( vbo.getPrimitiveType(), indexCount, GL_UNSIGNED_INT, (GLvoid*)( sizeof(uint32_t) * startIndex ) );
#endif

    gl::VboMesh::unbindBuffers();
    vbo.disableClientStates();
}