mIndexBuffer->BindBuffer( context, program );
}
-// BindBuffers( context, bufferIndex, program );
-// EnableVertexAttributes( context, bufferIndex, program );
Draw( context, bufferIndex, dataProviders );
for( unsigned int i = 0; i < mVertexBuffers.Count(); ++i )
{
mVertexBuffers[i]->DisableVertexAttributes( context, bufferIndex, program );
}
- //DisableVertexAttributes( context, bufferIndex, program );
}
void RenderGeometry::GeometryUpdated()
BufferIndex bufferIndex,
const RenderDataProvider* dataProviders )
{
- if( mDataNeedsUploading ) // @todo Or if any of the property buffers are dirty
+ if( mDataNeedsUploading )
{
- DoUpload( context, bufferIndex, dataProviders );
+ SetUpPropertyBuffers( context, bufferIndex, dataProviders );
+
+ for( unsigned int i = 0; i < mVertexBuffers.Count(); ++i )
+ {
+ mVertexBuffers[i]->Upload( context, bufferIndex );
+ }
+ if( mIndexBuffer )
+ {
+ mIndexBuffer->Upload( context, bufferIndex );
+ }
mDataNeedsUploading = false;
}
}
-void RenderGeometry::DoUpload(
+void RenderGeometry::SetUpPropertyBuffers(
Context& context,
BufferIndex bufferIndex,
const RenderDataProvider* dataProvider )
{
const PropertyBufferDataProvider* vertexBuffer = vertexBuffers[i];
- RenderPropertyBuffer* propertyBuffer = new RenderPropertyBuffer( *vertexBuffer, false );
-
- propertyBuffer->DoUpload( context, bufferIndex );
+ RenderPropertyBuffer* propertyBuffer = new RenderPropertyBuffer(
+ *vertexBuffer,
+ GpuBuffer::ARRAY_BUFFER,
+ GpuBuffer::STATIC_DRAW ); // TODO: MESH_REWORK: change this for animated meshes
mVertexBuffers.PushBack( propertyBuffer );
}
const PropertyBufferDataProvider* indexBuffer = dataProvider->GetIndexBuffer();
if( indexBuffer )
{
- mIndexBuffer = new RenderPropertyBuffer( *indexBuffer, true );
-
- mIndexBuffer->DoUpload( context, bufferIndex );
+ mIndexBuffer = new RenderPropertyBuffer(
+ *indexBuffer,
+ GpuBuffer::ELEMENT_ARRAY_BUFFER,
+ GpuBuffer::STATIC_DRAW ); // TODO: MESH_REWORK: change this for animated meshes
}
}
unsigned int numIndices = 0;
if( indexBuffer )
{
- numIndices = /* TODO: MESH_REWORK remove this 2, should implement unsigned short properties */ 2 * indexBuffer->GetDataSize(bufferIndex) / indexBuffer->GetElementSize(bufferIndex);
+ numIndices = indexBuffer->GetDataSize(bufferIndex) / indexBuffer->GetElementSize(bufferIndex);
}
switch(type)
{
case Dali::Geometry::TRIANGLES:
{
- context.DrawElements(GL_TRIANGLES, numIndices, GL_UNSIGNED_SHORT, 0);
+ if( numIndices )
+ {
+ context.DrawElements(GL_TRIANGLES, numIndices, GL_UNSIGNED_SHORT, 0);
+ }
+ else
+ {
+ const PropertyBufferDataProvider* firstVertexBuffer = dataProvider->GetVertexBuffers()[0];
+ unsigned int numVertices = firstVertexBuffer->GetElementCount( bufferIndex );
+ context.DrawArrays( GL_TRIANGLES, 0, numVertices );
+ }
break;
}
case Dali::Geometry::LINES:
{
- context.DrawElements(GL_LINES, numIndices, GL_UNSIGNED_SHORT, 0);
+ if( numIndices )
+ {
+ context.DrawElements(GL_LINES, numIndices, GL_UNSIGNED_SHORT, 0);
+ }
+ else
+ {
+ const PropertyBufferDataProvider* firstVertexBuffer = dataProvider->GetVertexBuffers()[0];
+ unsigned int numVertices = firstVertexBuffer->GetElementCount( bufferIndex );
+ context.DrawArrays( GL_LINES, 0, numVertices );
+ }
break;
}
case Dali::Geometry::POINTS:
{
const PropertyBufferDataProvider* firstVertexBuffer = dataProvider->GetVertexBuffers()[0];
-
unsigned int numVertices = firstVertexBuffer->GetElementCount( bufferIndex );
context.DrawArrays(GL_POINTS, 0, numVertices );
break;