本文整理汇总了C++中VertexElement::size方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexElement::size方法的具体用法?C++ VertexElement::size怎么用?C++ VertexElement::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexElement
的用法示例。
在下文中一共展示了VertexElement::size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rebuild
void VertexDeclaration::rebuild()
{
mHash = 0;
int nTexCoord = 0;
int nElem = 0;
int nVB = mParent->vertexBufferCount();
for (int v = 0; v<nVB; ++v) {
VertexBuffer* vb = mParent->vertexBuffer(v);
if (vb) {
nElem += vb->vertexElementCount();
}
}
delete[] mElements;
mElements = TD_NEW D3D11_INPUT_ELEMENT_DESC[nElem];
int eIdx = 0;
for (int v = 0; v<nVB; ++v) {
VertexBuffer* vb = mParent->vertexBuffer(v);
if (vb) {
int offset = 0;
int nVbElem = vb->vertexElementCount();
for (int e = 0; e<nVbElem; ++e)
{
VertexElement* ve = vb->vertexElement(e);
D3D11_INPUT_ELEMENT_DESC& elem = mElements[eIdx];
elem.SemanticName = s_SemanticNameLUT[ve->mUsage];
elem.SemanticIndex = (BYTE)ve->mIndex;
elem.Format = makeD3D11Type(ve->mType, ve->mCount);
elem.AlignedByteOffset = (WORD)offset;
elem.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
elem.InputSlot = v;
elem.InstanceDataStepRate = 0;
offset += ve->size();
++eIdx;
// while we at this, create the hash (bitmask) that identifies this vertex structure
if (ve->mUsage == VEU_TEXCOORD)
nTexCoord++;
int mask = 0;
if (ve->mUsage != VEU_UNKNOWN) {
mask = 1 << ve->mUsage;
}
mHash |= mask;
}
}
}
// add the number of texcoords (if any) to the hash
mHash |= (nTexCoord << 16);
// release any existing declaration object
mLayout.Reset();
// it seems pretty ugly from a dependency perspective, but D3D11 forces us to have an
// existing vertex shader in order to make a vertex declaration (input format), so we
// need to fetch one that matches the submesh (or face the warnings that the D3D runtime
// will spew at us)
VertexShader* vs = static_cast<VertexShader*>(ShaderManager::instance().createOrFindInstanceOf(mParent));
// create the vertex declaration
HRESULT hr = mDevice->CreateInputLayout(
mElements,
nElem,
vs->bytecode(),
vs->bytecodeLength(),
&mLayout
);
if (FAILED(hr)) {
throw Exception("Failed to (re)build vertex input layout in VertexDeclaration::rebuild");
}
}