本文整理汇总了C++中VertexBufferPtr::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexBufferPtr::GetSize方法的具体用法?C++ VertexBufferPtr::GetSize怎么用?C++ VertexBufferPtr::GetSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexBufferPtr
的用法示例。
在下文中一共展示了VertexBufferPtr::GetSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateGeomtry
void SimpleObj::UpdateGeomtry()
{
int decl_flag = _DECL_POSITION;
if (m_normals.Size())
{
debug_assert(m_normals.Size() == mositions.Size(), "normal size != position size.");
decl_flag |= _DECL_NORMAL;
}
if (m_colors.Size())
{
debug_assert(m_colors.Size() == mositions.Size(), "color size != position size.");
decl_flag |= _DECL_COLOR;
}
if (m_texcoords.Size())
{
debug_assert(m_texcoords.Size() == mositions.Size(), "texcoord size != position size.");
decl_flag |= _DECL_TEXCOORD;
}
int stride = 0;
if (decl_flag != m_decl_flag)
{
VertexDeclarationPtr decl = VideoBufferManager::Instance().CreateVertexDeclaration();
decl->AddElement(0, 0, DECLTYPE_FLOAT3, DECLMETHOD_DEFAULT, DECLUSAGE_POSITION, 0);
stride += 12;
if (decl_flag & _DECL_NORMAL)
{
decl->AddElement(0, stride, DECLTYPE_FLOAT3, DECLMETHOD_DEFAULT, DECLUSAGE_NORMAL, 0);
stride += 12;
}
if (decl_flag & _DECL_COLOR)
{
decl->AddElement(0, stride, DECLTYPE_FLOAT4, DECLMETHOD_DEFAULT, DECLUSAGE_COLOR, 0);
stride += 16;
}
if (decl_flag & _DECL_TEXCOORD)
{
decl->AddElement(0, stride, DECLTYPE_FLOAT2, DECLMETHOD_DEFAULT, DECLUSAGE_TEXCOORD, 0);
stride += 8;
}
decl->EndDecl();
m_decl_flag = decl_flag;
mVertexStream.SetDeclaration(decl);
}
stride = mVertexStream.GetDeclaration()->GetStreamSize(0);
int size = stride * mositions.Size();
VertexBufferPtr buffer = mVertexStream.GetStream(0);
if (buffer.IsNull() || buffer->GetSize() < size)
{
buffer = VideoBufferManager::Instance().CreateVertexBuffer(size, USAGE_WRITEONLY, POOL_MANAGED);
}
//Update Geomtry;
Vector<Vec3>::Iterator pi;
Vector<Vec3>::Iterator pe;
Vector<Vec3>::Iterator ni;
Vector<Vec3>::Iterator ne;
Vector<Color4>::Iterator ci;
Vector<Color4>::Iterator ce;
Vector<Vec2>::Iterator ti;
Vector<Vec2>::Iterator te;
pi = mositions.Begin();
pe = mositions.End();
ni = m_normals.Begin();
ne = m_normals.End();
ci = m_colors.Begin();
ce = m_colors.End();
ti = m_texcoords.Begin();
te = m_texcoords.End();
char * verteces;
buffer->Lock(0, 0, (void**)&verteces, LOCK_DISCARD);
while (pi != pe)
{
int offset = 0;
if (m_decl_flag & _DECL_POSITION)
{
float * position = (float*)(verteces + offset);
if (pi != pe)
//.........这里部分代码省略.........