本文整理汇总了C++中ITexture::SetPixelArray方法的典型用法代码示例。如果您正苦于以下问题:C++ ITexture::SetPixelArray方法的具体用法?C++ ITexture::SetPixelArray怎么用?C++ ITexture::SetPixelArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITexture
的用法示例。
在下文中一共展示了ITexture::SetPixelArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mFunction_CreateTexture_AsciiBitmapTable
BOOL IFontManager::mFunction_CreateTexture_AsciiBitmapTable(N_FontObject& fontObj,std::string fontName, UINT charWidth, UINT charHeight)
{
//define the width /height of bitmap Table , Ascii code 0~127
UINT tablePxWidth = charWidth*NOISE_MACRO_FONT_ASCII_BITMAP_TABLE_COLUMN_COUNT;
UINT tablePxHeight = charHeight*NOISE_MACRO_FONT_ASCII_BITMAP_TABLE_ROW_COUNT;
UINT tableRowCount = NOISE_MACRO_FONT_ASCII_BITMAP_TABLE_ROW_COUNT;
UINT tableColumnCount = NOISE_MACRO_FONT_ASCII_BITMAP_TABLE_COLUMN_COUNT;
//try to create a new pure color texture to be modified
fontObj.mInternalTextureName = "AsciiBitmapTable" + fontName;//not same with the public FONT NAME
//Create a pure color Texture
ITexture* pTexture = m_pTexMgr->CreatePureColorTexture(
fontObj.mInternalTextureName,
tablePxWidth,
tablePxHeight,
NVECTOR4(0, 0, 0, 0),
TRUE
);
//check if texture creation success
if (pTexture==nullptr)
{
ERROR_MSG("CreateFontFromFile : Create Bitmap Table Texture failed!");
return FALSE;
}
//-----Up to now,the texture is still a pure color bitmap-------
//-----we are gonna write an ASCII bitmap table to it (code 0~127)--
std::vector<NVECTOR4> pixelBuff(tablePxWidth*tablePxHeight);
for (UINT rowID = 0;rowID < tableRowCount;rowID++)
{
for (UINT colID = 0;colID < tableColumnCount;colID++)
{
N_Font_Bitmap tmpFontBitmap;
mFunction_GetBitmapOfChar(fontObj,rowID*tableColumnCount+colID, tmpFontBitmap, NVECTOR4(1.0f, 0, 0, 1.0f));
for (UINT localY = 0;localY < charHeight;localY++)
{
for (UINT localX = 0;localX < charWidth;localX++)
{
//...the size of char bitmap might didn't match the size of the boundary rect(for 1 char)
if (localX < tmpFontBitmap.width && localY < tmpFontBitmap.height)
{
//copy every char bitmap to the global char bitmap table
UINT currentPixelID = (rowID*charHeight + localY)*tablePxWidth + colID*charWidth + localX;
pixelBuff.at(currentPixelID) = tmpFontBitmap.bitmapBuffer.at(localY*tmpFontBitmap.width + localX);
}
}
}
}
}
pTexture->SetPixelArray(pixelBuff);
//update a texture to Graphic Memory
pTexture->UpdateToVideoMemory();
return TRUE;
}