本文整理汇总了C++中IndexDescriptor::setType方法的典型用法代码示例。如果您正苦于以下问题:C++ IndexDescriptor::setType方法的具体用法?C++ IndexDescriptor::setType怎么用?C++ IndexDescriptor::setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IndexDescriptor
的用法示例。
在下文中一共展示了IndexDescriptor::setType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createRectangle
Mesh MeshManager::createRectangle(const Gre::Surface &surface)
{
if ( surface.height > 0 && surface.width > 0 )
{
std::string name = std::string ( "MeshRectangle#" ) + std::to_string(iMeshes.size());
std::string svbname = name + "/svb";
std::string sibname = name + "/sib";
// To create a Mesh, we have to fill a SoftwareVertexBuffer.
SoftwareVertexBufferHolder svbholder = SoftwareVertexBufferHolder ( new SoftwareVertexBufferPrivate(svbname) );
if ( !svbholder.isInvalid() )
{
VertexDescriptor vdesc;
vdesc << VertexComponentType::Position;
svbholder->setVertexDescriptor(vdesc);
VertexPosition* data = (VertexPosition*) new VertexPosition[4];
data[0] = VertexPosition ( surface.left , surface.top , 0.0f );
data[1] = VertexPosition ( surface.left + surface.width , surface.top , 0.0f );
data[2] = VertexPosition ( surface.left + surface.width , surface.top - surface.height , 0.0f );
data[3] = VertexPosition ( surface.left , surface.top - surface.height , 0.0f );
svbholder->addData((const char*) data, sizeof(VertexPosition) * 4);
}
else
{
#ifdef GreIsDebugMode
GreDebugPretty() << "SoftwareVertexBuffer '" << svbname << "' couldn't be created." << std::endl;
#endif
return Mesh ( nullptr );
}
// We also try to fill a SoftwareIndexBuffer.
SoftwareIndexBufferHolder sibholder = SoftwareIndexBufferHolder ( new SoftwareIndexBufferPrivate(sibname) );
if ( !sibholder.isInvalid() )
{
IndexDescriptor idesc;
idesc.setType(IndexType::UnsignedInteger);
unsigned int data[6] = { 0, 1, 2, 2, 3, 0 };
sibholder->setIndexDescriptor(idesc, 0);
sibholder->addDataToIndexBatch((const char*) data, sizeof(unsigned int) * 6, 0);
}
else
{
#ifdef GreIsDebugMode
GreDebugPretty() << "SoftwareIndexBuffer '" << sibname << "' couldn't be created." << std::endl;
#endif
return Mesh ( nullptr );
}
// Now we can add those two HardwareBuffer to a Mesh object.
MeshHolder rectangle = MeshHolder ( new MeshPrivate(name) );
if ( !rectangle.isInvalid() )
{
rectangle->setSoftwareVertexBuffer(SoftwareVertexBuffer(svbholder));
rectangle->setSoftwareIndexBuffer(SoftwareIndexBuffer(sibholder));
// Everything is set, just add this Mesh to the list and return it.
iMeshes.add(rectangle);
return Mesh ( rectangle );
}
else
{
#ifdef GreIsDebugMode
GreDebugPretty() << "Mesh '" << name << "' couldn't be created." << std::endl;
#endif
return Mesh ( nullptr );
}
}
else
{
#ifdef GreIsDebugMode
GreDebugPretty() << "Can't create a Mesh Resource using null Surface." << std::endl;
#endif
return Mesh ( nullptr );
}
}