本文整理汇总了C++中DynArray::AddArray方法的典型用法代码示例。如果您正苦于以下问题:C++ DynArray::AddArray方法的具体用法?C++ DynArray::AddArray怎么用?C++ DynArray::AddArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynArray
的用法示例。
在下文中一共展示了DynArray::AddArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompressTexture
/// Compress a font texture sheet and add the texture data to the given texture sheet array.
///
/// @param[in] pGrayscaleData Texture sheet data, stored as a contiguous array of 8-bit grayscale values.
/// @param[in] textureWidth Width of the texture sheet.
/// @param[in] textureHeight Height of the texture sheet.
/// @param[in] compression Font texture sheet compression method to use.
/// @param[in] rTextureSheets Array of texture sheets to which the texture data should be appended.
void FontResourceHandler::CompressTexture(
const uint8_t* pGrayscaleData,
uint16_t textureWidth,
uint16_t textureHeight,
Font::ECompression compression,
DynArray< DynArray< uint8_t > >& rTextureSheets )
{
HELIUM_ASSERT( pGrayscaleData );
DynArray< uint8_t >* pOutputSheet = rTextureSheets.New();
HELIUM_ASSERT( pOutputSheet );
// If the output is to be uncompressed grayscale data, simply copy the data to the output texture, as it's already
// uncompressed grayscale data.
if( compression == Font::ECompression::GRAYSCALE_UNCOMPRESSED )
{
size_t pixelCount = static_cast< size_t >( textureWidth ) * static_cast< size_t >( textureHeight );
pOutputSheet->AddArray( pGrayscaleData, pixelCount );
return;
}
// Convert the source image to a 32-bit BGRA image for the NVIDIA texture tools library to process.
Image::InitParameters imageParameters;
imageParameters.format.SetBytesPerPixel( 4 );
imageParameters.format.SetChannelBitCount( Image::CHANNEL_RED, 8 );
imageParameters.format.SetChannelBitCount( Image::CHANNEL_GREEN, 8 );
imageParameters.format.SetChannelBitCount( Image::CHANNEL_BLUE, 8 );
imageParameters.format.SetChannelBitCount( Image::CHANNEL_ALPHA, 8 );
#if HELIUM_ENDIAN_LITTLE
imageParameters.format.SetChannelBitOffset( Image::CHANNEL_RED, 16 );
imageParameters.format.SetChannelBitOffset( Image::CHANNEL_GREEN, 8 );
imageParameters.format.SetChannelBitOffset( Image::CHANNEL_BLUE, 0 );
imageParameters.format.SetChannelBitOffset( Image::CHANNEL_ALPHA, 24 );
#else
imageParameters.format.SetChannelBitOffset( Image::CHANNEL_RED, 8 );
imageParameters.format.SetChannelBitOffset( Image::CHANNEL_GREEN, 16 );
imageParameters.format.SetChannelBitOffset( Image::CHANNEL_BLUE, 24 );
imageParameters.format.SetChannelBitOffset( Image::CHANNEL_ALPHA, 0 );
#endif
imageParameters.width = textureWidth;
imageParameters.height = textureHeight;
Image bgraImage;
HELIUM_VERIFY( bgraImage.Initialize( imageParameters ) );
uint_fast32_t imageWidth = textureWidth;
uint_fast32_t imageHeight = textureHeight;
uint_fast32_t imagePitch = bgraImage.GetPitch();
uint8_t* pImagePixelData = static_cast< uint8_t* >( bgraImage.GetPixelData() );
HELIUM_ASSERT( pImagePixelData );
uint8_t* pImageRow = pImagePixelData;
for( uint_fast32_t imageY = 0; imageY < imageHeight; ++imageY )
{
uint8_t* pOutputPixel = pImageRow;
for( uint_fast32_t imageX = 0; imageX < imageWidth; ++imageX )
{
uint8_t pixel = *( pGrayscaleData++ );
*( pOutputPixel++ ) = pixel;
*( pOutputPixel++ ) = pixel;
*( pOutputPixel++ ) = pixel;
*( pOutputPixel++ ) = 0xff;
}
pImageRow += imagePitch;
}
// Set up the input options for the texture compressor.
nvtt::InputOptions inputOptions;
inputOptions.setTextureLayout( nvtt::TextureType_2D, textureWidth, textureHeight );
inputOptions.setMipmapData( pImagePixelData, textureWidth, textureHeight );
inputOptions.setMipmapGeneration( false );
inputOptions.setWrapMode( nvtt::WrapMode_Repeat );
inputOptions.setGamma( 1.0f, 1.0f );
inputOptions.setNormalMap( false );
// Set up the output options for the texture compressor.
MemoryTextureOutputHandler outputHandler( textureWidth, textureHeight, false, false );
nvtt::OutputOptions outputOptions;
outputOptions.setOutputHandler( &outputHandler );
outputOptions.setOutputHeader( false );
// Set up the compression options for the texture compressor (note that the only compression option we currently
// support other than uncompressed grayscale is BC1/DXT1).
nvtt::CompressionOptions compressionOptions;
compressionOptions.setFormat( nvtt::Format_BC1 );
compressionOptions.setQuality( nvtt::Quality_Normal );
//.........这里部分代码省略.........