[2.2] Does RenderBox support texture stretch

nec

21-09-2010 19:02:44

Hello,

I'm trying to do a minimap with a render box but i have some litlle problems.

here is the code i use to init the RB:


...
m_pRenderBox->createTexture(20, 20, MyGUI::Canvas::TRM_PT_VIEW_REQUESTED, Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE, Ogre::PF_A8R8G8B8);
m_pRenderBox->setCoord(0, 0, 80, 80 );
...


then i write in the texture with :


...
// update de la minimap
m_pRenderBox->lock();

for(UInt x = 0 ; x < 20 ; x++)
{
for(UInt y = 0 ; y < 20 ; y++)
{
m_pImage->setPixel(x, y, Ogre::ColourValue::Red);
}
}

m_pRenderBox->unlock();
...


What i'm expecting is to have a fully red canvas (20x20 streched over the 80x80 renderbox) but the red square is in the top left corner of the render box. So my question is, does the texture can be stetched so the 20x20 red square to cover the entire render box?
Itryed all the createTexture options but none do this.

Altren

23-09-2010 03:45:05

When you change canvas size it creates POT texture with size not smaller than widget size, and it shows texture part equal to widget size.
You can do next thing: create texture using MyGUI::Canvas or Ogre and then set it on StaticImage.
std::string textureName = canvas->getTextureName();
staticImage->setImageTexture(textureName);
staticImage->setImageCoord(MyGUI::IntCoord(0, 0, 20, 20));