- elementBufferCount = 0 states for whole or remaining buffer from elementBufferOffset.
Added two test cases covering that issue ( going out of bounds of the index buffer andusing 0 as number of elements )
Change-Id: I5d29401a3c2d717d173ce63a9cc9ba3b2ecb0e64
DALI_TEST_CHECK( result );
}
+ // Index out of bounds
+ {
+ renderer.SetIndexRange( 15, 30 );
+ geometry.SetGeometryType( Geometry::LINE_STRIP );
+ sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
+ application.SendNotification();
+ application.Render();
+ bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
+ DALI_TEST_CHECK( result );
+ }
+
+ // drawing whole buffer starting from 15 ( last valid primitive )
+ {
+ renderer.SetIndexRange( 15, 0 );
+ geometry.SetGeometryType( Geometry::LINE_STRIP );
+ sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
+ application.SendNotification();
+ application.Render();
+ bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
+ DALI_TEST_CHECK( result );
+ }
+
END_TEST;
}
base += mVertexBuffers[i]->EnableVertexAttributes( context, attributeLocation, base );
}
- GLenum geometryGLType(0);
- unsigned int numIndices(0u);
+ size_t numIndices(0u);
intptr_t firstIndexOffset(0u);
if( mIndexBuffer )
{
numIndices = mIndices.Size();
- if( elementBufferOffset )
+ if( elementBufferOffset != 0u )
{
- elementBufferOffset = elementBufferOffset >= numIndices ? numIndices- 1 : elementBufferOffset;
+ elementBufferOffset = elementBufferOffset >= numIndices ? numIndices - 1 : elementBufferOffset;
firstIndexOffset = elementBufferOffset * sizeof(GLushort);
+ numIndices -= elementBufferOffset;
}
- if ( elementBufferCount )
+
+ if( elementBufferCount != 0u )
{
- numIndices = std::min( elementBufferCount, numIndices - elementBufferOffset );
+ numIndices = std::min( elementBufferCount, numIndices );
}
}
+ GLenum geometryGLType(GL_NONE);
switch(mGeometryType)
{
case Dali::Geometry::TRIANGLES:
geometryGLType = GL_LINE_STRIP;
break;
}
- default:
- {
- DALI_ASSERT_ALWAYS( 0 && "Geometry type not supported (yet)" );
- break;
- }
}
//Draw call
* @param[in] bufferIndex The current buffer index
* @param[in] attributeLocation The location for the attributes in the shader
* @param[in] elementBufferOffset The index of first element to draw if index buffer bound
- * @param[in] elementBufferCount Number of elements to draw if index buffer bound
+ * @param[in] elementBufferCount Number of elements to draw if index buffer bound, uses whole buffer when 0
*/
void UploadAndDraw(Context& context,
BufferIndex bufferIndex,