If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Gorgon Zola
Posts: 118 Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland
Post
by Gorgon Zola » Fri Oct 03, 2003 3:05 pm
Hi,
does anyone know how i can manipulate the pixels in a texture?
i tried the following, but this doesn't work of course
Code: Select all
void updateTexture(){
perlin->makeNoise(CGlobalTimer::theTimer.getTime()/400.0f);
dimension2d<s32> dim = texture->getDimension();
s32 pitch = texture->getPitch();
s16 *p = (s16*)texture->lock();
for (int x=0; x<dim.Width; x++){
for (int y=0; y<dim.Height; y++) {
p[y*pitch + x]=(s16)perlin->map[x+y*perlin->size()];
}
}
texture->unlock();
}
the code throws an illegal access error
is it possible to alter textures after loading at all or do i have to try some other way??
thanks for help
gorgon
niko
Site Admin
Posts: 1759 Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:
Post
by niko » Fri Oct 03, 2003 4:37 pm
Your code is ok, it should work. But maybe I've overseen something..
Gorgon Zola
Posts: 118 Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland
Post
by Gorgon Zola » Fri Oct 03, 2003 5:00 pm
what meaning does pitch have? is it the row width of the texture image in pixels? (equal to dimension.Width??)
i wonder because i have added a texture with
videoDriver->addTexture(dimension2d<s32>(64,64),"perlin");
if i get the pitch of the texture it says 128 , i'd have expected it to be 64 .
niko
Site Admin
Posts: 1759 Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:
Post
by niko » Fri Oct 03, 2003 6:10 pm
It should be the width of the texture in bytes.
It is more clearer in the next version of the engine.
Gorgon Zola
Posts: 118 Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland
Post
by Gorgon Zola » Sat Oct 04, 2003 12:46 pm
niko wrote: It should be the width of the texture in bytes.
It is more clearer in the next version of the engine.
actually it's very clear.
You've mentioned it in the header file, shame on me!
I just changed the pitch value to half its size and now it works....
thanks