Code: Select all
auto width =2u, height = 2u; // 2x2
auto format = Ogre::PFG_R8_UNORM; // single channel greyscale
auto size = Ogre::PixelFormatGpuUtils::calculateSizeBytes( width, height, 1u, 1u, format, 1u );
// make sure the entire image starts black
auto *data = OGRE_MALLOC_SIMD( size, Ogre::MEMCATEGORY_RESOURCE );
memset( data, 0, size );
Ogre::Image2 image;
image.loadDynamicImage( data, width, height, 1u, Ogre::TextureTypes::Type2D, format, true, 0u );
// Set single pixel color
Ogre::TextureBox box = image.getData( 0u );
box.setColourAt( Ogre::ColourValue::White, 0, 0, 0u, format );
image.save( "heightmap.jpg", 0u, 0u );
Can anyone spot or explain what I am doing wrong here?