本文整理汇总了C++中GraphicsDevice::createIndexBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsDevice::createIndexBuffer方法的具体用法?C++ GraphicsDevice::createIndexBuffer怎么用?C++ GraphicsDevice::createIndexBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsDevice
的用法示例。
在下文中一共展示了GraphicsDevice::createIndexBuffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createPatchIndexBuffer
IndexBuffer TerrainTessellator::createPatchIndexBuffer(const GraphicsDevice& device, unsigned levelOfDetail)
{
// distance between two neighbor vertices
int delta = MathHelper::pow2(levelOfDetail);
// size of grid in current lod (e.g. lod 0: 64, lod 1: 32)
int lodSize = size / delta;
// main indices + skirt indices
int numIndices = lodSize * lodSize * 6;
IndexCollection indices(numIndices);
int count = 0;
unsigned interval = min(stripeSize * delta, size);
// init main indices
for (unsigned i = 0; i < size / interval; ++i)
for (unsigned row = 0; row < size; row += delta)
for (unsigned col = i * interval; col < (i+1) * interval; col += delta)
initQuadIndices(row, col, delta, delta, &indices, &count);
IndexBuffer indexBuffer = device.createIndexBuffer(sizeof(TerrainIndex) * numIndices, indexFormat, D3DUSAGE_WRITEONLY);
indexBuffer.setData(indices);
return indexBuffer;
}
示例2: createSkirtIndexBuffer
IndexBuffer TerrainTessellator::createSkirtIndexBuffer(const GraphicsDevice& device, unsigned levelOfDetail)
{
// distance between two neighbor vertices
int delta = MathHelper::pow2(levelOfDetail);
// size of grid in current lod (e.g. lod 0: 64, lod 1: 32)
int lodSize = size / delta;
// main indices + skirt indices
int numIndices = lodSize * 4 * 6;
IndexCollection indices(numIndices);
int count = 0;
int interval = min(stripeSize * delta, size);
// init skirt indices
for (int i = 0; i < 2; ++i)
for (int j = 0; j < 2; ++j)
for (unsigned row = 0; row < (i ? size : 1); row += delta)
for (unsigned col = 0; col < (i ? 1 : size); col += delta)
{
int r = i ? row : -1 + j * (size + 1);
int c = i ? -1 + j * (size + 1) : col;
int deltaCol = i ? 1 : delta;
int deltaRow = i ? delta : 1;
initQuadIndices(r, c, deltaRow, deltaCol, &indices, &count);
}
IndexBuffer indexBuffer = device.createIndexBuffer(sizeof(TerrainIndex) * numIndices, indexFormat, D3DUSAGE_WRITEONLY);
indexBuffer.setData(indices);
return indexBuffer;
}