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.