当前位置: 首页>>代码示例>>C++>>正文


C++ DynamicArray::AddArray方法代码示例

本文整理汇总了C++中DynamicArray::AddArray方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicArray::AddArray方法的具体用法?C++ DynamicArray::AddArray怎么用?C++ DynamicArray::AddArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DynamicArray的用法示例。


在下文中一共展示了DynamicArray::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,
    DynamicArray< DynamicArray< uint8_t > >& rTextureSheets )
{
    HELIUM_ASSERT( pGrayscaleData );

    DynamicArray< 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 );

//.........这里部分代码省略.........
开发者ID:HeliumProject,项目名称:Helium,代码行数:101,代码来源:FontResourceHandler.cpp


注:本文中的DynamicArray::AddArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。