Page 1 of 1

Alpha pixel value turn to full opaque after lock()

Posted: Wed Dec 14, 2016 2:46 am
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.

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

Posted: Wed Dec 14, 2016 11:59 am
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);
 

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

Posted: Thu Dec 22, 2016 2:19 pm
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?

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

Posted: Thu Dec 22, 2016 2:20 pm
by CuteAlien
If you have a simple test - sure - would be great. cpp file is enough, c::b also ok.

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

Posted: Thu Dec 22, 2016 4:10 pm
by kornwaretm
here is the file http://s000.tinyupload.com/index.php?fi ... 1091381843
i hope it is sufficient for the case.

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

Posted: Thu Dec 22, 2016 4:54 pm
by CuteAlien
Thanks a lot! I will look at it again when I'm back to working on that bug (will take a while).

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

Posted: Wed Oct 16, 2019 2:08 pm
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.