I am new to Ogre and I am trying to create a texture manually to use it in a shader.
I absolutely need it to have a RGBA pixel format (because I receive data from another part which is in RGBA and cannot be easily converted), but it looks like Ogre does not take my choice into account and always gives me what seems to be a BGRA texture.
I create my texture like this :
Code: Select all
_texture= Ogre::TextureManager::getSingleton().createManual(
"TestTexture",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D,
256, 256,
0,
Ogre::PF_BYTE_RGBA,
Ogre::TU_DYNAMIC
);
Code: Select all
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = _texture->getBuffer();
pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
unsigned char* pDest = static_cast<unsigned char*>(pixelBox.data);
for (size_t j = 0; j < 256; j++)
{
for (size_t i = 0; i < 256; i++)
{
*pDest++ = 255;
*pDest++ = 0;
*pDest++ = 0;
*pDest++ = 255;
}
}
Code: Select all
*pDest++ = 0;
*pDest++ = 0;
*pDest++ = 255;
*pDest++ = 255;
I tried to use PF_BYTE_BGRA (in hope that both were inverted) but the result is exactly the same.
Moreover, when I use
Code: Select all
_texture->getFormat()
Could someone help me understanding the usage of pixel formats, or tell me what I am doing wrong ?
By the way I'm using Ogre 1.9 and OpenGL/GLSL.
Thank you very much.