}
);
-PropertyBuffer CreateIndexBuffer( Geometry::GeometryType geometryType )
-{
- // Create indices
- const unsigned int indexDataLines[] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 0 };
- const unsigned int indexDataLoops[] = { 0, 1, 2, 3, 4 };
- const unsigned int indexDataStrips[] = { 0, 1, 2, 3, 4, 0 };
-
- // Create index buffer if doesn't exist
- Property::Map indexFormat;
- indexFormat["indices"] = Property::INTEGER;
- PropertyBuffer indices = PropertyBuffer::New( indexFormat );
-
- // Update buffer
- switch( geometryType )
- {
- case Geometry::LINES:
- {
- indices.SetData( indexDataLines, sizeof(indexDataLines)/sizeof(indexDataLines[0]) );
- break;
- }
- case Geometry::LINE_LOOP:
- {
- indices.SetData( indexDataLoops, sizeof(indexDataLoops)/sizeof(indexDataLoops[0]) );
- break;
- }
- case Geometry::LINE_STRIP:
- {
- indices.SetData( indexDataStrips, sizeof(indexDataStrips)/sizeof(indexDataStrips[0]) );
- break;
- }
- default: // this will never happen, but compilers yells
- {
- }
- }
-
- return indices;
-}
+const unsigned short indexLines[] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 0 };
+const unsigned short indexLoop[] = { 0, 1, 2, 3, 4 };
+const unsigned short indexStrip[] = { 0, 1, 2, 3, 4, 0 };
+const unsigned short* indices[3] = { &indexLines[0], &indexLoop[0], &indexStrip[0] };
+const unsigned int indicesSize[3] = { sizeof(indexLines)/sizeof(indexLines[0]), sizeof(indexLoop)/sizeof(indexLoop[0]), sizeof(indexStrip)/sizeof(indexStrip[0])};
Geometry CreateGeometry()
{
PropertyBuffer pentagonVertices = PropertyBuffer::New( pentagonVertexFormat );
pentagonVertices.SetData(pentagonVertexData, 5);
- // Create indices
- PropertyBuffer indices = CreateIndexBuffer( Geometry::LINES );
// Create the geometry object
Geometry pentagonGeometry = Geometry::New();
pentagonGeometry.AddVertexBuffer( pentagonVertices );
- pentagonGeometry.SetIndexBuffer( indices );
+ pentagonGeometry.SetIndexBuffer( indices[0], indicesSize[0] );
pentagonGeometry.SetGeometryType( Geometry::LINES );
return pentagonGeometry;
}
index = 2;
}
- PropertyBuffer indices = CreateIndexBuffer( geomTypes[ index ] );
- mGeometry.SetIndexBuffer( indices );
+ mGeometry.SetIndexBuffer( indices[index], indicesSize[index] );
mGeometry.SetGeometryType( geomTypes[ index ] );
return true;
texturedQuadVertices.SetData( texturedQuadVertexData, 4 );
// Create indices
- unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 };
- Property::Map indexFormat;
- indexFormat["indices"] = Property::INTEGER;
- PropertyBuffer indices = PropertyBuffer::New( indexFormat );
- indices.SetData( indexData, 6 );
+ unsigned short indexData[6] = { 0, 3, 1, 0, 2, 3 };
// Create the geometry object
Geometry texturedQuadGeometry = Geometry::New();
texturedQuadGeometry.AddVertexBuffer( texturedQuadVertices );
- texturedQuadGeometry.SetIndexBuffer( indices );
+ texturedQuadGeometry.SetIndexBuffer( &indexData[0], sizeof(indexData)/sizeof(unsigned short) );
return texturedQuadGeometry;
}
{ Vector2(1.0f, 1.0f * aspect) }
};
- int indices[] = { 0, 3, 1, 0, 2, 3 };
-
unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition);
//Vertices
textureVertices.SetData( textures, numberOfVertices );
//Indices
- Property::Map indicesVertexFormat;
- indicesVertexFormat["aIndices"] = Property::INTEGER;
- PropertyBuffer indicesToVertices = PropertyBuffer::New( indicesVertexFormat );
- indicesToVertices.SetData( indices, 6 );
+ unsigned short indices[] = { 0, 3, 1, 0, 2, 3 };
// Create the geometry object
Geometry texturedQuadGeometry = Geometry::New();
texturedQuadGeometry.AddVertexBuffer( positionVertices );
texturedQuadGeometry.AddVertexBuffer( textureVertices );
- texturedQuadGeometry.SetIndexBuffer ( indicesToVertices );
+ texturedQuadGeometry.SetIndexBuffer ( &indices[0], sizeof( indices )/ sizeof( indices[0] ) );
return texturedQuadGeometry;
}
{ Vector2(1.0f, 1.0f) }
};
- int indices[] = { 0, 3, 1, 0, 2, 3 };
-
unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition);
//Vertices
textureVertices.SetData( textures, numberOfVertices );
//Indices
- Property::Map indicesVertexFormat;
- indicesVertexFormat["aIndices"] = Property::INTEGER;
- PropertyBuffer indicesToVertices = PropertyBuffer::New( indicesVertexFormat );
- indicesToVertices.SetData( indices, 6 );
+ unsigned short indices[] = { 0, 3, 1, 0, 2, 3 };
// Create the geometry object
Geometry texturedQuadGeometry = Geometry::New();
texturedQuadGeometry.AddVertexBuffer( positionVertices );
texturedQuadGeometry.AddVertexBuffer( textureVertices );
- texturedQuadGeometry.SetIndexBuffer ( indicesToVertices );
+ texturedQuadGeometry.SetIndexBuffer ( &indices[0], sizeof( indices )/ sizeof( indices[0] ) );
return texturedQuadGeometry;
}
{ Vector3(0.0f, 0.0f, 1.0f) }
};
- int indices[] = { 0, 3, 1, 0, 2, 3 };
-
unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition);
//Vertices
normalVertices.SetData( normals, numberOfVertices );
//Indices
- Property::Map indicesVertexFormat;
- indicesVertexFormat["aIndices"] = Property::INTEGER;
- PropertyBuffer indicesToVertices = PropertyBuffer::New( indicesVertexFormat );
- indicesToVertices.SetData( indices, 6 );
-
+ unsigned short indices[] = { 0, 3, 1, 0, 2, 3 };
// Create the geometry object
Geometry texturedQuadGeometry = Geometry::New();
texturedQuadGeometry.AddVertexBuffer( textureVertices );
texturedQuadGeometry.AddVertexBuffer( normalVertices );
- texturedQuadGeometry.SetIndexBuffer ( indicesToVertices );
+ texturedQuadGeometry.SetIndexBuffer ( &indices[0], 6 );
return texturedQuadGeometry;
}
{ Vector3(0.0f, 0.0f, 1.0f) }
};
- int indices[] = { 0, 3, 1, 0, 2, 3 };
-
unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition);
//Vertices
normalVertices.SetData( normals, numberOfVertices );
//Indices
- Property::Map indicesVertexFormat;
- indicesVertexFormat["aIndices"] = Property::INTEGER;
- PropertyBuffer indicesToVertices = PropertyBuffer::New( indicesVertexFormat );
- indicesToVertices.SetData( indices, 6 );
+ unsigned short indices[] = { 0, 3, 1, 0, 2, 3 };
// Create the geometry object
Geometry texturedQuadGeometry = Geometry::New();
texturedQuadGeometry.AddVertexBuffer( textureVertices );
texturedQuadGeometry.AddVertexBuffer( normalVertices );
- texturedQuadGeometry.SetIndexBuffer ( indicesToVertices );
+ texturedQuadGeometry.SetIndexBuffer ( &indices[0], sizeof( indices )/ sizeof( indices[0] ) );
return texturedQuadGeometry;
}
vertices.SetData( vertexData, 5 );
// Specify all the faces
- unsigned int indexData[12] = { 0,1,3,0,2,4,0,3,4,0,2,1 };
- Property::Map indexFormat;
- indexFormat["indices"] = Property::INTEGER;
- PropertyBuffer indices = PropertyBuffer::New( indexFormat );
- indices.SetData( indexData, 12 );
+ unsigned short indexData[12] = { 0,1,3,0,2,4,0,3,4,0,2,1 };
// Create the geometry object
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( vertices );
- geometry.SetIndexBuffer( indices );
+ geometry.SetIndexBuffer( &indexData[0], 12 );
return geometry;
}
PropertyBuffer vertices = PropertyBuffer::New( vertexFormat );
vertices.SetData( vertexData, 7u );
- unsigned int indexData[15] = { 0,1,2,0,2,3,0,3,4,0,4,5,0,5,6 };
- Property::Map indexFormat;
- indexFormat["indices"] = Property::INTEGER;
- PropertyBuffer indices = PropertyBuffer::New( indexFormat );
- indices.SetData( indexData, 15u );
+ unsigned short indexData[15] = { 0,1,2,0,2,3,0,3,4,0,4,5,0,5,6 };
Geometry meshGeometry = Geometry::New();
meshGeometry.AddVertexBuffer( vertices );
- meshGeometry.SetIndexBuffer( indices );
+ meshGeometry.SetIndexBuffer( &indexData[0], sizeof( indexData )/sizeof(indexData[0]) );
// Create shader
std::ostringstream vertexShaderStringStream;
texturedQuadVertices.SetData( texturedQuadVertexData, 4 );
// Create indices
- unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 };
- Property::Map indexFormat;
- indexFormat["indices"] = Property::INTEGER;
- PropertyBuffer indices = PropertyBuffer::New( indexFormat );
- indices.SetData( indexData, sizeof(indexData)/sizeof(indexData[0]) );
+ unsigned short indexData[6] = { 0, 3, 1, 0, 2, 3 };
// Create the geometry object
Geometry texturedQuadGeometry = Geometry::New();
texturedQuadGeometry.AddVertexBuffer( texturedQuadVertices );
- texturedQuadGeometry.SetIndexBuffer( indices );
+ texturedQuadGeometry.SetIndexBuffer( &indexData[0], sizeof(indexData)/sizeof(indexData[0]) );
return texturedQuadGeometry;
}