Page 1 of 1

2d graphics - can they be scaled ?

Posted: Sat Oct 29, 2005 9:03 am
by Alien
ITexture* texture = driver->getTexture("../../media/irrlichtlogoalpha.tga");
env->addImage(texture,core::position2d<s32>(10,10));

Is it possible to change the size of an image using Irrlicht. That is, instead of just displaying the loaded image, you can actually stretch the image so its larger.

I noticed you could lock the texture, and get the pixels...what sort of structure would i use to get the data so i could modify it ?

Posted: Sun Oct 30, 2005 2:07 pm
by CZestmyr
I'm accessing the texture data in my new fire scene node, you can have a look at it, but basicaly you just have to do this:

Code: Select all

u8* pixels = (u8*) texture->lock();
for (u32 i = 0; i < pixelNum; i++){
    pixels[i * 4] .. //do whatever with the blue component
    pixels[i * 4 + 1] .. //green component
    pixels[i * 4 + 2] .. //red component
    //[i * 4 + 3] could be the alpha value, but I haven't tried it
}
Of course, this just works, when you have the A8R8G8B8 format, but the others should be similar.

Posted: Sun Oct 30, 2005 3:57 pm
by Alien
Cool :D Ever played old games like Unreal, and seen how the textures have ripple effects and the pixels undergo filters....this will allow for the same thing :) But as for scaling textures, this doesn't really help. Is there a way to give a texture a new array of pixels ?