示例#1
0
float* GeometryBuffer::getAttribute(VertexAttribute attribute, uint32 i) const
{
	VertexElement* elem = declarations.find(attribute);
	if( !elem ) return nullptr;

	if(elem->stride == 0)
	{
		uint8 elemSize = elem->getSize();

		const uint8* loc = &data.front() + elem->offset + (elemSize * i);
		return (float*) loc;
	}

	// Calculate the starting position of the attribute data.
	uint8 totalSize = declarations.getVertexSize();
	uint8 localOffset = declarations.getOffset(elem->attribute);

	// TODO: Check the bounds and return null in that case too.

	const uint8* loc = &data.front() + (totalSize * i) + localOffset;
	return (float*) loc;
}
示例#2
0
void VertexDeclaration::add( const VertexElement& element ) {
	_stride += element.getSize();
	_elements.push_back(element);
}