Hi I have problem while I am trying to create dynamic texture to assign as a background in my ogre window. I want to assign values dynamicly for an each pixel of texture and then I use this texture as a background. I use this code to create dynamic texture.
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual("BackgroundTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 800, 600, 0, Ogre::PF_R8G8B8, Ogre:: TU_DYNAMIC);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("BackgroundMat",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->getTechnique(0)->getPass(0)->createTextureUnitState("BackgroundTex");
material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_COLOUR);
Ogre::Rectangle2D* rect = new Ogre::Rectangle2D(true);
rect->setCorners(-1.0, 1.0, 1.0, -1.0);
rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND);
rect->setBoundingBox(Ogre::AxisAlignedBox(-100000.0 * Ogre::Vector3::UNIT_SCALE, 100000.0 * Ogre::Vector3::UNIT_SCALE));
Ogre::SceneNode* node = sceneManager->getRootSceneNode()->createChildSceneNode("BackgroundMat");
node->attachObject(rect);
node->setVisible(true);
rect->setMaterial("BackgroundMat");
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer();
pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
Ogre::uint8* pDest = static_cast<Ogre::uint8*>(pixelBox.data);
for(size_t i=0; i < 600; i++)
{
for(size_t j=0; j < 800; j++)
{
*pDest++ = 0;
*pDest++ = 0;
*pDest++ = 255;
}
}
pixelBuffer->unlock();
in this piece of code I assign blue ( R:0 G:0 B:255 ) for each value. I expect to obtain full of blue window but instead of blue background I obtain this background that seen in the picture.
Instead of blue background, in the texture that I obtain there are 3 different color types and they are always repeat sequently. Blue pixels are true but the other 2 color would be blue as well. I cant find reason that cause this problem. What can I do? What is a wrong part?