本文整理汇总了C++中TexturePtr::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ TexturePtr::GetData方法的具体用法?C++ TexturePtr::GetData怎么用?C++ TexturePtr::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TexturePtr
的用法示例。
在下文中一共展示了TexturePtr::GetData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_application_initialized
void on_application_initialized ()
{
try
{
Test test ("disable=*");
media::CompressedImage image (IMAGE_NAME);
PixelFormat pixel_format;
const char* image_format = image.Format ();
if (!xtl::xstricmp (image_format, "dxt1"))
pixel_format = PixelFormat_DXT1;
else if (!xtl::xstricmp (image_format, "dxt3"))
pixel_format = PixelFormat_DXT3;
else if (!xtl::xstricmp (image_format, "dxt5"))
pixel_format = PixelFormat_DXT5;
else
throw xtl::format_operation_exception ("", "Unsupported dds texture format '%s'", image_format);
TextureDesc texture_desc;
memset (&texture_desc, 0, sizeof texture_desc);
texture_desc.dimension = TextureDimension_2D;
texture_desc.width = image.Width ();
texture_desc.height = image.Height ();
texture_desc.layers = 1;
texture_desc.format = pixel_format;
texture_desc.bind_flags = BindFlag_Texture;
texture_desc.access_flags = AccessFlag_ReadWrite;
texture_desc.generate_mips_enable = false;
stl::vector<unsigned int> sizes (image.BlocksCount ());
const media::CompressedImageBlockDesc* blocks = image.Blocks ();
unsigned int mips_count = image.BlocksCount ();
printf ("Load %u mips:\n", mips_count);
for (unsigned int i=0, count=(unsigned int)sizes.size (); i<count; i++)
{
sizes [i] = blocks [i].size;
printf (" level%02u: size=%u\n", i, sizes [i]);
}
TextureData data;
memset (&data, 0, sizeof (TextureData));
data.data = image.Data ();
data.sizes = &sizes [0];
TexturePtr texture (test.device->CreateTexture (texture_desc, data), false);
xtl::uninitialized_storage<char> buffer (get_image_size (image.Width (), image.Height (), PixelFormat_RGB8));
unsigned int width = image.Width (), height = image.Height ();
printf ("Set %u mips:\n", mips_count);
for (unsigned int i=0; i<mips_count; i++)
{
unsigned int size = get_image_size (width, height, PixelFormat_RGB8);
texture->GetData (0, i, 0, 0, width, height, PixelFormat_RGB8, buffer.data ());
printf (" level%02u: width=%u, height=%u, hash=%08x\n", i, width, height, common::crc32 (buffer.data (), size));
width = width > 1 ? width / 2 : width;
height = height > 1 ? height / 2 : height;
}
}
catch (std::exception& e)
{
printf ("exception: %s\n", e.what ());
}
syslib::Application::Exit (0);
}