本文整理汇总了C++中ogre::ColourValue::getAsABGR方法的典型用法代码示例。如果您正苦于以下问题:C++ ColourValue::getAsABGR方法的具体用法?C++ ColourValue::getAsABGR怎么用?C++ ColourValue::getAsABGR使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::ColourValue
的用法示例。
在下文中一共展示了ColourValue::getAsABGR方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setSubMeshColors
bool MaterialVertexBuffer::setSubMeshColors(
EntityMaterial* entity,
unsigned short mesh_index,
size_t ui32VertexColorCount,
const float* pVertexColorArray) const
{
if(entity->getOgreEntity() == NULL)
{
m_rKernelContext.getLogManager() << LogLevel_Error << "Can't set colors : no Entity found!\n";
return false;
}
Ogre::Mesh* mesh = entity->getOgreEntity()->getMesh().get();
if(mesh == NULL || mesh_index >= mesh->getNumSubMeshes())
{
m_rKernelContext.getLogManager() << LogLevel_Error << "Can't set colors : no Mesh found!\n";
return false;
}
Ogre::SubMesh* submesh = mesh->getSubMesh( mesh_index );
if(submesh->useSharedVertices)
{
m_rKernelContext.getLogManager() << LogLevel_Error << "Can't set colors : vertices are shared and thus not accessible from SubMesh!\n";
return false;
}
else
{
if(ui32VertexColorCount != submesh->vertexData->vertexCount)
{
m_rKernelContext.getLogManager() << LogLevel_Error << "Can't set colors : vertex count mismatch!\n";
return false;
}
//get pointer to submesh vertex data
Ogre::VertexData* vertex_data = submesh->vertexData;
//get pointer to DIFFUSE element
const Ogre::VertexElement* difElem = vertex_data->vertexDeclaration->findElementBySemantic(Ogre::VES_DIFFUSE);
if(difElem == NULL)
{
m_rKernelContext.getLogManager() << LogLevel_Error << "Can't set colors : no colours_diffuse element found in vertex buffer!\n";
return false;
}
//convert color to current RenderSystem's format
Ogre::VertexElementType type = difElem->getType();
//retrieve VB for DIFFUSE element
Ogre::HardwareVertexBufferSharedPtr vbuf = vertex_data->vertexBufferBinding->getBuffer(difElem->getSource());
//lock VB for reading
unsigned char* color = static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
// There is _no_ baseVertexPointerToElement() which takes an Ogre::Real or a double
// as second argument. So make it float, to avoid trouble when Ogre::Real will
// be comiled/typedefed as double:
// Ogre::Real* pReal;
Ogre::RGBA* pRGBA;
Ogre::ColourValue colour;
for( size_t j = 0; j < vertex_data->vertexCount; ++j, color += vbuf->getVertexSize())
{
//get pointer to RGBA DIFFUSE data
difElem->baseVertexPointerToElement(color, &pRGBA);
colour.r = pVertexColorArray[4*j];
colour.g = pVertexColorArray[4*j+1];
colour.b = pVertexColorArray[4*j+2];
colour.a = pVertexColorArray[4*j+3];
//convert color from RGBA floats to a single ARGB uint32
if(type == Ogre::VET_COLOUR_ARGB) //D3D format
{
*pRGBA = colour.getAsARGB();
}
else /*if type == OGRE::VET_COLOUR_ABGR)*/ //GL format
{
*pRGBA = colour.getAsABGR();
}
}
//unlock VB
vbuf->unlock();
}
return true;
}