hey.. i use different resolutions when i create my window and i want to be able to resize the images accordingly too (for example: the background image is 800x600, i open the window at 640x480, i want to resize the background image to 640x480). Any way of doing this with IGUIImage, or i have to do it with another interface.. If yes, then which\how?
thanks a lot
resize IGUIImage?
i tried:
it does resize the texture, but it cuts it off at the size of the original image (so i actually only see 1\4 of the image, the top-left part of it)..
please help me on this one. thanks
Code: Select all
bg_img = env->addImage(env->getScreenRect(rect<f32>(0, 0, 1, 1)));
ITexture *img = driver->getTexture("data/texture/bg.tga");
core::matrix4& tran = img->getTransformation();
tran.setScale(core::vector3df(0.5f,0.5f,0.5f));
bg_img->setImage(img);please help me on this one. thanks
-
harukiblue
- Posts: 49
- Joined: Sun Dec 10, 2006 6:23 pm
Is there a reason you are accessing the transfermation matrix by reference and not ussing a pointer?
Shouldn't this be . . .
or try this
Hope this helps!
Code: Select all
core::matrix4& tran = img->getTransformation();
tran.setScale(core::vector3df(0.5f,0.5f,0.5f));
Code: Select all
core::matrix4* tran = img->getTransformation();
tran->setScale(core::vector3df(0.5f,0.5f,0.5f));
Code: Select all
bg_img = env->addImage(env->getScreenRect(rect<f32>(0, 0, 640, 480)));
bg_img->setImage("data/texture/bg.tga"); thanks for trying but "core::matrix4&" is correct, "core::matrix4*" is not (compiler error).
and it should be "bg_img->setImage(driver->getTexture("data/texture/bg.tga"));", not "bg_img->setImage("data/texture/bg.tga");", but that doesn't work, it just makes it so you can only see the 640x480 pixels of the image (it just cuts the image off so it fits the rectange, it doesn't resize it).
and it should be "bg_img->setImage(driver->getTexture("data/texture/bg.tga"));", not "bg_img->setImage("data/texture/bg.tga");", but that doesn't work, it just makes it so you can only see the 640x480 pixels of the image (it just cuts the image off so it fits the rectange, it doesn't resize it).
-
hybrid
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
The texture matrix cannot scale the image, it works on the texture coords. So when using original coord (1,1) you would get (0.5,0.5) with your scale factor. And that makes your texture stretch one fourth of itself to the whole image. But indeed the reference is correct, there's always a proper matrix (only for Irrlicht 1.2, though, as this will change for the next release).
But shouldn't the image resize automatically? It's using a pretty simple scaling, though, which will give some artifacts in your image. Thus it's better to have iomages with different resolutions.
But shouldn't the image resize automatically? It's using a pretty simple scaling, though, which will give some artifacts in your image. Thus it's better to have iomages with different resolutions.