Alpha pixel value turn to full opaque after lock()

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.
Post Reply
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Alpha pixel value turn to full opaque after lock()

Post by kornwaretm »

i am trying to implement marching cube to create polygon shapes out of ITexture for 2D physic game. the process requires pixel access. here is the code i use for getting the texels.

Code: Select all

 
core::dimension2d<u32> dimension = texture->getOriginalSize();
u8 * texels = (u8 *)texture->lock(video::ETLM_READ_ONLY, 0);
u32 pitch = texture->getPitch();
video::ECOLOR_FORMAT format = texture->getColorFormat();
u32 bytes = video::IImage::getBitsPerPixelFromFormat(format) / 8;
 
somehow the alpha channel value of the texels are always full opaque (255). if i change ETLM_READ_ONLY to ETLM_READ_WRITE, the transparent area of the texture turn to black opaque color. i also try to change u8 * texels to u32* which is does not make any sense at all since they are bits not bytes right? another odd thing is, if i immediately execute this process, before driver->endscene() it works just fine.

this strange behavior occurred when i update irrlicht. is it a bug? or my code is wrong?

thanks in advance.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Alpha pixel value turn to full opaque after lock()

Post by CuteAlien »

There might be a bug. I know I got one in fonts which sounds similar, but haven't managed yet to figure out too much as my test-case to reproduce it is still rather complicated. If you got a simpler that would be great. If it's the same the following workaround will probably fix it for now:

Code: Select all

 
Driver->setTextureCreationFlag(video::ETCF_ALLOW_MEMORY_COPY, true);
 
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Re: Alpha pixel value turn to full opaque after lock()

Post by kornwaretm »

hai CuteAlien. thanks for the reply. yes the texture creation flag solve my problem. about the simple test. do you still need it? how do you want it? is codeblock project ok?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Alpha pixel value turn to full opaque after lock()

Post by CuteAlien »

If you have a simple test - sure - would be great. cpp file is enough, c::b also ok.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Re: Alpha pixel value turn to full opaque after lock()

Post by kornwaretm »

here is the file http://s000.tinyupload.com/index.php?fi ... 1091381843
i hope it is sufficient for the case.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Alpha pixel value turn to full opaque after lock()

Post by CuteAlien »

Thanks a lot! I will look at it again when I'm back to working on that bug (will take a while).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Alpha pixel value turn to full opaque after lock()

Post by CuteAlien »

Sorry took 3 years to get to this item on my todo-list and the test-case is gone by now :-(. But although I don't have this specific test-case anymore, the problem is still potentially fixed. There's been several fixes in trunk with regard to lock() and color formats problems so by now (currently r5887) this is likely working as well.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply